-
Notifications
You must be signed in to change notification settings - Fork 38
Expand file tree
/
Copy pathMakefile
More file actions
121 lines (105 loc) · 4.84 KB
/
Makefile
File metadata and controls
121 lines (105 loc) · 4.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
.PHONY: help build release test app dmg zip clean run debug debug-logs debug-app debug-file notices
APP_NAME := CodMate
VER ?= 0.1.0
BUILD_NUMBER_STRATEGY ?= date
APP_DIR ?= build/CodMate.app
OUTPUT_DIR ?= artifacts/release
# Default arch for local builds
ARCH_NATIVE := $(shell uname -m)
ARCH ?= $(ARCH_NATIVE)
help: ## Show this help message
@echo "CodMate - macOS SwiftPM App"
@echo ""
@echo "Available targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
build: ## SwiftPM debug build
@swift build
release: ## SwiftPM release build
@swift build -c release
test: ## Run SwiftPM tests (if any)
@swift test
notices: ## Update THIRD-PARTY-NOTICES.md
@python3 scripts/gen-third-party-notices.py
app: ## Build CodMate.app (ARCH=arm64|x86_64|"arm64 x86_64")
@if [ -z "$(VER)" ]; then echo "error: VER is required (e.g., VER=1.2.3)"; exit 1; fi
@VER=$(VER) BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$(ARCH)" APP_DIR=$(APP_DIR) \
./scripts/create-app-bundle.sh
run: ## Build and launch CodMate.app (native arch, inferred version)
@VER_RUN=$${VER:-$$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)}; \
ARCH_NATIVE=$$(uname -m); \
VER="$$VER_RUN" BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$$ARCH_NATIVE" APP_DIR=$(APP_DIR) STRIP=0 SWIFT_CONFIG=debug \
SIGN_ADHOC=1 \
./scripts/create-app-bundle.sh; \
open "$(APP_DIR)"
debug: ## Build and run with terminal output (prints to stdout/stderr)
@echo "Building CodMate.app for debug..."
@VER_RUN=$${VER:-$$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)}; \
ARCH_NATIVE=$$(uname -m); \
VER="$$VER_RUN" BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$$ARCH_NATIVE" APP_DIR=$(APP_DIR) STRIP=0 SWIFT_CONFIG=debug \
SIGN_ADHOC=1 \
./scripts/create-app-bundle.sh
@echo ""
@echo "Starting CodMate with terminal output..."
@echo "Press Ctrl+C to stop"
@echo "========================================"
@"$(APP_DIR)/Contents/MacOS/CodMate"
debug-app: ## Build, launch app in background, and stream logs in foreground
@echo "Building and launching CodMate.app..."
@VER_RUN=$${VER:-$$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)}; \
ARCH_NATIVE=$$(uname -m); \
VER="$$VER_RUN" BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$$ARCH_NATIVE" APP_DIR=$(APP_DIR) STRIP=0 SWIFT_CONFIG=debug \
SIGN_ADHOC=1 \
./scripts/create-app-bundle.sh
@open "$(APP_DIR)"
@sleep 1
@echo ""
@echo "Streaming logs from CodMate (Ctrl+C to stop)..."
@echo "========================================"
@log stream --predicate 'processImagePath CONTAINS "CodMate"' --style compact
debug-logs: ## Stream live logs from running CodMate app (use with 'make run' in another terminal)
@echo "Streaming logs from CodMate (Ctrl+C to stop)..."
@echo "========================================"
@log stream --predicate 'processImagePath CONTAINS "CodMate"' --style compact
debug-file: ## Build and run with output to both terminal and logs/debug.log
@echo "Building CodMate.app for debug..."
@VER_RUN=$${VER:-$$(git describe --tags --abbrev=0 2>/dev/null || echo 0.0.0)}; \
ARCH_NATIVE=$$(uname -m); \
VER="$$VER_RUN" BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$$ARCH_NATIVE" APP_DIR=$(APP_DIR) STRIP=0 SWIFT_CONFIG=debug \
SIGN_ADHOC=1 \
./scripts/create-app-bundle.sh
@mkdir -p logs
@echo ""
@echo "Starting CodMate with output to terminal and file..."
@echo "Log file: logs/debug.log"
@echo "Press Ctrl+C to stop"
@echo "========================================"
@"$(APP_DIR)/Contents/MacOS/CodMate" 2>&1 | tee logs/debug.log
dmg: ## Build Developer ID DMG (ARCH=arm64|x86_64|"arm64 x86_64")
@if [ -z "$(VER)" ]; then echo "error: VER is required (e.g., VER=1.2.3)"; exit 1; fi
@VER=$(VER) BUILD_NUMBER_STRATEGY=$(BUILD_NUMBER_STRATEGY) \
ARCH_MATRIX="$(ARCH)" APP_DIR=$(APP_DIR) OUTPUT_DIR=$(OUTPUT_DIR) \
./scripts/macos-build-notarized-dmg.sh
zip: ## Create zip archives from DMG files (one zip per arch, requires dmg first, VER=1.2.3)
@if [ -z "$(VER)" ]; then echo "error: VER is required (e.g., VER=1.2.3)"; exit 1; fi
@if [ ! -d "$(OUTPUT_DIR)" ]; then echo "error: OUTPUT_DIR $(OUTPUT_DIR) does not exist. Run 'make dmg' first."; exit 1; fi
@DMG_FILES=$$(find "$(OUTPUT_DIR)" -name "codmate-*.dmg" 2>/dev/null | sort); \
if [ -z "$$DMG_FILES" ]; then \
echo "error: No DMG files found in $(OUTPUT_DIR). Run 'make dmg' first."; \
exit 1; \
fi; \
echo "Creating zip archives from DMG files..."; \
cd "$(OUTPUT_DIR)" && \
for dmg_file in $$DMG_FILES; do \
dmg_basename=$$(basename "$$dmg_file" .dmg); \
zip_name="$$dmg_basename.zip"; \
echo " Creating: $$zip_name"; \
zip -q "$$zip_name" "$$dmg_basename.dmg"; \
done; \
echo "Zip archives created in $(OUTPUT_DIR)"
clean: ## Clean build artifacts
@rm -rf .build build $(APP_DIR) artifacts