Add support for snippets to build recipe

This commit is contained in:
urob 2024-11-25 09:31:26 -05:00
parent 24948e1801
commit de8250296a

View file

@ -36,19 +36,19 @@ _parse_combos:
# parse build.yaml and filter targets by expression
_parse_targets $expr:
#!/usr/bin/env bash
attrs="[.board, .shield]"
attrs="[.board, .shield, .snippet]"
filter="(($attrs | map(. // [.]) | combinations), ((.include // {})[] | $attrs)) | join(\",\")"
echo "$(yq -r "$filter" build.yaml | grep -v "^," | grep -i "${expr/#all/.*}")"
# build firmware for single board & shield combination
_build_single $board $shield *west_args:
_build_single $board $shield $snippet *west_args:
#!/usr/bin/env bash
set -euo pipefail
artifact="${shield:+${shield// /+}-}${board}"
build_dir="{{ build / '$artifact' }}"
echo "Building firmware for $artifact..."
west build -s zmk/app -d "$build_dir" -b $board {{ west_args }} -- \
west build -s zmk/app -d "$build_dir" -b $board {{ west_args }} ${snippet:+-S "$snippet"} -- \
-DZMK_CONFIG="{{ config }}" ${shield:+-DSHIELD="$shield"}
if [[ -f "$build_dir/zephyr/zmk.uf2" ]]; then
@ -64,8 +64,8 @@ build expr *west_args: _parse_combos
targets=$(just _parse_targets {{ expr }})
[[ -z $targets ]] && echo "No matching targets found. Aborting..." >&2 && exit 1
echo "$targets" | while IFS=, read -r board shield; do
just _build_single "$board" "$shield" {{ west_args }}
echo "$targets" | while IFS=, read -r board shield snippet; do
just _build_single "$board" "$shield" "$snippet" {{ west_args }}
done
# clear build cache and artifacts