@@ -109,18 +109,30 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
109109 exit 1
110110 fi
111111
112+ # The directory that will hold all the artifcats (the build directory) is
113+ # provided through:
114+ # 1. An env variable called ARDUINO_BUILD_DIR.
115+ # 2. Created at the sketch level as "build" in the case of a single
116+ # configuration test.
117+ # 3. Created at the sketch level as "buildX" where X is the number
118+ # of configuration built in case of a multiconfiguration test.
119+
112120 ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
113- if [ -z " $ARDUINO_BUILD_DIR " ]; then
114- build_dir=" $sketchdir /build"
115- else
121+ if [ -n " $ARDUINO_BUILD_DIR " ]; then
116122 build_dir=" $ARDUINO_BUILD_DIR "
123+ elif [ $len -eq 1 ]; then
124+ build_dir=" $sketchdir /build"
117125 fi
118126
119127 mkdir -p " $ARDUINO_CACHE_DIR "
120128 for i in ` seq 0 $(( $len - 1 )) `
121129 do
122- rm -rf " $build_dir$i "
123- mkdir -p " $build_dir$i "
130+ if [ $len -ne 1 ]; then
131+ build_dir=" $sketchdir /build$i "
132+ fi
133+ rm -rf $build_dir
134+ mkdir -p $build_dir
135+
124136 currfqbn=` echo $fqbn | jq -r --argjson i $i ' .[$i]' `
125137 sketchname=$( basename $sketchdir )
126138 echo " Building $sketchname with FQBN=$currfqbn "
@@ -134,7 +146,7 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
134146 -hardware " $user_path /hardware" \
135147 -libraries " $user_path /libraries" \
136148 -build-cache " $ARDUINO_CACHE_DIR " \
137- -build-path " $build_dir$i " \
149+ -build-path " $build_dir " \
138150 $xtra_opts " ${sketchdir} /${sketchname} .ino"
139151 done
140152}
0 commit comments