|
| 1 | +.PHONY: build clean dmg test help |
| 2 | + |
| 3 | +# 변수 설정 |
| 4 | +PROJECT = TextOverlay.xcodeproj |
| 5 | +SCHEME = TextOverlay |
| 6 | +CONFIGURATION = Release |
| 7 | +BUILD_DIR = .build |
| 8 | +DMG_DIR = $(BUILD_DIR)/dmg |
| 9 | +APP_NAME = TextOverlay |
| 10 | +VERSION ?= $(shell git describe --tags --always) |
| 11 | + |
| 12 | +help: ## Show this help message |
| 13 | + @echo "Available targets:" |
| 14 | + @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}' |
| 15 | + |
| 16 | +clean: ## Clean build artifacts |
| 17 | + @echo "🧹 Cleaning build artifacts..." |
| 18 | + rm -rf $(BUILD_DIR) |
| 19 | + rm -rf $(DMG_DIR) |
| 20 | + xcodebuild clean -project $(PROJECT) -scheme $(SCHEME) -configuration $(CONFIGURATION) |
| 21 | + |
| 22 | +build: ## Build the app |
| 23 | + @echo "🔨 Building $(APP_NAME)..." |
| 24 | + xcodebuild -project $(PROJECT) \ |
| 25 | + -scheme $(SCHEME) \ |
| 26 | + -configuration $(CONFIGURATION) \ |
| 27 | + -derivedDataPath $(BUILD_DIR) \ |
| 28 | + build |
| 29 | + |
| 30 | +test: build ## Test the built app |
| 31 | + @echo "🧪 Testing $(APP_NAME)..." |
| 32 | + @APP_PATH="$(BUILD_DIR)/Build/Products/$(CONFIGURATION)/$(APP_NAME).app"; \ |
| 33 | + if [ ! -d "$$APP_PATH" ]; then \ |
| 34 | + echo "❌ App not found at $$APP_PATH"; \ |
| 35 | + exit 1; \ |
| 36 | + fi; \ |
| 37 | + echo "✅ App exists at $$APP_PATH"; \ |
| 38 | + \ |
| 39 | + if [ ! -f "$$APP_PATH/Contents/MacOS/$(APP_NAME)" ]; then \ |
| 40 | + echo "❌ Executable not found"; \ |
| 41 | + exit 1; \ |
| 42 | + fi; \ |
| 43 | + echo "✅ Executable found"; \ |
| 44 | + \ |
| 45 | + codesign -dv "$$APP_PATH" 2>&1 | grep -q "Signature" && \ |
| 46 | + echo "✅ App is signed" || \ |
| 47 | + echo "⚠️ App is not signed (expected for local builds)"; \ |
| 48 | + \ |
| 49 | + file "$$APP_PATH/Contents/MacOS/$(APP_NAME)" | grep -q "Mach-O" && \ |
| 50 | + echo "✅ Valid Mach-O executable" || \ |
| 51 | + (echo "❌ Invalid executable format"; exit 1); \ |
| 52 | + \ |
| 53 | + echo "🚀 Running smoke test..."; \ |
| 54 | + "$$APP_PATH/Contents/MacOS/$(APP_NAME)" "Build Test" --position top,left & \ |
| 55 | + APP_PID=$$!; \ |
| 56 | + sleep 9; \ |
| 57 | + if kill -0 $$APP_PID 2>/dev/null; then \ |
| 58 | + echo "✅ App launched successfully"; \ |
| 59 | + kill $$APP_PID 2>/dev/null; \ |
| 60 | + else \ |
| 61 | + echo "⚠️ App exited unexpectedly"; \ |
| 62 | + fi; \ |
| 63 | + \ |
| 64 | + echo "✅ All tests passed" |
| 65 | + |
| 66 | +dmg: test ## Create DMG file |
| 67 | + @echo "📦 Creating DMG for $(APP_NAME) $(VERSION)..." |
| 68 | + @mkdir -p $(DMG_DIR) |
| 69 | + @rm -f $(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg |
| 70 | + |
| 71 | + # create-dmg 설치 확인 |
| 72 | + @if ! command -v create-dmg &> /dev/null; then \ |
| 73 | + echo "⚠️ create-dmg not found. Installing..."; \ |
| 74 | + brew install create-dmg; \ |
| 75 | + fi |
| 76 | + |
| 77 | + # DMG 생성 |
| 78 | + create-dmg \ |
| 79 | + --volname "$(APP_NAME)" \ |
| 80 | + --window-pos 200 120 \ |
| 81 | + --window-size 600 400 \ |
| 82 | + --icon-size 100 \ |
| 83 | + --icon "$(APP_NAME).app" 175 120 \ |
| 84 | + --hide-extension "$(APP_NAME).app" \ |
| 85 | + --app-drop-link 425 120 \ |
| 86 | + "$(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg" \ |
| 87 | + "$(BUILD_DIR)/Build/Products/$(CONFIGURATION)/$(APP_NAME).app" |
| 88 | + |
| 89 | + @echo "✅ DMG created: $(DMG_DIR)/$(APP_NAME)-$(VERSION).dmg" |
| 90 | + |
| 91 | +version: ## Show current version |
| 92 | + @echo "Current version: $(VERSION)" |
| 93 | + |
| 94 | +.DEFAULT_GOAL := help |
0 commit comments