Skip to content

Commit 7ddda9c

Browse files
committed
extra: replace targets.json with details extracted from boards.txt
This commit replaces the static 'targets.json' file with a script that extracts the board details directly from 'boards.txt', removing the need to maintain a separate file.
1 parent 2ccb910 commit 7ddda9c

File tree

6 files changed

+59
-24
lines changed

6 files changed

+59
-24
lines changed

Diff for: .github/workflows/package_core.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
./extra/bootstrap.sh -o=--filter=tree:0
3636
echo "CORE_TAG=$(git describe --always)" >> "$GITHUB_ENV"
3737
echo "CORE_ARTIFACT=ArduinoCore-zephyr-$(git describe --always)" >> "$GITHUB_ENV"
38-
echo "BOARD_VARIANTS=[ $(cat boards.txt | grep '^[^#]*\.build\.variant' | sed -e 's/^\([^#]*\)\.build\.variant=\(.*\)/{ \"variant\": \"\2\", \"board\": \"\1\" },/' | sort | tr '\r\n' ' ' | sed -e 's/,\s*$//') ]" >> "$GITHUB_ENV"
38+
echo "BOARD_VARIANTS=$(extra/get_board_details.sh | jq -cr '.[] | sort_by(.variant)')" >> "$GITHUB_ENV"
3939
4040
- name: ccache
4141
uses: hendrikmuhs/[email protected]

Diff for: boards.txt

+16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ giga.menu.debug.true=Debug
1212
giga.menu.debug.false.postbuild_debug=
1313
giga.menu.debug.true.postbuild_debug=-debug
1414

15+
giga.build.zephyr_target=arduino_giga_r1//m7
16+
giga.build.zephyr_args=--shield giga_display_shield
1517
giga.build.variant=arduino_giga_r1_stm32h747xx_m7
1618
giga.build.mcu=cortex-m7
1719
giga.build.fpu=-mfpu=fpv5-d16
@@ -75,6 +77,8 @@ nano33ble.menu.debug.true=Debug
7577
nano33ble.menu.debug.false.postbuild_debug=
7678
nano33ble.menu.debug.true.postbuild_debug=-debug
7779

80+
nano33ble.build.zephyr_target=arduino_nano_33_ble//sense
81+
nano33ble.build.zephyr_args=
7882
nano33ble.build.variant=arduino_nano_33_ble_nrf52840_sense
7983
nano33ble.build.mcu=cortex-m4
8084
nano33ble.build.fpu=-mfpu=fpv4-sp-d16
@@ -136,6 +140,8 @@ ek_ra8d1.menu.debug.true=Debug
136140
ek_ra8d1.menu.debug.false.postbuild_debug=
137141
ek_ra8d1.menu.debug.true.postbuild_debug=-debug
138142

143+
ek_ra8d1.build.zephyr_target=ek_ra8d1
144+
ek_ra8d1.build.zephyr_args=
139145
ek_ra8d1.build.variant=ek_ra8d1_r7fa8d1bhecbd
140146
ek_ra8d1.build.mcu=cortex-m85+nomve
141147
ek_ra8d1.build.fpu=-mfpu=fpv5-d16
@@ -192,6 +198,8 @@ frdm_mcxn947.menu.debug.true=Debug
192198
frdm_mcxn947.menu.debug.false.postbuild_debug=
193199
frdm_mcxn947.menu.debug.true.postbuild_debug=-debug
194200

201+
frdm_mcxn947.build.zephyr_target=frdm_mcxn947//cpu0
202+
frdm_mcxn947.build.zephyr_args=
195203
frdm_mcxn947.build.variant=frdm_mcxn947_mcxn947_cpu0
196204
frdm_mcxn947.build.mcu=cortex-m33
197205
frdm_mcxn947.build.fpu=-mfpu=fpv5-sp-d16
@@ -243,6 +251,8 @@ portentah7.menu.debug.true=Debug
243251
portentah7.menu.debug.false.postbuild_debug=
244252
portentah7.menu.debug.true.postbuild_debug=-debug
245253

254+
255+
portentah7.build.zephyr_args=
246256
portentah7.build.variant=arduino_portenta_h7_stm32h747xx_m7
247257
portentah7.build.mcu=cortex-m7
248258
portentah7.build.fpu=-mfpu=fpv5-d16
@@ -306,6 +316,8 @@ frdm_rw612.menu.debug.true=Debug
306316
frdm_rw612.menu.debug.false.postbuild_debug=
307317
frdm_rw612.menu.debug.true.postbuild_debug=-debug
308318

319+
frdm_rw612.build.zephyr_target=frdm_rw612
320+
frdm_rw612.build.zephyr_args=
309321
frdm_rw612.build.variant=frdm_rw612_rw612
310322
frdm_rw612.build.mcu=cortex-m33+nodsp
311323
frdm_rw612.build.fpu=-mfpu=fpv5-sp-d16
@@ -356,6 +368,8 @@ niclasense.menu.debug.true=Debug
356368
niclasense.menu.debug.false.postbuild_debug=
357369
niclasense.menu.debug.true.postbuild_debug=-debug
358370

