Skip to content

Commit

Permalink
Add makefile for simple builds and install
Browse files Browse the repository at this point in the history
Signed-off-by: Ethan Dye <[email protected]>
  • Loading branch information
ecdye committed Nov 2, 2024
1 parent ac2f147 commit b4b85f4
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 6 deletions.
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ An Apple M series processor is required for macSubtitleOCR, PRs adding additiona
> [!IMPORTANT]
> macSubtitleOCR requires Swift 6 support to compile
Follow the directions below to compile the project with your desired support option.
The final build will be available in the `.build/release` directory.
To make and install the project, follow the directions below:

### Build Internal Decoder Only

Expand All @@ -40,7 +39,8 @@ To build macSubtitleOCR, follow these steps:
``` shell
git clone https://github.com/ecdye/macSubtitleOCR
cd macSubtitleOCR
swift build --configuration release
make
sudo make install
```

### Build With FFmpeg Decoder
Expand All @@ -51,9 +51,8 @@ To build with FFmpeg support, follow these steps:
brew install ffmpeg
git clone https://github.com/ecdye/macSubtitleOCR
cd macSubtitleOCR
mv Package.swift Package.internal.swift
mv Package.ffmpeg.swift Package.swift
swift build -Xswiftc -DFFMPEG --configuration release
make ffmpeg
sudo make install_ffmpeg
```

## Running Tests
Expand Down
67 changes: 67 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
.PHONY: all internal ffmpeg reset help install install_ffmpeg clean

# Default configuration
CONFIGURATION ?= release

# Validate CONFIGURATION
ifneq ($(CONFIGURATION),release)
ifneq ($(CONFIGURATION),debug)
$(error CONFIGURATION must be either 'release' or 'debug')
endif
endif

all: internal

internal:
@echo "Building internal $(CONFIGURATION) version..."
xcrun swift build --configuration $(CONFIGURATION) --arch arm64

ffmpeg:
@echo "Building FFmpeg $(CONFIGURATION) version..."
@if ! command -v ffmpeg &> /dev/null; then \
echo "FFmpeg is not installed. Please install FFmpeg and try again."; \
exit 1; \
fi
@if [ -f Package.internal.swift ] && [ -f Package.ffmpeg.swift ]; then \
mv Package.swift Package.internal.swift; \
mv Package.ffmpeg.swift Package.swift; \
xcrun swift build -Xswiftc -DFFMPEG --configuration $(CONFIGURATION) --arch arm64; \
$(MAKE) reset; \
else \
echo "Error: Package.internal.swift or Package.ffmpeg.swift not found."; \
exit 1; \
fi

reset:
@if [ -f Package.internal.swift ] && [ -f Package.swift ]; then \
mv Package.swift Package.ffmpeg.swift; \
mv Package.internal.swift Package.swift; \
echo "Package files reset."; \
else \
echo "Error: Package.internal.swift or Package.swift not found for reset."; \
exit 1; \
fi

install: internal
@echo "Installing macSubtitleOCR..."
install -m 755 .build/$(CONFIGURATION)/macSubtitleOCR /usr/local/bin

install_ffmpeg: ffmpeg
@echo "Installing macSubtitleOCR with FFmpeg support..."
install -m 755 .build/$(CONFIGURATION)/macSubtitleOCR /usr/local/bin

clean: reset
@echo "Cleaning build artifacts..."
rm -rf .build

help:
@echo "Usage: make [internal|ffmpeg|install|install_ffmpeg|reset|clean] [CONFIGURATION=release|debug]"
@echo "Targets:"
@echo " internal - Build the internal version (default: release)"
@echo " ffmpeg - Build the FFmpeg version (default: release)"
@echo " install - Install the application"
@echo " install_ffmpeg - Install the application with FFmpeg support"
@echo " reset - Reset the package files"
@echo " clean - Clean the build artifacts"
@echo "Variables:"
@echo " CONFIGURATION - Build configuration (release or debug, default: release)"

0 comments on commit b4b85f4

Please sign in to comment.