File
Blob: Makefile
| 1 | .DEFAULT_GOAL := help |
| 2 | PYTHON ?= python3 |
| 3 | CARGO ?= cargo |
| 4 | SIGNALING_URL ?= |
| 5 | SERIAL_PREFIX ?= |
| 6 | FLASH_ARGS ?= --firmware-only |
| 7 | MONITOR_ARGS ?= |
| 8 | export 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 | |
| 12 | help: |
| 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 | |
| 35 | setup: setup-firmware setup-web |
| 36 | setup-firmware: setup-c-format |
| 37 | $(PYTHON) scripts/setup_tooling.py |
| 38 | setup-web: |
| 39 | cd worker && npm ci --ignore-scripts |
| 40 | cd worker && ./node_modules/.bin/wrangler types |
| 41 | setup-c-format: |
| 42 | $(PYTHON) scripts/format_c.py --setup |
| 43 | tooling-check: |
| 44 | $(PYTHON) scripts/format_c.py --version |
| 45 | $(PYTHON) scripts/setup_tooling.py --check |
| 46 | |
| 47 | check: check-c-format check-rust check-web check-scripts |
| 48 | check-c-format: |
| 49 | $(PYTHON) scripts/format_c.py --check |
| 50 | check-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 |
| 55 | check-web: |
| 56 | cd worker && npm run check |
| 57 | check-scripts: |
| 58 | $(PYTHON) -m unittest discover -s scripts -p 'test_*.py' |
| 59 | check-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 |
| 70 | test-worker: |
| 71 | cd worker && npm run test:worker |
| 72 | test-worker-bundle: build-web |
| 73 | cd worker && npm run test:bundle |
| 74 | fmt: fmt-c |
| 75 | $(CARGO) fmt --manifest-path firmware/Cargo.toml --all |
| 76 | cd worker && npm run format |
| 77 | fmt-c: |
| 78 | $(PYTHON) scripts/format_c.py |
| 79 | |
| 80 | build: build-firmware build-web |
| 81 | build-firmware: |
| 82 | $(PYTHON) scripts/build_firmware.py |
| 83 | build-web: |
| 84 | cd worker && ./node_modules/.bin/vite build |
| 85 | backup: |
| 86 | $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/backup_flash.py |
| 87 | backup-check: |
| 88 | .tools/esptool/bin/python scripts/backup_flash.py --check |
| 89 | flash: |
| 90 | $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/flash_device.py $(FLASH_ARGS) |
| 91 | flash-music: |
| 92 | $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/flash_device.py --music-only |
| 93 | monitor: |
| 94 | $(SERIAL_PREFIX) .tools/esptool/bin/python scripts/monitor_device.py $(MONITOR_ARGS) |
| 95 | music: |
| 96 | $(PYTHON) scripts/prepare_music.py |
| 97 | secrets: |
| 98 | $(PYTHON) scripts/prepare_secrets.py |
| 99 | dev: |
| 100 | cd worker && ./node_modules/.bin/vite |
| 101 | dev-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 |
| 104 | deploy-dry-run: build-web check-web |
| 105 | $(PYTHON) scripts/deploy_worker.py --dry-run |
| 106 | deploy: build-web check-web |
| 107 | $(PYTHON) scripts/deploy_worker.py |