371+
niclasense.build.zephyr_target=arduino_nicla_sense_me
372+
niclasense.build.zephyr_args=
359373
niclasense.build.variant=arduino_nicla_sense_me_nrf52832
360374
niclasense.build.mcu=cortex-m4
361375
niclasense.build.fpu=-mfpu=fpv4-sp-d16
@@ -433,6 +447,8 @@ portentac33.menu.mode.linked.build.ldscript={runtime.platform.path}/variants/lin
433447
portentac33.menu.mode.linked.upload.extension=bin-zsk.bin
434448
portentac33.menu.mode.linked.postbuild_mode=-prelinked
435449

450+
portentac33.build.zephyr_target=arduino_portenta_c33
451+
portentac33.build.zephyr_args=
436452
portentac33.build.variant=arduino_portenta_c33_r7fa6m5bh3cfc
437453
portentac33.build.mcu=cortex-m33
438454
portentac33.build.fpu=-mfpu=fpv5-sp-d16

Diff for: extra/build.sh

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

1515
if [[ $# -eq 0 ]]; then
16-
board=$(jq -cr '.[0].board' < ./extra/targets.json)
17-
args=$(jq -cr '.[0].args' < ./extra/targets.json)
16+
first_board=$(extra/get_board_details.sh | jq -cr '.[0]')
17+
target=$(jq -cr '.target' <<< "$first_board")
18+
args=$(jq -cr '.args' <<< "$first_board")
1819
else
19-
board=$1
20+
target=$1
2021
shift
2122
fi
2223

@@ -25,18 +26,18 @@ source venv/bin/activate
2526
ZEPHYR_BASE=$(west topdir)/zephyr
2627

2728
# Get the variant name (NORMALIZED_BOARD_TARGET in Zephyr)
28-
variant=$(extra/get_variant_name.sh $board)
29+
variant=$(extra/get_variant_name.sh $target)
2930

3031
if [ -z "${variant}" ] ; then
31-
echo "Failed to get variant name from '$board'"
32+
echo "Failed to get variant name from '$target'"
3233
exit 1
3334
fi
3435

3536
# Build the loader
3637
BUILD_DIR=build/${variant}
3738
VARIANT_DIR=variants/${variant}
3839
rm -rf ${BUILD_DIR}
39-
west build -d ${BUILD_DIR} -b ${board} loader -t llext-edk $*
40+
west build -d ${BUILD_DIR} -b ${target} loader -t llext-edk $*
4041

4142
# Extract the generated EDK tarball and copy it to the variant directory
4243
mkdir -p ${VARIANT_DIR} firmwares

Diff for: extra/build_all.sh

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,20 @@ if [ ! -z "$GITHUB_STEP_SUMMARY" ] ; then
2424
echo "### Variant build results:" >> "$GITHUB_STEP_SUMMARY"
2525
fi
2626

27-
jq -cr '.[]' < ./extra/targets.json | while read -r item; do
28-
board=$(jq -cr '.board // ""' <<< "$item")
27+
extra/get_board_details.sh | jq -cr '.[]' | while read -r item; do
28+
variant=$(jq -cr '.variant // ""' <<< "$item")
29+
target=$(jq -cr '.target // ""' <<< "$item")
2930
args=$(jq -cr '.args // ""' <<< "$item")
3031

31-
variant=$(extra/get_variant_name.sh "$board" || echo "$board")
3232
if [ -z "$GITHUB_STEP_SUMMARY" ] ; then
3333
echo && echo
34-
echo ${variant}
35-
echo ${variant} | sed -e 's/./=/g'
34+
echo ${board} (${variant})
35+
echo ${board} (${variant}) | sed -e 's/./=/g'
3636
else
37-
echo "::group::=== ${variant} ==="
37+
echo "::group::=== ${board} (${variant}) ==="
3838
fi
3939

40-
./extra/build.sh "$board" $args
40+
./extra/build.sh "$target" $args
4141
result=$?
4242

4343
if [ -z "$GITHUB_STEP_SUMMARY" ] ; then

Diff for: extra/get_board_details.sh

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
get_boards() {
4+
cat boards.txt | sed -e 's/#.*//' | grep -E '^.*\.build\.variant=' | sed -e 's/\.build\.variant=.*//'
5+
}
6+
7+
get_board_field() {
8+
board=$1
9+
field=$2
10+
cat boards.txt | sed -e 's/#.*//' | grep -E "^$board\\.build\\.$field=" | cut -d '=' -f2- | sed -e 's/"/\"/g'
11+
}
12+
13+
echo "["
14+
QUOTE=" "
15+
for BOARD in $(get_boards); do
16+
VARIANT=$(get_board_field $BOARD "variant")
17+
TARGET=$(get_board_field $BOARD "zephyr_target")
18+
ARGS=$(get_board_field $BOARD "zephyr_args")
19+
20+
if [ -z "$TARGET" ] ; then
21+
echo "error: missing '$BOARD.build.zephyr_target'" 1>&2
22+
exit 1
23+
fi
24+
25+
echo "$QUOTE { \"board\": \"$BOARD\", \"variant\": \"$VARIANT\", \"target\": \"$TARGET\", \"args\": \"$ARGS\" }"
26+
QUOTE=","
27+
done
28+
echo "]"

Diff for: extra/targets.json

-10
This file was deleted.

0 commit comments

Comments
 (0)