@@ -113,14 +113,31 @@ function print_sketch_info()
113113 local build_rem=$2
114114
115115 local testcnt=0
116+ local cnt=0
116117
117118 for sketch in $ESP8266_ARDUINO_SKETCHES ; do
118119 testcnt=$(( ($testcnt + 1 ) % $build_mod ))
119120 if [ $testcnt -ne $build_rem ]; then
120121 continue # Not ours to do
121122 fi
122123
123- echo $sketch
124+ local sketchdir
125+ sketchdir=$( dirname $sketch )
126+
127+ local sketchdirname
128+ sketchdirname=$( basename $sketchdir )
129+
130+ local sketchname
131+ sketchname=$( basename $sketch )
132+
133+ local skip
134+ skip=$( skip_sketch " $sketch " " $sketchname " " $sketchdir " " $sketchdirname " )
135+ if [ -n " $skip " ]; then
136+ continue # Should be skipped / cannot be built
137+ fi
138+
139+ cnt=$(( $cnt + 1 ))
140+ printf ' %2d\t%s\n' " $cnt " " $sketch "
124141 done
125142}
126143
@@ -140,9 +157,10 @@ function build_sketches()
140157 local core_path=$1
141158 local cli_path=$2
142159 local library_path=$3
143- local build_mod=$4
144- local build_rem=$5
145- local lwip=$6
160+ local lwip=$4
161+ local build_mod=$5
162+ local build_rem=$6
163+ local build_cnt=$7
146164
147165 local build_dir=" $cache_dir " /build
148166 mkdir -p " $build_dir "
@@ -163,53 +181,19 @@ function build_sketches()
163181
164182 print_size_info_header > " $cache_dir " /size.log
165183
166- local mk_clean_core =1
184+ local clean_core =1
167185 local testcnt=0
186+ local cnt=0
168187
169188 for sketch in $ESP8266_ARDUINO_SKETCHES ; do
170189 testcnt=$(( ($testcnt + 1 ) % $build_mod ))
171190 if [ $testcnt -ne " $build_rem " ]; then
172191 continue # Not ours to do
173192 fi
174193
175- # mkbuildoptglobals.py is optimized around the Arduino IDE 1.x
176- # behaviour. One way the CI differs from the Arduino IDE is in the
177- # handling of core and caching core. With the Arduino IDE, each sketch
178- # has a private copy of core and contributes to a core cache. With the
179- # CI, there is one shared copy of core for all sketches. When global
180- # options are used, the shared copy of core and cache are removed before
181- # and after the build.
182- #
183194 # Do we need a clean core build? $build_dir/core/* cannot be shared
184195 # between sketches when global options are present.
185- if [ -s ${sketch} .globals.h ]; then
186- mk_clean_core=1
187- fi
188- if [ $mk_clean_core -ne 0 ]; then
189- rm -rf " $build_dir " /core/*
190- else
191- # Remove sketch specific files from ./core/ between builds.
192- rm -rf " $build_dir /core/build.opt" " $build_dir " /core/* .ino.globals.h
193- fi
194-
195- if [ -e ${build_dir} /core/* .a ]; then
196- # We need to preserve the build.options.json file and replace the last .ino
197- # with this sketch's ino file, or builder will throw everything away.
198- jq ' ."sketchLocation" = "' $sketch ' "' $build_dir /build.options.json \
199- > " $build_dir " /build.options.json.tmp
200- mv " $build_dir " /build.options.json.tmp " $build_dir " /build.options.json
201- if [ $mk_clean_core -ne 0 ]; then
202- # Hack workaround for CI not handling core rebuild for global options
203- rm ${build_dir} /core/* .a
204- fi
205- fi
206-
207- if [ -s ${sketch} .globals.h ]; then
208- # Set to cleanup core at the start of the next build.
209- mk_clean_core=1
210- else
211- mk_clean_core=0
212- fi
196+ clean_core=$( arduino_mkbuildoptglobals_cleanup " $clean_core " " $build_dir " " $sketch " )
213197
214198 # Clear out the last built sketch, map, elf, bin files, but leave the compiled
215199 # objects in the core and libraries available for use so we don't need to rebuild
@@ -235,15 +219,23 @@ function build_sketches()
235219 continue
236220 fi
237221
238- echo ::group::Building $sketch
222+ cnt=$(( $cnt + 1 ))
223+ if [ $build_cnt != 0 ] ; then
224+ if [ $build_cnt != $cnt ] ; then
225+ continue
226+ fi
227+ build_cnt=0
228+ fi
229+
230+ echo ::group::Building $cnt $sketch
239231 echo " $build_cmd $sketch "
240232
241233 local result
242234 time $build_cmd $sketch > " $cache_dir " /build.log \
243235 && result=0 || result=1
244236
245237 if [ $result -ne 0 ]; then
246- echo ::error::Build failed for $sketch
238+ echo ::error::Build failed for $cnt $ sketch
247239 cat " $cache_dir /build.log"
248240 echo ::endgroup::
249241 return $result
@@ -455,18 +447,65 @@ function arduino_lwip_menu_option()
455447 esac
456448}
457449
458- function build_sketches_with_arduino()
450+ # mkbuildoptglobals.py is optimized around the Arduino IDE 1.x
451+ # behaviour. One way the CI differs from the Arduino IDE is in the
452+ # handling of core and caching core. With the Arduino IDE, each sketch
453+ # has a private copy of core and contributes to a core cache. With the
454+ # CI, there is one shared copy of core for all sketches. When global
455+ # options are used, the shared copy of core and cache are removed before
456+ # and after the build.
457+ function arduino_mkbuildoptglobals_cleanup()
459458{
460- local build_mod=$1
461- local build_rem=$2
459+ local clean_core=$1
460+ local build_dir=$2
461+ local sketch=$3
462462
463+ if [ -s ${sketch} .globals.h ]; then
464+ clean_core=1
465+ fi
466+
467+ # Remove sketch specific files from ./core/ between builds.
468+ if [ $clean_core -ne 0 ]; then
469+ rm -rf " $build_dir " /core/*
470+ else
471+ rm -rf " $build_dir /core/build.opt" " $build_dir " /core/* .ino.globals.h
472+ fi
473+
474+ if [ -e ${build_dir} /core/* .a ]; then
475+ # We need to preserve the build.options.json file and replace the last .ino
476+ # with this sketch's ino file, or builder will throw everything away.
477+ jq ' ."sketchLocation" = "' $sketch ' "' $build_dir /build.options.json \
478+ > " $build_dir " /build.options.json.tmp
479+ mv " $build_dir " /build.options.json.tmp " $build_dir " /build.options.json
480+ if [ $clean_core -ne 0 ]; then
481+ # Hack workaround for CI not handling core rebuild for global options
482+ rm ${build_dir} /core/* .a
483+ fi
484+ fi
485+
486+ if [ -s ${sketch} .globals.h ]; then
487+ # Set to cleanup core at the start of the next build.
488+ clean_core=1
489+ else
490+ clean_core=0
491+ fi
492+
493+ echo $clean_core
494+ }
495+
496+ function build_sketches_with_arduino()
497+ {
463498 local lwip
464- lwip=$( arduino_lwip_menu_option $3 )
499+ lwip=$( arduino_lwip_menu_option $1 )
500+
501+ local build_mod=$2
502+ local build_rem=$3
503+ local build_cnt=$4
465504
466505 build_sketches " $ESP8266_ARDUINO_BUILD_DIR " \
467506 " $ESP8266_ARDUINO_CLI " \
468507 " $ESP8266_ARDUINO_LIBRARIES " \
469- " $build_mod " " $build_rem " " $lwip "
508+ " $lwip " " $ build_mod" " $build_rem " " $build_cnt "
470509 step_summary " Size report" " $cache_dir /size.log"
471510}
472511
@@ -510,6 +549,7 @@ function build_sketches_with_platformio()
510549{
511550 local build_mod=$1
512551 local build_rem=$2
552+ local build_cnt=$3
513553 local testcnt=0
514554
515555 for sketch in $ESP8266_ARDUINO_SKETCHES ; do
@@ -534,6 +574,14 @@ function build_sketches_with_platformio()
534574 continue
535575 fi
536576
577+ cnt=$(( $cnt + 1 ))
578+ if [ $build_cnt != 0 ] ; then
579+ if [ $build_cnt != $cnt ] ; then
580+ continue
581+ fi
582+ build_cnt=0
583+ fi
584+
537585 echo ::group::Building $sketch
538586
539587 local result
0 commit comments