Skip to content
File

Blob: Makefile

makefile108 lines
1.DEFAULT_GOAL := help
2PYTHON ?= python3
3CARGO ?= cargo
4SIGNALING_URL ?=
5SERIAL_PREFIX ?=
6FLASH_ARGS ?= --firmware-only
7MONITOR_ARGS ?=
8export TRACK PLAYLIST SIGNALING_URL PYTHON
9 
10.PHONY: help setup setup-firmware setup-web setup-c-format tooling-check check check-c-format check-rust check-web check-scripts check-transport-patches test-worker test-worker-bundle fmt fmt-c build build-firmware build-web backup backup-check flash flash-music monitor music secrets dev dev-live deploy-dry-run deploy
11 
12help:
13 @printf '%s\n' 'Pocket Radio — ESP32-S3 × Cloudflare SFU' \
14 'make setup Install pinned firmware tools and web dependencies' \
15 'make setup-c-format Install the pinned C formatter without the SDK' \
16 'make fmt Format Rust, C and web source' \
17 'make check C formatting, Rust, web and host-tool checks' \
18 'make check-transport-patches Run the vendored transport library tests' \
19 'make build Build Rust firmware and browser assets' \
20 'make backup Read and verify the original flash before changing firmware' \
21 'make backup-check Check the saved backup without accessing the board' \
22 'make flash Flash changed firmware sectors; preserves music' \
23 'make flash-music Flash changed music sectors with full verification' \
24 'make monitor Stream USB logs (MONITOR_ARGS=--check for a health check)' \
25 'make music TRACK=… Prepare audio files/folder (or PLAYLIST=playlist.json)' \
26 'make secrets Initialize credentials and refresh worker/.dev.vars' \
27 'make dev Run Vite and the local Worker on port 11880' \
28 'make dev-live Preview the exhibit with the deployed board API' \
29 'make test-worker Run Worker/RPC tests in the Vitest runtime' \
30 'make test-worker-bundle Check the production bundle and real lease alarm' \
31 'make deploy-dry-run Validate Worker deployment' \
32 'make deploy Deploy the Worker and its four production secrets' \
33 'Set SIGNALING_URL to the HTTPS origin of your deployed Worker.'
34 
35setup: setup-firmware setup-web
36setup-firmware: setup-c-format
37 $(PYTHON) scripts/setup_tooling.py
38setup-web:
39 cd worker && npm ci --ignore-scripts
40 cd worker && ./node_modules/.bin/wrangler types
41setup-c-format:
42 $(PYTHON) scripts/format_c.py --setup
43tooling-check:
44 $(PYTHON) scripts/format_c.py --version
45 $(PYTHON) scripts/setup_tooling.py --check
46 
47check: check-c-format check-rust check-web check-scripts
48check-c-format:
49 $(PYTHON) scripts/format_c.py --check
50check-rust:
51 $(CARGO) fmt --manifest-path firmware/Cargo.toml --all -- --check
52 $(CARGO) test --manifest-path firmware/Cargo.toml --locked
53 $(CARGO) clippy --manifest-path firmware/Cargo.toml --workspace --all-targets --all-features --locked -- -D warnings
54 RUSTDOCFLAGS='-D warnings' $(CARGO) doc --manifest-path firmware/Cargo.toml --workspace --all-features --no-deps --locked
55check-web:
56 cd worker && npm run check
57check-scripts:
58 $(PYTHON) -m unittest discover -s scripts -p 'test_*.py'
59check-transport-patches:
60 $(CARGO) test --manifest-path firmware/vendor/sctp-proto/Cargo.toml --locked --lib --target-dir artifacts/vendor-tests
61 $(CARGO) test --manifest-path firmware/vendor/str0m/Cargo.toml --locked --no-default-features --features rust-crypto --lib \
62 --config 'patch.crates-io.sctp-proto.path="firmware/vendor/sctp-proto"' \
63 --config 'patch.crates-io.str0m-rust-crypto.path="firmware/vendor/str0m-rust-crypto"' \
64 --target-dir artifacts/vendor-tests
65 $(CARGO) test --manifest-path firmware/vendor/str0m/Cargo.toml --locked --no-default-features --features rust-crypto,_internal_test_exports \
66 --test contiguous --test keyframes --test loss \
67 --config 'patch.crates-io.sctp-proto.path="firmware/vendor/sctp-proto"' \
68 --config 'patch.crates-io.str0m-rust-crypto.path="firmware/vendor/str0m-rust-crypto"' \
69 --target-dir artifacts/vendor-tests
70test-worker:
71 cd worker && npm run test:worker
72test-worker-bundle: build-web
73 cd worker && npm run test:bundle
74fmt: fmt-c
75 $(CARGO) fmt --manifest-path firmware/Cargo.toml --all
76 cd worker && npm run format
77fmt-c:
78 $(PYTHON) scripts/format_c.py
79 
80build: build-firmware build-web
81build-firmware:
82 $(PYTHON) scripts/build_firmware.py
83build-web:
84 cd worker && ./node_modules/.bin/vite build
85backup:
86 $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/backup_flash.py
87backup-check:
88 .tools/esptool/bin/python scripts/backup_flash.py --check
89flash:
90 $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/flash_device.py $(FLASH_ARGS)
91flash-music:
92 $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/flash_device.py --music-only
93monitor:
94 $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/monitor_device.py $(MONITOR_ARGS)
95music:
96 $(PYTHON) scripts/prepare_music.py
97secrets:
98 $(PYTHON) scripts/prepare_secrets.py
99dev:
100 cd worker && ./node_modules/.bin/vite
101dev-live:
102 @test -n "$$SIGNALING_URL" || { printf '%s\n' 'Set SIGNALING_URL to your deployed Worker HTTPS origin.'; exit 1; }
103 cd worker && RADIO_API_ORIGIN="$$SIGNALING_URL" ./node_modules/.bin/vite
104deploy-dry-run: build-web check-web
105 $(PYTHON) scripts/deploy_worker.py --dry-run
106deploy: build-web check-web
107 $(PYTHON) scripts/deploy_worker.py