-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
223 lines (191 loc) · 9.25 KB
/
Copy pathMakefile
File metadata and controls
223 lines (191 loc) · 9.25 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
.PHONY: help build build-release build-macos run test test-all install clean \
release release-patch release-minor bump-formula wait-for-release-assets smoke-test \
bench-all bench-startup bench-playback bench-pause bench-memory bench-cpu \
bench-profile bench-watch bench-results bench-analyze bench-clean
BINARY := looper
INSTALL_DIR := /usr/local/bin
FIXTURE := tests/fixtures/sound.mp3
TAP_REPO := https://github.com/program247365/homebrew-tap.git
TAP_DIR := /tmp/homebrew-tap-update
VERSION := $(shell cargo metadata --no-deps --format-version 1 | python3 -c "import sys,json;print(json.load(sys.stdin)['packages'][0]['version'])")
help: ## Show available targets
@awk 'BEGIN {FS = ":.*##"; printf "Usage: make \033[36m<target>\033[0m\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-16s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
# ── Local development ─────────────────────────────────────────────────────────
#
# NOTE: `vergen` is pinned to 9.0.6 in Cargo.lock to keep librespot-core's build
# script compiling (see the note in Cargo.toml). If a build fails with a
# vergen-lib trait mismatch after `cargo update`, re-pin with:
# cargo update -p vergen --precise 9.0.6
build: ## Build debug binary
cargo build
build-release: ## Build optimized release binary
cargo build --release
build-macos: ## Build release binary for x86_64 macOS
cargo build --target=x86_64-apple-darwin --release
run: ## Play the fixture audio file on loop (Ctrl+C to stop)
cargo run -- play --url $(FIXTURE)
test: ## Run non-interactive tests
cargo test
test-all: ## Run all tests including those requiring audio output
cargo test -- --ignored
install: build-release ## Install release binary to $(INSTALL_DIR)
sudo install -m 755 target/release/$(BINARY) $(INSTALL_DIR)/$(BINARY)
@find target/release/build -name '*.dylib' | while read DYLIB_SRC; do \
DYLIB_NAME=$$(basename $$DYLIB_SRC); \
DYLIB_OLD=$$(otool -L $(INSTALL_DIR)/$(BINARY) | awk -v n="$$DYLIB_NAME" '$$0 ~ n {print $$1}'); \
if [ -n "$$DYLIB_OLD" ]; then \
sudo install -m 644 $$DYLIB_SRC /usr/local/lib/$$DYLIB_NAME; \
sudo install_name_tool -change $$DYLIB_OLD /usr/local/lib/$$DYLIB_NAME $(INSTALL_DIR)/$(BINARY); \
fi; \
done
clean: ## Remove build artifacts
cargo clean
# ── Performance Benchmarking ──────────────────────────────────────────────────
# Usage:
# make bench-all — Run all benchmarks
# make bench-startup — Measure startup time and initial memory
# make bench-playback — Measure memory/CPU during playback
# make bench-pause — Measure pause behavior
# make bench-memory — Deep memory profiling
# make bench-cpu — CPU profiling
# make bench-profile — Full profiling session (100s+)
# make bench-watch — Real-time memory monitoring
# make bench-results — Show latest results
# make bench-analyze — Analyze results and identify memory hogs
# make bench-clean — Clean benchmark results
BENCH_DIR := bench
BENCH_SCRIPTS := $(BENCH_DIR)/scripts
BENCH_RESULTS := $(BENCH_DIR)/results
bench-setup:
@mkdir -p $(BENCH_RESULTS)
@$(MAKE) build-release
bench-all: bench-setup ## Run all performance benchmarks
@echo "=== Running Full Benchmark Suite ==="
@$(MAKE) bench-startup
@$(MAKE) bench-playback
@$(MAKE) bench-pause
@$(MAKE) bench-memory
@$(MAKE) bench-cpu
@echo ""
@echo "=== Benchmark Complete ==="
@$(MAKE) bench-results
bench-startup: bench-setup ## Measure startup performance
@$(BENCH_SCRIPTS)/bench-startup.sh
bench-playback: bench-setup ## Measure playback performance (30s)
@$(BENCH_SCRIPTS)/bench-playback.sh
bench-pause: bench-setup ## Measure pause behavior
@$(BENCH_SCRIPTS)/bench-pause.sh
bench-memory: bench-setup ## Deep memory profiling (2min)
@$(BENCH_SCRIPTS)/memory-profile.sh
bench-cpu: bench-setup ## CPU profiling (30s)
@$(BENCH_SCRIPTS)/cpu-profile.sh
bench-profile: bench-setup ## Full profiling session (~100s)
@$(BENCH_SCRIPTS)/full-profile.sh
bench-watch: ## Real-time memory monitoring (Ctrl+C to stop)
@$(BENCH_SCRIPTS)/watch-memory.sh
bench-results: ## Show latest benchmark results
@echo "=== Latest Benchmark Results ==="
@if [ -d $(BENCH_RESULTS) ] && [ -n "$$(ls -A $(BENCH_RESULTS) 2>/dev/null)" ]; then \
echo ""; \
echo "Startup:"; \
ls -t $(BENCH_RESULTS)/startup_*.txt 2>/dev/null | head -1 | xargs tail -n +2 || echo " No results"; \
echo ""; \
echo "Playback:"; \
ls -t $(BENCH_RESULTS)/playback_*_summary.txt 2>/dev/null | head -1 | xargs tail -n +2 || echo " No results"; \
echo ""; \
echo "Memory Profile:"; \
ls -t $(BENCH_RESULTS)/memory_profile_*_summary.txt 2>/dev/null | head -1 | xargs tail -n +2 || echo " No results"; \
echo ""; \
echo "All results in: $(BENCH_RESULTS)/"; \
else \
echo "No results found. Run 'make bench-all' first."; \
fi
bench-analyze: ## Analyze results and identify memory hogs
@$(BENCH_SCRIPTS)/analyze-results.sh
bench-clean: ## Clean benchmark results
@echo "Cleaning benchmark results..."
@rm -rf $(BENCH_RESULTS)/*
@echo "✓ Clean complete"
# ── Homebrew release workflow ─────────────────────────────────────────────────
# Usage:
# make release — tag current Cargo.toml version, push, publish release, update formula
# make release-patch — bump patch version (0.1.0 → 0.1.1), then release
# make release-minor — bump minor version (0.1.x → 0.2.0), then release
release-patch: ## Bump patch version and release
cargo install cargo-edit 2>/dev/null || true
cargo set-version --bump patch
$(MAKE) release
release-minor: ## Bump minor version and release
cargo install cargo-edit 2>/dev/null || true
cargo set-version --bump minor
$(MAKE) release
release: ## Tag, push, wait for CI binaries, then update Homebrew tap
@echo "Releasing v$(VERSION)..."
git add Cargo.toml Cargo.lock
git diff --cached --quiet || git commit -m "Bump version to v$(VERSION)"
git tag v$(VERSION)
git push origin main
git push origin v$(VERSION)
@echo "Tag pushed. CI will build binaries and create the GitHub release."
$(MAKE) bump-formula
wait-for-release-assets: ## Wait until the arm64 tarball is attached to the GH release
@echo "Waiting for v$(VERSION) arm64 release asset..."
@for i in $$(seq 1 90); do \
ASSETS=$$(gh release view v$(VERSION) --repo program247365/looper --json assets --jq '.assets[].name' 2>/dev/null || true); \
ARM=$$(echo "$$ASSETS" | grep -c "looper-aarch64-apple-darwin.tar.gz" || true); \
if [ "$$ARM" = "1" ]; then \
echo "arm64 asset present."; \
exit 0; \
fi; \
printf " (%02d/90) waiting... arm64=%s\n" "$$i" "$$ARM"; \
sleep 10; \
done; \
echo "Timed out waiting for release asset. Check: gh run list --repo program247365/looper"; \
exit 1
bump-formula: wait-for-release-assets ## Update tap formula with prebuilt arm64 URL + SHA256
@set -e; \
ARM_URL="https://github.com/program247365/looper/releases/download/v$(VERSION)/looper-aarch64-apple-darwin.tar.gz"; \
echo "Computing SHA256..."; \
ARM_SHA=$$(curl -fsSL "$$ARM_URL" | shasum -a 256 | awk '{print $$1}'); \
echo " arm64: $$ARM_SHA"; \
rm -rf $(TAP_DIR); \
git clone $(TAP_REPO) $(TAP_DIR); \
bash scripts/render-formula.sh "$(VERSION)" "$$ARM_SHA" > $(TAP_DIR)/Formula/looper.rb; \
cd $(TAP_DIR) && git add Formula/looper.rb && \
git commit -m "Update looper to v$(VERSION)" && \
git push origin main; \
rm -rf $(TAP_DIR); \
echo "Done. Apple Silicon users get a prebuilt binary on 'brew upgrade looper'."
smoke-test: ## Verify the published formula installs the prebuilt binary cleanly
@echo "Smoke-testing prebuilt install for v$(VERSION)..."
@brew tap program247365/tap >/dev/null 2>&1 || true
@echo "==> Refreshing tap..."
@brew update --quiet
@echo "==> Asserting formula uses prebuilt-binary install path..."
@brew cat program247365/tap/looper | grep -q 'bin.install "looper"' || \
(echo "FAIL: formula is not on the prebuilt path"; exit 1)
@echo "==> Asserting tap formula version matches Cargo.toml..."
@TAP_VERSION=$$(brew cat program247365/tap/looper | awk -F'"' '/^ version /{print $$2; exit}'); \
if [ "$$TAP_VERSION" != "$(VERSION)" ]; then \
echo "FAIL: tap has v$$TAP_VERSION but Cargo.toml is v$(VERSION) — run 'make bump-formula' first"; \
exit 1; \
fi; \
echo " tap version: $$TAP_VERSION"
@echo "==> Reinstalling..."
@if brew list --versions program247365/tap/looper >/dev/null 2>&1; then \
brew reinstall program247365/tap/looper; \
else \
brew install program247365/tap/looper; \
fi
@echo "==> Verifying binary..."
@INSTALLED=$$(brew list --versions program247365/tap/looper | awk '{print $$2}'); \
if [ "$$INSTALLED" != "$(VERSION)" ]; then \
echo "FAIL: brew installed v$$INSTALLED but expected v$(VERSION)"; \
exit 1; \
fi; \
echo " installed: v$$INSTALLED"
@LOOPER_BIN="$$(brew --prefix)/bin/looper"; \
"$$LOOPER_BIN" --help >/dev/null 2>&1 && echo " --help: OK" || \
(echo "FAIL: $$LOOPER_BIN --help failed"; exit 1)
@echo ""
@echo "Smoke test passed for v$(VERSION)."