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

Skip to content

Commit 66a209c

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 b853131 commit 66a209c

File tree

3 files changed

+44
-63
lines changed

3 files changed

+44
-63
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: 44 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,33 @@
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_artifacts {
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+
fi
31+
done
32+
}
833

934
function build_board {
1035
# check/get parameters
@@ -13,30 +38,26 @@ function build_board {
1338
return 1
1439
fi
1540

16-
board_json=$1
17-
fw_tag=$2
18-
dest_dir=$3
19-
shift
20-
shift
21-
shift
41+
local board_json=$1
42+
local fw_tag=$2
43+
local dest_dir=$3
44+
shift 3
2245

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
46+
local board=$(echo $board_json | awk -F '/' '{ print $2 }')
47+
local descr=$(cat $board_json | python3 -c "import json,sys; print(json.load(sys.stdin).get('id', '$board'))")
2648

2749
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-
fi
37-
done
38-
)
50+
local build_dir=/tmp/micropython-build-$board
51+
$MICROPY_AUTOBUILD_MAKE BOARD=$board BUILD=$build_dir && copy_artifacts $dest_dir $descr $fw_tag $build_dir $@
3952
rm -rf $build_dir
53+
54+
# Run the query-variants target (if supported).
55+
for variant in `($MICROPY_AUTOBUILD_MAKE BUILD=$build_dir-variants BOARD=$board query-variants 2>&1 || true) | grep VARIANTS: | cut -d' ' -f2-`; do
56+
local variant_build_dir=$build_dir-$variant
57+
echo "building variant $descr $board $variant"
58+
$MICROPY_AUTOBUILD_MAKE BOARD=$board BOARD_VARIANT=$variant BUILD=$variant_build_dir && copy_artifacts $dest_dir $descr-$variant $fw_tag $variant_build_dir $@
59+
rm -rf $variant_build_dir
60+
done
4061
}
4162

4263
function build_boards {
@@ -46,7 +67,7 @@ function build_boards {
4667
return 1
4768
fi
4869

49-
check_file=$1
70+
local check_file=$1
5071
shift
5172

5273
# 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