#!/usr/bin/env bash # Builds the firmware with the credentials from .env (see .env.example). # # esp-idf-sys downloads the pinned ESP-IDF automatically. Set IDF_PATH in the # environment to reuse an existing installation (see README.md). set -euo pipefail cd "$(dirname "$0")/.." # Resolve the SDK defaults/components from this repository even when the build # cache is elsewhere, and copy the partition table into the CMake project. export CARGO_WORKSPACE_DIR="$PWD" export ESP_IDF_GLOB_BASE="$PWD" export ESP_IDF_GLOB_PARTITIONS="partitions.csv" if [ -f .env ]; then set -a # shellcheck disable=SC1091 . ./.env set +a fi : "${WIFI_SSID:?set WIFI_SSID in .env (or export it) before building}" export WIFI_PASS="${WIFI_PASS:-}" package=0 cargo_args=() for arg in "$@"; do case "$arg" in --package) package=1 ;; *) cargo_args+=("$arg") ;; esac done cargo build --release --locked "${cargo_args[@]}" if [ "$package" -eq 1 ]; then if ! command -v python3 >/dev/null 2>&1; then echo "error: --package requires python3 on PATH" >&2 exit 1 fi python3 scripts/package_firmware.py --firmware target/firmware fi