Skip to content

Commit bd3a17b

Browse files
committed
build: switch to external list of targets
Manage the list of build targets via the extra/targets.json file. The first entry in the file will be built by build.sh when run with no arguments.
1 parent 4887276 commit bd3a17b

File tree

4 files changed

+66
-23
lines changed

4 files changed

+66
-23
lines changed

extra/build.sh

+5-11
Original file line numberDiff line numberDiff line change
@@ -13,31 +13,25 @@ if [ x$ZEPHYR_SDK_INSTALL_DIR == x"" ]; then
1313
fi
1414

1515
if [[ $# -eq 0 ]]; then
16-
board=arduino_giga_r1//m7
16+
board=$(jq -cr '.[0].board' < ./extra/targets.json)
17+
args=$(jq -cr '.[0].args' < ./extra/targets.json)
1718
else
18-
board=$1
19-
shift
19+
board=$1
20+
shift
2021
fi
2122

2223
source venv/bin/activate
2324

2425
ZEPHYR_BASE=$(west topdir)/zephyr
2526

2627
# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr)
27-
tmpdir=$(mktemp -d)
28-
variant=$(cmake -DBOARD=$board -P extra/get_variant_name.cmake | grep 'VARIANT=' | cut -d '=' -f 2)
29-
rm -rf ${tmpdir}
28+
variant=$(extra/get_variant_name.sh $board)
3029

3130
if [ -z "${variant}" ] ; then
3231
echo "Failed to get variant name from '$board'"
3332
exit 1
3433
fi
3534

36-
echo && echo && echo
37-
echo ${variant}
38-
echo ${variant} | sed -e 's/./=/g'
39-
echo
40-
4135
# Build the loader
4236
BUILD_DIR=build/${variant}
4337
VARIANT_DIR=variants/${variant}

extra/build_all.sh

+40-12
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,40 @@
1-
# Update this file if a new board gets supported
2-
3-
set -e
4-
5-
./extra/build.sh arduino_giga_r1//m7 --shield giga_display_shield
6-
./extra/build.sh arduino_nano_33_ble//sense
7-
./extra/build.sh arduino_nicla_sense_me
8-
./extra/build.sh arduino_portenta_c33
9-
./extra/build.sh [email protected]//m7
10-
./extra/build.sh ek_ra8d1
11-
./extra/build.sh frdm_mcxn947/mcxn947/cpu0
12-
./extra/build.sh frdm_rw612
1+
#!/bin/bash
2+
3+
FORCE=false
4+
5+
while getopts "hfl" opt; do
6+
case $opt in
7+
h)
8+
echo "Usage: $0 [-hfl]"
9+
echo " -h Show this help message"
10+
echo " -f Force build all targets"
11+
exit 0
12+
;;
13+
f)
14+
FORCE=true
15+
;;
16+
*)
17+
echo "Invalid option: -$OPTARG" >&2
18+
exit 1
19+
;;
20+
esac
21+
done
22+
23+
jq -cr '.[]' < ./extra/targets.json | while read -r item; do
24+
board=$(jq -cr '.board // ""' <<< "$item")
25+
args=$(jq -cr '.args // ""' <<< "$item")
26+
27+
variant=$(extra/get_variant_name.sh "$board" || echo "$board")
28+
echo && echo
29+
echo ${variant}
30+
echo ${variant} | sed -e 's/./=/g'
31+
32+
./extra/build.sh "$board" $args
33+
result=$?
34+
35+
echo
36+
echo "${variant} result: $result"
37+
[ $result -ne 0 ] && ! $FORCE && exit $result
38+
done
39+
40+
exit 0

extra/get_variant_name.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source venv/bin/activate
5+
6+
# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr)
7+
tmpdir=$(mktemp -d)
8+
variant=$(cmake "-DBOARD=$1" -P extra/get_variant_name.cmake 2>/dev/null | grep 'VARIANT=' | cut -d '=' -f 2)
9+
rm -rf ${tmpdir}
10+
11+
echo $variant

extra/targets.json

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[
2+
{ "board": "arduino_giga_r1//m7", "args": "--shield giga_display_shield" },
3+
{ "board": "arduino_nano_33_ble//sense" },
4+
{ "board": "arduino_nicla_sense_me" },
5+
{ "board": "arduino_portenta_c33" },
6+
{ "board": "[email protected]//m7" },
7+
{ "board": "ek_ra8d1" },
8+
{ "board": "frdm_mcxn947/mcxn947/cpu0" },
9+
{ "board": "frdm_rw612" }
10+
]

0 commit comments

Comments
 (0)