Files
meshcore-bot-firmware/scripts/apply-patches.sh
cj-vana 949b761195 build: enable bot on all companion_radio_(usb|ble) envs
Upstream MeshCore only added ${cmesh_bot_production.build_flags} to
Heltec V3 and RAK 4631 companion envs. Every other companion build
target (~129 envs across 64 boards) compiled without CMESH_BOT_ENABLED,
so the bot code was stripped at preprocessing and the firmware behaved
like stock MeshCore (no replies on #bot).

Caught when a tester reported the Heltec V4 build wouldn't respond to
commands. The fix isn't board-specific -- it applies to every variant
in the release matrix.

Adds scripts/enable-bot-on-companion-envs.py: scans
vendor/MeshCore/variants/*/platformio.ini, finds every
*_companion_radio_(usb|ble) env, injects ${cmesh_bot_production.build_flags}
into its build_flags block (idempotent). Hooks into apply-patches.sh
so every local / CI build picks it up.

Choosing a script over a vendor patch keeps us robust to upstream
adding new boards: we don't have to maintain a per-variant patch.
2026-05-16 21:49:38 -06:00

34 lines
996 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
source "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)/meshcore-env.sh"
if [ ! -d "${MESHCORE_DIR}/.git" ] && [ ! -f "${MESHCORE_DIR}/.git" ]; then
echo "MeshCore submodule is missing at ${MESHCORE_DIR}" >&2
echo "Run: git submodule update --init --recursive" >&2
exit 1
fi
if [ -n "$(git -C "${MESHCORE_DIR}" status --porcelain)" ]; then
echo "MeshCore submodule has uncommitted or untracked changes; commit, export, or reset them before applying patches." >&2
exit 1
fi
shopt -s nullglob
patches=("${PATCH_DIR}"/*.patch)
shopt -u nullglob
if [ "${#patches[@]}" -eq 0 ]; then
echo "No MeshCore patches to apply. MeshCore commit: $(meshcore_commit)"
exit 0
fi
for patch in "${patches[@]}"; do
echo "Applying ${patch#${MESHCORE_FW_ROOT}/}"
git -C "${MESHCORE_DIR}" apply --index "$patch"
done
echo "Applied ${#patches[@]} MeshCore patch(es) to $(meshcore_commit)"
python3 "${MESHCORE_FW_ROOT}/scripts/enable-bot-on-companion-envs.py"