Skip to content

Commit 818c195

Browse files
committed
tests: Accept multiple FQBNs in the config file.
Signed-off-by: Abdelatif Guettouche <[email protected]>
1 parent b976277 commit 818c195

File tree

3 files changed

+55
-39
lines changed

3 files changed

+55
-39
lines changed

Diff for: .github/scripts/sketch_utils.sh

+46-34
Original file line numberDiff line numberDiff line change
@@ -75,41 +75,48 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
7575
exit 1
7676
fi
7777

78-
# Select the common part of the FQBN based on the target. The rest will be
79-
# appended depending on the passed options.
80-
81-
case "$target" in
82-
"esp32") fqbn="espressif:esp32:esp32:"
83-
;;
84-
"esp32s2") fqbn="espressif:esp32:esp32s2:"
85-
;;
86-
"esp32c3") fqbn="espressif:esp32:esp32c3:"
87-
;;
88-
"esp32s3") fqbn="espressif:esp32:esp32s3:"
89-
;;
90-
esac
91-
9278
# The options are either stored in the test directory, for a per test
9379
# customization or passed as parameters. Command line options take
9480
# precedence. Note that the following logic also falls to the default
9581
# parameters if no arguments were passed and no file was found.
9682

9783
if [ $options -eq 0 ] && [ -f $sketchdir/cfg.json ]; then
98-
opts=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn' $sketchdir/cfg.json`
84+
# The config file could contain multiple FQBNs for one chip. If
85+
# that's the case we build one time for every FQBN.
86+
87+
len=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn | length' $sketchdir/cfg.json`
88+
fqbn=`jq -r --arg chip $target '.targets[] | select(.name==$chip) | .fqbn' $sketchdir/cfg.json`
9989
else
90+
# Since we are passing options, we will end up with only one FQBN to
91+
# build.
92+
93+
len=1
94+
95+
# Select the common part of the FQBN based on the target. The rest will be
96+
# appended depending on the passed options.
97+
98+
case "$target" in
99+
"esp32") fqbn="espressif:esp32:esp32:"
100+
;;
101+
"esp32s2") fqbn="espressif:esp32:esp32s2:"
102+
;;
103+
"esp32c3") fqbn="espressif:esp32:esp32c3:"
104+
;;
105+
"esp32s3") fqbn="espressif:esp32:esp32s3:"
106+
;;
107+
esac
108+
100109
partition="PartitionScheme=$partition_opt"
101110
ff="FlashFreq=$ff_opt"
102111
fm="FlashMode=$fm_opt"
103112
fs="FlashSize=$fs_opt"
104113
opts=$fm,$ff,$fs,$partition
114+
fqbn+=$opts
115+
fqbn="[\"$fqbn\"]"
105116
fi
106-
107-
fqbn+=$opts
108117
fi
109118

110-
echo $fqbn
111-
112-
if [ -z $fqbn ]; then
119+
if [ -z "$fqbn" ]; then
113120
echo "No FQBN passed or unvalid chip: $target"
114121
exit 1
115122
fi
@@ -121,21 +128,26 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
121128
build_dir="$ARDUINO_BUILD_DIR"
122129
fi
123130

124-
rm -rf "$build_dir"
125-
mkdir -p "$build_dir"
126131
mkdir -p "$ARDUINO_CACHE_DIR"
127-
$ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \
128-
-fqbn=\"$fqbn\" \
129-
-warnings="all" \
130-
-tools "$ide_path/tools-builder" \
131-
-tools "$ide_path/tools" \
132-
-built-in-libraries "$ide_path/libraries" \
133-
-hardware "$ide_path/hardware" \
134-
-hardware "$user_path/hardware" \
135-
-libraries "$user_path/libraries" \
136-
-build-cache "$ARDUINO_CACHE_DIR" \
137-
-build-path "$build_dir" \
138-
$win_opts $xtra_opts "${sketchdir}/$(basename ${sketchdir}).ino"
132+
for i in `seq 0 $(($len - 1))`
133+
do
134+
rm -rf "$build_dir$i"
135+
mkdir -p "$build_dir$i"
136+
currfqbn=`echo $fqbn | jq -r --argjson i $i '.[$i]'`
137+
echo "Building with FQBN=$currfqbn"
138+
$ide_path/arduino-builder -compile -logger=human -core-api-version=10810 \
139+
-fqbn=\"$currfqbn\" \
140+
-warnings="all" \
141+
-tools "$ide_path/tools-builder" \
142+
-tools "$ide_path/tools" \
143+
-built-in-libraries "$ide_path/libraries" \
144+
-hardware "$ide_path/hardware" \
145+
-hardware "$user_path/hardware" \
146+
-libraries "$user_path/libraries" \
147+
-build-cache "$ARDUINO_CACHE_DIR" \
148+
-build-path "$build_dir$i" \
149+
$win_opts $xtra_opts "${sketchdir}/$(basename ${sketchdir}).ino"
150+
done
139151
}
140152

141153
function count_sketches(){ # count_sketches <path> [target]

Diff for: tests/.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
build/
1+
build*/
22
__pycache__/

Diff for: tests/democfg/cfg.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,23 @@
22
"targets": [
33
{
44
"name": "esp32",
5-
"fqbn": "espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio"
5+
"fqbn":[
6+
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dio",
7+
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=dout",
8+
"espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app,FlashMode=qio"
9+
]
610
},
711
{
812
"name": "esp32s2",
9-
"fqbn": "espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"
13+
"fqbn": ["espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"]
1014
},
1115
{
1216
"name": "esp32c3",
13-
"fqbn": "espressif:esp32:esp32c3:PartitionScheme=huge_app"
17+
"fqbn": ["espressif:esp32:esp32c3:PartitionScheme=huge_app"]
1418
},
1519
{
1620
"name": "esp32s3",
17-
"fqbn": "espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app"
21+
"fqbn": ["espressif:esp32:esp32s3:PSRAM=opi,USBMode=default,PartitionScheme=huge_app"]
1822
}
1923
]
2024
}

0 commit comments

Comments
 (0)