feat: add BUILD_TOKEN to firmware and consolidate build system
- Generate BUILD_TOKEN from 'git describe --always --dirty' - Include via -include flag in justfile compile recipe - Print BUILD_TOKEN in boot banners (DoorbellLogic + uno-r4-wifi) - Remove all [tasks] from mise.toml; keep only [tools] + [env] - Update AGENTS.md to use just commands as single source of truth - Add 'just full' recipe (compile -> upload -> monitor -> watch) - Switch BOARD var to env_var_or_default for mise set compatibility - DRY clean/clean-temp with wildcard patterns
This commit is contained in:
@@ -6,18 +6,28 @@
|
||||
default:
|
||||
@just --list
|
||||
|
||||
# Set default BOARD
|
||||
BOARD := "esp32-32e-4"
|
||||
# Default BOARD — overridable via env var or CLI: BOARD=uno-r4-wifi just compile
|
||||
BOARD := env_var_or_default('BOARD', 'esp32-s3-lcd-43')
|
||||
|
||||
# Helper to source board config
|
||||
# just passes args as positional, so we source in each recipe
|
||||
|
||||
# Build token header for -include (generated fresh each compile)
|
||||
BUILD_TOKEN_HEADER := "/tmp/doorbell-build-token.h"
|
||||
|
||||
# Compile firmware
|
||||
compile:
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
source ./boards/{{BOARD}}/board-config.sh
|
||||
|
||||
BUILD_TOKEN=$(git describe --always --dirty 2>/dev/null || echo "unknown")
|
||||
echo "#pragma once" > /tmp/doorbell-build-token.h
|
||||
echo "#define BUILD_TOKEN \"$BUILD_TOKEN\"" >> /tmp/doorbell-build-token.h
|
||||
echo "Build token: $BUILD_TOKEN"
|
||||
|
||||
CFLAGS="$OPTS -include /tmp/doorbell-build-token.h"
|
||||
|
||||
# Only regenerate compile_commands.json if needed (board changed or first run)
|
||||
NEED_GEN=false
|
||||
if [ ! -f compile_commands.json ]; then
|
||||
@@ -28,7 +38,7 @@ compile:
|
||||
|
||||
if [ "$NEED_GEN" = "true" ]; then
|
||||
rm -rf /tmp/arduino-build
|
||||
arduino-cli compile --only-compilation-database --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$OPTS" --build-path /tmp/arduino-build ./boards/{{BOARD}}
|
||||
arduino-cli compile --only-compilation-database --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$CFLAGS" --build-path /tmp/arduino-build ./boards/{{BOARD}}
|
||||
cp /tmp/arduino-build/compile_commands.json .
|
||||
echo "{{BOARD}}" > .board-last
|
||||
echo "[OK] Generated compile_commands.json for {{BOARD}}"
|
||||
@@ -36,7 +46,7 @@ compile:
|
||||
echo "[SKIP] compile_commands.json already up to date for {{BOARD}}"
|
||||
fi
|
||||
|
||||
arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$OPTS" --warnings default ./boards/{{BOARD}}
|
||||
arduino-cli compile --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$CFLAGS" --warnings default ./boards/{{BOARD}}
|
||||
|
||||
# Upload firmware
|
||||
upload: kill
|
||||
@@ -77,10 +87,16 @@ monitor-tio: kill
|
||||
TARGET="$(readlink -f "$PORT" 2>/dev/null || echo "$PORT")"
|
||||
echo "Run: tio --map INLCRNL $TARGET -e"
|
||||
|
||||
# Monitor with JSON logging
|
||||
# Monitor with JSON logging (runs in background)
|
||||
monitor: kill
|
||||
#!/usr/bin/env bash
|
||||
python3 ./scripts/monitor-agent.py "{{BOARD}}" &
|
||||
nohup python3 ./scripts/monitor-agent.py "{{BOARD}}" > /dev/null 2>&1 &
|
||||
PID=$!
|
||||
echo "Monitor agent started for {{BOARD}} (PID: $PID)"
|
||||
echo " Log: /tmp/doorbell-{{BOARD}}.jsonl"
|
||||
echo " State: /tmp/doorbell-{{BOARD}}-state.json"
|
||||
echo " Cmd: echo 'dashboard' > /tmp/doorbell-{{BOARD}}-cmd.fifo"
|
||||
echo " Stop: kill $PID"
|
||||
|
||||
# Tail colored logs
|
||||
watch:
|
||||
@@ -124,26 +140,31 @@ install-libs-shared:
|
||||
# Install all libraries
|
||||
install: install-libs-shared
|
||||
#!/usr/bin/env bash
|
||||
./boards/{{BOARD}}/install.sh
|
||||
arduino-cli core install esp32:esp32
|
||||
if [ -f ./boards/{{BOARD}}/install.sh ]; then
|
||||
./boards/{{BOARD}}/install.sh
|
||||
arduino-cli core install esp32:esp32
|
||||
else
|
||||
echo "[SKIP] No board-specific install script for {{BOARD}}"
|
||||
fi
|
||||
|
||||
# Full build-compile-monitor loop
|
||||
full: compile upload monitor
|
||||
@just watch
|
||||
|
||||
# Clean build artifacts
|
||||
clean:
|
||||
#!/usr/bin/env bash
|
||||
rm -rf vendor/
|
||||
rm -rf .cache/
|
||||
rm -rf boards/esp32-32e/build
|
||||
rm -rf boards/esp32-32e-4/build
|
||||
rm -rf boards/esp32-s3-lcd-43/build
|
||||
rm -rf boards/*/build/
|
||||
rm -f .board-last
|
||||
rm -f /tmp/doorbell-build-token.h
|
||||
echo "[OK] Build artifacts cleaned"
|
||||
|
||||
# Clean temporary files (monitor logs, FIFOs, state files)
|
||||
clean-temp:
|
||||
#!/usr/bin/env bash
|
||||
rm -f /tmp/doorbell-esp32-32e.jsonl /tmp/doorbell-esp32-32e-state.json /tmp/doorbell-esp32-32e-cmd.fifo
|
||||
rm -f /tmp/doorbell-esp32-32e-4.jsonl /tmp/doorbell-esp32-32e-4-state.json /tmp/doorbell-esp32-32e-4-cmd.fifo
|
||||
rm -f /tmp/doorbell-esp32-s3-lcd-43.jsonl /tmp/doorbell-esp32-s3-lcd-43-state.json /tmp/doorbell-esp32-s3-lcd-43-cmd.fifo
|
||||
rm -f /tmp/doorbell-*.jsonl /tmp/doorbell-*-state.json /tmp/doorbell-*-cmd.fifo
|
||||
rm -f .board-last
|
||||
echo "[OK] Temp files cleaned"
|
||||
|
||||
@@ -176,10 +197,29 @@ format:
|
||||
boards/esp32-s3-lcd-43/*.cpp \
|
||||
boards/esp32-s3-lcd-43/*.h \
|
||||
boards/esp32-s3-lcd-43/*.ino \
|
||||
boards/uno-r4-wifi/*.cpp \
|
||||
boards/uno-r4-wifi/*.h \
|
||||
boards/uno-r4-wifi/*.ino \
|
||||
libraries/KlubhausCore/src/*.cpp \
|
||||
libraries/KlubhausCore/src/*.h \
|
||||
libraries/KlubhausCore/*.properties
|
||||
|
||||
# Generate compile_commands.json for LSP (no full compile)
|
||||
gen-compile-commands:
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
source ./boards/{{BOARD}}/board-config.sh
|
||||
BUILD_TOKEN=$(git describe --always --dirty 2>/dev/null || echo "unknown")
|
||||
echo "#pragma once" > /tmp/doorbell-build-token.h
|
||||
echo "#define BUILD_TOKEN \"$BUILD_TOKEN\"" >> /tmp/doorbell-build-token.h
|
||||
CFLAGS="$OPTS -include /tmp/doorbell-build-token.h"
|
||||
rm -rf /tmp/arduino-build
|
||||
arduino-cli compile --only-compilation-database --fqbn "$FQBN" --libraries ./libraries $LIBS --build-property "compiler.cpp.extra_flags=$CFLAGS" --build-path /tmp/arduino-build ./boards/{{BOARD}}
|
||||
cp /tmp/arduino-build/compile_commands.json .
|
||||
echo "{{BOARD}}" > .board-last
|
||||
rm -f /tmp/doorbell-build-token.h
|
||||
echo "[OK] Generated compile_commands.json for {{BOARD}}"
|
||||
|
||||
# Generate crush config
|
||||
gen-crush-config:
|
||||
#!/usr/bin/env bash
|
||||
|
||||
Reference in New Issue
Block a user