@@ -98,38 +98,47 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
9898
9999 # Default FQBN options if none were passed in the command line.
100100
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 } "
107- esp32p4_opts=" FlashMode=dio, USBMode=default${fqbn_append: +,$fqbn_append } "
101+ esp32_opts=" PSRAM=enabled${fqbn_append: +,$fqbn_append } "
102+ esp32s2_opts=" PSRAM=enabled${fqbn_append: +,$fqbn_append } "
103+ esp32s3_opts=" PSRAM=opi,USBMode=default${fqbn_append: +,$fqbn_append } "
104+ esp32c3_opts=" $ fqbn_append"
105+ esp32c6_opts=" $ fqbn_append"
106+ esp32h2_opts=" $ fqbn_append"
107+ esp32p4_opts=" USBMode=default${fqbn_append: +,$fqbn_append } "
108108
109109 # Select the common part of the FQBN based on the target. The rest will be
110110 # appended depending on the passed options.
111111
112+ opt=" "
113+
112114 case " $target " in
113115 " esp32" )
114- fqbn=" espressif:esp32:esp32:${options:- $esp32_opts } "
116+ [ -n " ${options:- $esp32_opts } " ] && opt=" :${options:- $esp32_opts } "
117+ fqbn=" espressif:esp32:esp32$opt "
115118 ;;
116119 " esp32s2" )
117- fqbn=" espressif:esp32:esp32s2:${options:- $esp32s2_opts } "
120+ [ -n " ${options:- $esp32s2_opts } " ] && opt=" :${options:- $esp32s2_opts } "
121+ fqbn=" espressif:esp32:esp32s2$opt "
118122 ;;
119123 " esp32c3" )
120- fqbn=" espressif:esp32:esp32c3:${options:- $esp32c3_opts } "
124+ [ -n " ${options:- $esp32c3_opts } " ] && opt=" :${options:- $esp32c3_opts } "
125+ fqbn=" espressif:esp32:esp32c3$opt "
121126 ;;
122127 " esp32s3" )
123- fqbn=" espressif:esp32:esp32s3:${options:- $esp32s3_opts } "
128+ [ -n " ${options:- $esp32s3_opts } " ] && opt=" :${options:- $esp32s3_opts } "
129+ fqbn=" espressif:esp32:esp32s3$opt "
124130 ;;
125131 " esp32c6" )
126- fqbn=" espressif:esp32:esp32c6:${options:- $esp32c6_opts } "
132+ [ -n " ${options:- $esp32c6_opts } " ] && opt=" :${options:- $esp32c6_opts } "
133+ fqbn=" espressif:esp32:esp32c6$opt "
127134 ;;
128135 " esp32h2" )
129- fqbn=" espressif:esp32:esp32h2:${options:- $esp32h2_opts } "
136+ [ -n " ${options:- $esp32h2_opts } " ] && opt=" :${options:- $esp32h2_opts } "
137+ fqbn=" espressif:esp32:esp32h2$opt "
130138 ;;
131139 " esp32p4" )
132- fqbn=" espressif:esp32:esp32p4:${options:- $esp32p4_opts } "
140+ [ -n " ${options:- $esp32p4_opts } " ] && opt=" :${options:- $esp32p4_opts } "
141+ fqbn=" espressif:esp32:esp32p4$opt "
133142 ;;
134143 esac
135144
@@ -167,9 +176,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
167176 exit 0
168177 fi
169178
170- # Check if the sketch requires any configuration options
179+ # Check if the sketch requires any configuration options (AND)
171180 requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
172- if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
181+ if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
173182 for requirement in $requirements ; do
174183 requirement=$( echo $requirement | xargs)
175184 found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
@@ -179,6 +188,24 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
179188 fi
180189 done
181190 fi
191+
192+ # Check if the sketch excludes any configuration options (OR)
193+ requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
194+ if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
195+ found=false
196+ for requirement in $requirements_or ; do
197+ requirement=$( echo $requirement | xargs)
198+ found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
199+ if [[ " $found_line " != " " ]]; then
200+ found=true
201+ break
202+ fi
203+ done
204+ if [[ " $found " == " false" ]]; then
205+ echo " Target $target meets none of the requirements in requires_any for $sketchname . Skipping."
206+ exit 0
207+ fi
208+ fi
182209 fi
183210
184211 ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
@@ -217,9 +244,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
217244 --build-cache-path " $ARDUINO_CACHE_DIR " \
218245 --build-path " $build_dir " \
219246 $xtra_opts " ${sketchdir} " \
220- > $output_file
247+ 2>&1 | tee $output_file
221248
222- exit_status=$?
249+ exit_status=${PIPESTATUS[0]}
223250 if [ $exit_status -ne 0 ]; then
224251 echo " ERROR: Compilation failed with error code $exit_status "
225252 exit $exit_status
@@ -326,9 +353,9 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
326353 fi
327354
328355 if [ " $ignore_requirements " != " 1" ]; then
329- # Check if the sketch requires any configuration options
356+ # Check if the sketch requires any configuration options (AND)
330357 requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
331- if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
358+ if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
332359 for requirement in $requirements ; do
333360 requirement=$( echo $requirement | xargs)
334361 found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
@@ -337,6 +364,23 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
337364 fi
338365 done
339366 fi
367+
368+ # Check if the sketch excludes any configuration options (OR)
369+ requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
370+ if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
371+ found=false
372+ for requirement in $requirements_or ; do
373+ requirement=$( echo $requirement | xargs)
374+ found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
375+ if [[ " $found_line " != " " ]]; then
376+ found=true
377+ break
378+ fi
379+ done
380+ if [[ " $found " == " false" ]]; then
381+ continue 2
382+ fi
383+ fi
340384 fi
341385 fi
342386 echo $sketch >> sketches.txt
0 commit comments