From 652da2a7f756b8506ab4e6751a19843e399d7498 Mon Sep 17 00:00:00 2001 From: Bo Date: Thu, 19 Feb 2026 10:00:00 -0800 Subject: [PATCH] Add macOS build scripts --- scripts/build_macos.sh | 21 ++++++++++++++++++++ scripts/setup_idf_macos.sh | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100755 scripts/build_macos.sh create mode 100755 scripts/setup_idf_macos.sh diff --git a/scripts/build_macos.sh b/scripts/build_macos.sh new file mode 100755 index 0000000..773d6c5 --- /dev/null +++ b/scripts/build_macos.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash +set -euo pipefail + +PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" +IDF_VERSION="${IDF_VERSION:-v5.5.2}" +ESP_ROOT="${ESP_ROOT:-$HOME/.espressif}" +DEFAULT_IDF_DIR="$ESP_ROOT/esp-idf-$IDF_VERSION" +IDF_DIR="${IDF_DIR:-${IDF_PATH:-$DEFAULT_IDF_DIR}}" + +if [[ ! -f "$IDF_DIR/export.sh" ]]; then + echo "ESP-IDF not found at: $IDF_DIR" >&2 + echo "Run scripts/setup_idf_macos.sh first, or set IDF_DIR/IDF_PATH." >&2 + exit 1 +fi + +# shellcheck source=/dev/null +. "$IDF_DIR/export.sh" + +cd "$PROJECT_ROOT" +idf.py set-target esp32s3 +idf.py build diff --git a/scripts/setup_idf_macos.sh b/scripts/setup_idf_macos.sh new file mode 100755 index 0000000..1f38bd3 --- /dev/null +++ b/scripts/setup_idf_macos.sh @@ -0,0 +1,39 @@ +#!/usr/bin/env bash +set -euo pipefail + +if [[ "${OSTYPE:-}" != "darwin"* ]]; then + echo "This setup script currently supports macOS only." >&2 + exit 1 +fi + +IDF_VERSION="${IDF_VERSION:-v5.5.2}" +ESP_ROOT="${ESP_ROOT:-$HOME/.espressif}" +IDF_DIR="${IDF_DIR:-$ESP_ROOT/esp-idf-$IDF_VERSION}" + +if ! command -v brew >/dev/null 2>&1; then + echo "Homebrew not found. Install it first:" >&2 + echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"" >&2 + exit 1 +fi + +brew install \ + git wget flex bison gperf python cmake ninja ccache dfu-util libusb libffi openssl@3 + +mkdir -p "$ESP_ROOT" +if [[ ! -d "$IDF_DIR/.git" ]]; then + git clone --depth 1 --branch "$IDF_VERSION" --recursive \ + https://github.com/espressif/esp-idf.git "$IDF_DIR" +else + git -C "$IDF_DIR" fetch --tags --depth 1 origin "$IDF_VERSION" + git -C "$IDF_DIR" checkout "$IDF_VERSION" + git -C "$IDF_DIR" submodule update --init --recursive +fi + +"$IDF_DIR/install.sh" esp32s3 + +echo +echo "ESP-IDF installed. For current shell run:" +echo " . \"$IDF_DIR/export.sh\"" +echo "Then run from project root:" +echo " idf.py set-target esp32s3" +echo " idf.py build"