-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathMakefile
More file actions
165 lines (134 loc) · 5.67 KB
/
Makefile
File metadata and controls
165 lines (134 loc) · 5.67 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
SHELL := /bin/bash
SWIFT := swift
XCODEBUILD := xcodebuild
XCODEGEN := xcodegen
PRODUCT_APP := KumoApp
PRODUCT_CLI := kumo
APP_BUNDLE_ID := io.kumo.KumoApp
SCHEME_APP := KumoApp
SCHEME_PACKAGE := Kumo-Package
PROJECT := Kumo.xcodeproj
DERIVED_DATA := build
APP_PATH_DEBUG := $(DERIVED_DATA)/Build/Products/Debug/Kumo.app
APP_PATH_RELEASE := $(DERIVED_DATA)/Build/Products/Release/Kumo.app
SERVICE_PATH_DEBUG := $(DERIVED_DATA)/Build/Products/Debug/KumoService
SERVICE_PATH_RELEASE := $(DERIVED_DATA)/Build/Products/Release/KumoService
RELEASE_OUTPUT := $(DERIVED_DATA)/release
DESTINATION ?= platform=macOS
BUILD_NUMBER ?= 1
SUBSTORE_RUNTIME_SCRIPT := Scripts/prepare_substore_runtime.sh
.DEFAULT_GOAL := help
.PHONY: help
help: ## Show available commands.
@awk 'BEGIN {FS = ":.*##"; printf "Kumo development commands:\n\n"} /^[a-zA-Z0-9_-]+:.*##/ {printf " %-18s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: generate
generate: ## Regenerate the Xcode project from project.yml using XcodeGen.
$(XCODEGEN) generate
.PHONY: prepare-substore-runtime
prepare-substore-runtime: ## Download the generated Sub-Store Node runtime into local resources.
bash $(SUBSTORE_RUNTIME_SCRIPT)
.PHONY: app
app: generate ## Build the Kumo .app bundle in Debug to build/Build/Products/Debug.
$(MAKE) prepare-substore-runtime
$(XCODEBUILD) -project $(PROJECT) -scheme $(SCHEME_APP) -configuration Debug -derivedDataPath $(DERIVED_DATA) build
@if [ -x "$(SERVICE_PATH_DEBUG)" ]; then \
mkdir -p "$(APP_PATH_DEBUG)/Contents/MacOS"; \
cp "$(SERVICE_PATH_DEBUG)" "$(APP_PATH_DEBUG)/Contents/MacOS/KumoService"; \
chmod 755 "$(APP_PATH_DEBUG)/Contents/MacOS/KumoService"; \
fi
.PHONY: app-release
app-release: generate ## Build the Kumo .app bundle in Release to build/Build/Products/Release.
$(MAKE) prepare-substore-runtime
$(XCODEBUILD) -project $(PROJECT) -scheme $(SCHEME_APP) -configuration Release -derivedDataPath $(DERIVED_DATA) build $(if $(VERSION),MARKETING_VERSION="$(VERSION)" CURRENT_PROJECT_VERSION="$(BUILD_NUMBER)",)
@if [ -x "$(SERVICE_PATH_RELEASE)" ]; then \
mkdir -p "$(APP_PATH_RELEASE)/Contents/MacOS"; \
cp "$(SERVICE_PATH_RELEASE)" "$(APP_PATH_RELEASE)/Contents/MacOS/KumoService"; \
chmod 755 "$(APP_PATH_RELEASE)/Contents/MacOS/KumoService"; \
fi
.PHONY: require-release-version
require-release-version:
@test -n "$(VERSION)" || { echo "Set VERSION, for example: make release-dmg VERSION=0.0.1"; exit 1; }
.PHONY: release-dmg
release-dmg: require-release-version ## Build release app, DMG, and latest.yml. Requires VERSION=0.0.1.
$(MAKE) app-release VERSION="$(VERSION)" BUILD_NUMBER="$(BUILD_NUMBER)"
VERSION="$(VERSION)" CHANNEL="$(CHANNEL)" OUTPUT_DIR="$(RELEASE_OUTPUT)" APP_PATH="$(APP_PATH_RELEASE)" bash Scripts/make_release_artifacts.sh
.PHONY: release-artifacts
release-artifacts: release-dmg ## Alias for release-dmg.
.PHONY: release-manifest
release-manifest: release-dmg ## Alias for release-dmg; latest.yml is emitted beside the DMG.
.PHONY: quit-app
quit-app: ## Quit a running Kumo app before replacing the debug bundle.
@osascript -e 'tell application id "$(APP_BUNDLE_ID)" to quit' >/dev/null 2>&1 || true
@for attempt in 1 2 3 4 5 6 7 8 9 10; do \
if pgrep -x "Kumo" >/dev/null; then \
sleep 0.2; \
else \
break; \
fi; \
done
@if pgrep -x "Kumo" >/dev/null; then \
echo "Kumo is still running; sending SIGTERM before rebuilding."; \
pkill -TERM -x "Kumo"; \
fi
.PHONY: clean-debug-app
clean-debug-app: ## Remove the debug app bundle before rebuilding it.
rm -rf "$(APP_PATH_DEBUG)"
.PHONY: dev
dev: ## Quit any running Kumo, build, and open the debug .app bundle.
$(MAKE) quit-app
$(MAKE) clean-debug-app
$(MAKE) app
open -n "$(APP_PATH_DEBUG)"
.PHONY: dev-cli
dev-cli: ## Run the SwiftUI macOS app via swift run (no .app bundle).
$(MAKE) prepare-substore-runtime
$(SWIFT) run $(PRODUCT_APP)
.PHONY: check
check: build test cli-status ## Build with Xcode, test, and verify the CLI status output.
.PHONY: build
build: app ## Build the Kumo .app bundle (alias for `make app`).
.PHONY: xcode-list
xcode-list: generate ## List Xcode schemes.
$(XCODEBUILD) -project $(PROJECT) -list
.PHONY: xcode-build
xcode-build: app ## Build the KumoApp scheme via xcodebuild.
.PHONY: xcode-test
xcode-test: ## Run package tests via xcodebuild.
$(XCODEBUILD) -scheme $(SCHEME_PACKAGE) -destination '$(DESTINATION)' test
.PHONY: swift-build
swift-build: ## Build all Swift package products in debug mode.
$(MAKE) prepare-substore-runtime
$(SWIFT) build
.PHONY: build-release
build-release: ## Build all Swift package products in release mode.
$(MAKE) prepare-substore-runtime
$(SWIFT) build -c release
.PHONY: test
test: xcode-test ## Run unit tests with Xcode CLI.
.PHONY: swift-test
swift-test: ## Run unit tests with SwiftPM.
$(SWIFT) test
.PHONY: run-cli
run-cli: ## Run the Kumo CLI. Override ARGS, for example: make run-cli ARGS="status --json".
$(MAKE) prepare-substore-runtime
$(SWIFT) run $(PRODUCT_CLI) $(ARGS)
.PHONY: cli-status
cli-status: ## Print CLI status as JSON.
$(SWIFT) run $(PRODUCT_CLI) status --json
.PHONY: cli-sysproxy-dry-run
cli-sysproxy-dry-run: ## Show system proxy commands without applying them.
$(SWIFT) run $(PRODUCT_CLI) sysproxy on --dry-run --json
.PHONY: docs
docs: ## List technical documentation files.
@printf "Technical docs:\n"
@find docs -name '*.md' | sort
.PHONY: clean
clean: ## Remove Swift build artifacts.
$(SWIFT) package clean
rm -rf $(DERIVED_DATA)
.PHONY: xcode-clean
xcode-clean: ## Clean the KumoApp scheme via xcodebuild.
$(XCODEBUILD) -project $(PROJECT) -scheme $(SCHEME_APP) -configuration Debug clean
.PHONY: reset-local-state
reset-local-state: ## Remove local Kumo application support data.
rm -rf "$$HOME/Library/Application Support/Kumo"