8000 tools/autobuild: Automatically build all variants for each board. · micropython/micropython@96296f9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 96296f9

Browse files
committed
tools/autobuild: Automatically build all variants for each board.
Removes the special-case for stm32. This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
1 parent 10a5cf0 commit 96296f9

File tree

3 files changed

+50
-66
lines changed

3 files changed

+50
-66
lines changed

tools/autobuild/autobuild.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ cd ../samd
7777
build_samd_boards ${FW_TAG} ${LOCAL_FIRMWARE}
7878
cd ../stm32
7979
build_stm32_boards ${FW_TAG} ${LOCAL_FIRMWARE}
80-
${AUTODIR}/build-stm32-extra.sh ${FW_TAG} ${LOCAL_FIRMWARE}
8180

8281
popd
8382

tools/autobuild/build-boards.sh

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,36 @@
33
# The functions in this file can be run independently to build boards.
44
# For example:
55
#
6-
# $ source build-boards.sh
7-
# $ MICROPY_AUTOBUILD_MAKE=make build_rp2_boards -latest /tmp
6+
# $ source tools/autobuild/build-boards.sh
7+
# $ cd ports/rp2
8+
# $ MICROPY_AUTOBUILD_MAKE="make -j8" build_rp2_boards -latest /tmp
9+
#
10+
# Or to build a single board:
11+
#
12+
# $ source tools/autobuild/build-boards.sh
13+
# $ cd ports/rp2
14+
# $ MICROPY_AUTOBUILD_MAKE="make -j8" build_board boards/PICO/board.json -latest /tmp uf2
15+
16+
function copy_artefacts {
17+
local dest_dir=$1
18+
local descr=$2
19+
local fw_tag=$3
20+
local build_dir=$4
21+
shift 4
22+
23+
for ext in $@; do
24+
dest=$dest_dir/$descr$fw_tag.$ext
25+
if [ -r $build_dir/firmware.$ext ]; then
26+
mv $build_dir/firmware.$ext $dest
27+
elif [ -r $build_dir/micropython.$ext ]; then
28+
# esp32 has micropython.elf, etc
29+
mv $build_dir/micropython.$ext $dest
30+
elif [ $ext = app-bin -a -r $build_dir/micropython.bin ]; then
31+
# esp32 has micropython.bin which is just the application
32+
mv $build_dir/micropython.bin $dest
33+
fi
34+
done
35+
}
836

937
function build_board {
1038
# check/get parameters
@@ -13,33 +41,29 @@ function build_board {
1341
return 1
1442
fi
1543

16-
board_json=$1
17-
fw_tag=$2
18-
dest_dir=$3
19-
shift
20-
shift
21-
shift
44+
local board_json=$1
45+
local fw_tag=$2
46+
local dest_dir=$3
47+
shift 3
2248

23-
board=$(echo $board_json | awk -F '/' '{ print $2 }')
24-
descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))")
25-
build_dir=/tmp/micropython-build-$board
49+
local board=$(echo $board_json | awk -F '/' '{ print $2 }')
50+
local descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))")
2651

52+
# Build the "default" variant. For most boards this is the only thing we build.
2753
echo "building $descr $board"
28-
$MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir && (
29-
for ext in $@; do
30-
dest=$dest_dir/$descr$fw_tag.$ext
31-
if [ -r $build_dir/firmware.$ext ]; then
32-
mv $build_dir/firmware.$ext $dest
33-
elif [ -r $build_dir/micropython.$ext ]; then
34-
# esp32 has micropython.elf, etc
35-
mv $build_dir/micropython.$ext $dest
36-
elif [ $ext = app-bin -a -r $build_dir/micropython.bin ]; then
37-
# esp32 has micropython.bin which is just the application
38-
mv $build_dir/micropython.bin $dest
39-
fi
40-
done
41-
)
54+
local build_dir=/tmp/micropython-build-$board
55+
$MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir && copy_artefacts $dest_dir $descr $fw_tag $build_dir $@
4256
rm -rf $build_dir
57+
58+
# Query variants from board.json and build them. Ignore the special "idf3"
59+
# variant for ESP32 boards (this allows the downloads page to still have
60+
# the idf3 files for older releases that used to be explicitly built).
61+
for variant in `cat $board_json | python3 -c "import json,sys; print(' '.join(v for v in json.load(sys.stdin).get('variants', {}).keys() if v != 'idf3'))"`; do
62+
local variant_build_dir=$build_dir-$variant
63+
echo "building variant $descr $board $variant"
64+
$MICROPY_AUTOBUILD_MAKE BOARD=$board BOARD_VARIANT=$variant BUILD=$variant_build_dir && copy_artefacts $dest_dir $descr-$variant $fw_tag $variant_build_dir $@
65+
rm -rf $variant_build_dir
66+
done
4367
}
4468

4569
function build_boards {
@@ -49,7 +73,7 @@ function build_boards {
4973
return 1
5074
fi
5175

52-
check_file=$1
76+
local check_file=$1
5377
shift
5478

5579
# check we are in the correct directory

tools/autobuild/build-stm32-extra.sh

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)
0