1
1
#! /bin/bash
2
2
3
+ if [ -d " $ARDUINO_ESP32_PATH /tools/esp32-arduino-libs" ]; then
4
+ SDKCONFIG_DIR=" $ARDUINO_ESP32_PATH /tools/esp32-arduino-libs"
5
+ elif [ -d " $GITHUB_WORKSPACE /tools/esp32-arduino-libs" ]; then
6
+ SDKCONFIG_DIR=" $GITHUB_WORKSPACE /tools/esp32-arduino-libs"
7
+ else
8
+ SDKCONFIG_DIR=" tools/esp32-arduino-libs"
9
+ fi
10
+
3
11
function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [extra-options]
4
12
while [ ! -z " $1 " ]; do
5
13
case " $1 " in
@@ -81,14 +89,21 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
81
89
82
90
len=1
83
91
92
+ if [ -f $sketchdir /ci.json ]; then
93
+ fqbn_append=` jq -r ' .fqbn_append' $sketchdir /ci.json`
94
+ if [ $fqbn_append == " null" ]; then
95
+ fqbn_append=" "
96
+ fi
97
+ fi
98
+
84
99
# Default FQBN options if none were passed in the command line.
85
100
86
- esp32_opts=" PSRAM=enabled,PartitionScheme=huge_app, FlashMode=dio"
87
- esp32s2_opts=" PSRAM=enabled,PartitionScheme=huge_app, FlashMode=dio"
88
- esp32s3_opts=" PSRAM=opi,USBMode=default,PartitionScheme=huge_app, FlashMode=dio"
89
- esp32c3_opts=" PartitionScheme=huge_app, FlashMode=dio"
90
- esp32c6_opts=" PartitionScheme=huge_app, FlashMode=dio"
91
- esp32h2_opts=" PartitionScheme=huge_app, FlashMode=dio"
101
+ esp32_opts=" PSRAM=enabled,FlashMode=dio${fqbn_append : +, $fqbn_append } "
102
+ esp32s2_opts=" PSRAM=enabled,FlashMode=dio${fqbn_append : +, $fqbn_append } "
103
+ esp32s3_opts=" PSRAM=opi,USBMode=default,FlashMode=dio${fqbn_append : +, $fqbn_append } "
104
+ esp32c3_opts=" FlashMode=dio${fqbn_append : +, $fqbn_append } "
105
+ esp32c6_opts=" FlashMode=dio${fqbn_append : +, $fqbn_append } "
106
+ esp32h2_opts=" FlashMode=dio${fqbn_append : +, $fqbn_append } "
92
107
93
108
# Select the common part of the FQBN based on the target. The rest will be
94
109
# appended depending on the passed options.
@@ -140,16 +155,26 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
140
155
141
156
sketchname=$( basename $sketchdir )
142
157
143
- # If the target is listed as false, skip the sketch. Otherwise, include it.
144
158
if [ -f $sketchdir /ci.json ]; then
159
+ # If the target is listed as false, skip the sketch. Otherwise, include it.
145
160
is_target=$( jq -r --arg target $target ' .targets[$target]' $sketchdir /ci.json)
146
- else
147
- is_target=" true"
148
- fi
161
+ if [[ " $is_target " == " false" ]]; then
162
+ echo " Skipping $sketchname for target $target "
163
+ exit 0
164
+ fi
149
165
150
- if [[ " $is_target " == " false" ]]; then
151
- echo " Skipping $sketchname for target $target "
152
- exit 0
166
+ # Check if the sketch requires any configuration options
167
+ requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
168
+ if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
169
+ for requirement in $requirements ; do
170
+ requirement=$( echo $requirement | xargs)
171
+ found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
172
+ if [[ " $found_line " == " " ]]; then
173
+ echo " Target $target does not meet the requirement $requirement for $sketchname . Skipping."
174
+ exit 0
175
+ fi
176
+ done
177
+ fi
153
178
fi
154
179
155
180
ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
@@ -259,10 +284,11 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
259
284
unset options
260
285
}
261
286
262
- function count_sketches(){ # count_sketches <path> [target] [file]
287
+ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requirements]
263
288
local path=$1
264
289
local target=$2
265
- local file=$3
290
+ local ignore_requirements=$3
291
+ local file=$4
266
292
267
293
if [ $# -lt 1 ]; then
268
294
echo " ERROR: Illegal number of parameters"
@@ -275,7 +301,7 @@ function count_sketches(){ # count_sketches <path> [target] [file]
275
301
return 0
276
302
fi
277
303
278
- if [ -n " $file " ]; then
304
+ if [ -f " $file " ]; then
279
305
local sketches=$( cat $file )
280
306
else
281
307
local sketches=$( find $path -name * .ino | sort)
@@ -288,16 +314,26 @@ function count_sketches(){ # count_sketches <path> [target] [file]
288
314
local sketchname=$( basename $sketch )
289
315
if [[ " $sketchdirname .ino" != " $sketchname " ]]; then
290
316
continue
291
- elif [[ -n $target ]]; then
317
+ elif [[ -n $target ]] && [[ -f $sketchdir /ci.json ]] ; then
292
318
# If the target is listed as false, skip the sketch. Otherwise, include it.
293
- if [ -f $sketchdir /ci.json ]; then
294
- is_target=$( jq -r --arg target $target ' .targets[$target]' $sketchdir /ci.json)
295
- else
296
- is_target=" true"
297
- fi
319
+ is_target=$( jq -r --arg target $target ' .targets[$target]' $sketchdir /ci.json)
298
320
if [[ " $is_target " == " false" ]]; then
299
321
continue
300
322
fi
323
+
324
+ if [ " $ignore_requirements " != " 1" ]; then
325
+ # Check if the sketch requires any configuration options
326
+ requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
327
+ if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
328
+ for requirement in $requirements ; do
329
+ requirement=$( echo $requirement | xargs)
330
+ found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
331
+ if [[ " $found_line " == " " ]]; then
332
+ continue 2
333
+ fi
334
+ done
335
+ fi
336
+ fi
301
337
fi
302
338
echo $sketch >> sketches.txt
303
339
sketchnum=$(( $sketchnum + 1 ))
@@ -374,7 +410,7 @@ function build_sketches(){ # build_sketches <ide_path> <user_path> <target> <pat
374
410
375
411
set +e
376
412
if [ -n " $sketches_file " ]; then
377
- count_sketches " $path " " $target " " $sketches_file "
413
+ count_sketches " $path " " $target " " 0 " " $sketches_file "
378
414
local sketchcount=$?
379
415
else
380
416
count_sketches " $path " " $target "
0 commit comments