@@ -98,34 +98,42 @@ 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 } "
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"
107107
108108 # Select the common part of the FQBN based on the target. The rest will be
109109 # appended depending on the passed options.
110110
111+ opt=" "
112+
111113 case " $target " in
112114 " esp32" )
113- fqbn=" espressif:esp32:esp32:${options:- $esp32_opts } "
115+ [ -n " ${options:- $esp32_opts } " ] && opt=" :${options:- $esp32_opts } "
116+ fqbn=" espressif:esp32:esp32$opt "
114117 ;;
115118 " esp32s2" )
116- fqbn=" espressif:esp32:esp32s2:${options:- $esp32s2_opts } "
119+ [ -n " ${options:- $esp32s2_opts } " ] && opt=" :${options:- $esp32s2_opts } "
120+ fqbn=" espressif:esp32:esp32s2$opt "
117121 ;;
118122 " esp32c3" )
119- fqbn=" espressif:esp32:esp32c3:${options:- $esp32c3_opts } "
123+ [ -n " ${options:- $esp32c3_opts } " ] && opt=" :${options:- $esp32c3_opts } "
124+ fqbn=" espressif:esp32:esp32c3$opt "
120125 ;;
121126 " esp32s3" )
122- fqbn=" espressif:esp32:esp32s3:${options:- $esp32s3_opts } "
127+ [ -n " ${options:- $esp32s3_opts } " ] && opt=" :${options:- $esp32s3_opts } "
128+ fqbn=" espressif:esp32:esp32s3$opt "
123129 ;;
124130 " esp32c6" )
125- fqbn=" espressif:esp32:esp32c6:${options:- $esp32c6_opts } "
131+ [ -n " ${options:- $esp32c6_opts } " ] && opt=" :${options:- $esp32c6_opts } "
132+ fqbn=" espressif:esp32:esp32c6$opt "
126133 ;;
127134 " esp32h2" )
128- fqbn=" espressif:esp32:esp32h2:${options:- $esp32h2_opts } "
135+ [ -n " ${options:- $esp32h2_opts } " ] && opt=" :${options:- $esp32h2_opts } "
136+ fqbn=" espressif:esp32:esp32h2$opt "
129137 ;;
130138 esac
131139
@@ -163,9 +171,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
163171 exit 0
164172 fi
165173
166- # Check if the sketch requires any configuration options
174+ # Check if the sketch requires any configuration options (AND)
167175 requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
168- if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
176+ if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
169177 for requirement in $requirements ; do
170178 requirement=$( echo $requirement | xargs)
171179 found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
@@ -175,6 +183,24 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
175183 fi
176184 done
177185 fi
186+
187+ # Check if the sketch excludes any configuration options (OR)
188+ requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
189+ if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
190+ found=false
191+ for requirement in $requirements_or ; do
192+ requirement=$( echo $requirement | xargs)
193+ found_line=$( grep -E " ^$requirement " " $SDKCONFIG_DIR /$target /sdkconfig" )
194+ if [[ " $found_line " != " " ]]; then
195+ found=true
196+ break
197+ fi
198+ done
199+ if [[ " $found " == " false" ]]; then
200+ echo " Target $target meets none of the requirements in requires_any for $sketchname . Skipping."
201+ exit 0
202+ fi
203+ fi
178204 fi
179205
180206 ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
@@ -213,9 +239,9 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
213239 --build-cache-path " $ARDUINO_CACHE_DIR " \
214240 --build-path " $build_dir " \
215241 $xtra_opts " ${sketchdir} " \
216- > $output_file
242+ 2>&1 | tee $output_file
217243
218- exit_status=$?
244+ exit_status=${PIPESTATUS[0]}
219245 if [ $exit_status -ne 0 ]; then
220246 echo " ERROR: Compilation failed with error code $exit_status "
221247 exit $exit_status
@@ -322,9 +348,9 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
322348 fi
323349
324350 if [ " $ignore_requirements " != " 1" ]; then
325- # Check if the sketch requires any configuration options
351+ # Check if the sketch requires any configuration options (AND)
326352 requirements=$( jq -r ' .requires[]? // empty' $sketchdir /ci.json)
327- if [[ " $requirements " != " null" ]] || [[ " $requirements " != " " ]]; then
353+ if [[ " $requirements " != " null" && " $requirements " != " " ]]; then
328354 for requirement in $requirements ; do
329355 requirement=$( echo $requirement | xargs)
330356 found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
@@ -333,6 +359,23 @@ function count_sketches(){ # count_sketches <path> [target] [file] [ignore-requi
333359 fi
334360 done
335361 fi
362+
363+ # Check if the sketch excludes any configuration options (OR)
364+ requirements_or=$( jq -r ' .requires_any[]? // empty' $sketchdir /ci.json)
365+ if [[ " $requirements_or " != " null" && " $requirements_or " != " " ]]; then
366+ found=false
367+ for requirement in $requirements_or ; do
368+ requirement=$( echo $requirement | xargs)
369+ found_line=$( grep -E " ^$requirement " $SDKCONFIG_DIR /$target /sdkconfig)
370+ if [[ " $found_line " != " " ]]; then
371+ found=true
372+ break
373+ fi
374+ done
375+ if [[ " $found " == " false" ]]; then
376+ continue 2
377+ fi
378+ fi
336379 fi
337380 fi
338381 echo $sketch >> sketches.txt
0 commit comments