@@ -141,7 +141,12 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
141
141
fi
142
142
143
143
log_file=" $HOME /.arduino/cli_compile_output.txt"
144
- sizes_file=" $HOME /.arduino/cli_compile_output.json"
144
+ sizes_file=" $GITHUB_WORKSPACE /cli_compile_$CHUNK_INDEX .json"
145
+
146
+ # echo board,target and start of sketches to sizes_file json
147
+ echo " { \" board\" : \" $fqbn \" ,
148
+ \" target\" : \" $target \" ,
149
+ \" sketches\" : [" >> " $sizes_file "
145
150
146
151
mkdir -p " $ARDUINO_CACHE_DIR "
147
152
for i in ` seq 0 $(( $len - 1 )) `
@@ -182,16 +187,28 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
182
187
ram_bytes=$( grep -oE ' Global variables use ([0-9]+) bytes' $log_file | awk ' {print $4}' )
183
188
ram_percentage=$( grep -oE ' Global variables use ([0-9]+) bytes \(([0-9]+)%\)' $log_file | awk ' {print $6}' | tr -d ' (%)' )
184
189
190
+ # Define the constant part
191
+ constant_path=" $HOME /Arduino/hardware/espressif/esp32/libraries/"
192
+
193
+ # Extract the desired substring using awk
194
+ lib_sketch_name=$( echo " $sketch " | sed " s|$constant_part \([^/]*\)/.*|\1|" )
195
+
196
+ # Print the extracted substring
197
+ echo " Extracted Path: $lib_sketch_name "
198
+
185
199
# append json file where key is fqbn, sketch name, sizes -> extracted values
186
- echo " {\" fqbn\" : \" $fqbn \" ,
187
- \" sketch\" : \" $sketch \" ,
200
+ echo " {\" name\" : \" $lib_sketch_name \" ,
188
201
\" sizes\" : {
189
202
\" flash_bytes\" : $flash_bytes ,
190
203
\" flash_percentage\" : $flash_percentage ,
191
204
\" ram_bytes\" : $ram_bytes ,
192
205
\" ram_percentage\" : $ram_percentage
193
206
}
194
- }" >> " $sizes_file "
207
+ }," >> " $sizes_file "
208
+ # if i is the last index of the loop, remove the last comma
209
+ if [ $i -eq $(( $len - 1 )) ]; then
210
+ sed -i ' $ s/.$//' " $sizes_file "
211
+ fi
195
212
196
213
elif [ -f " $ide_path /arduino-builder" ]; then
197
214
echo " Building $sketchname with arduino-builder and FQBN=$currfqbn "
@@ -226,6 +243,12 @@ function build_sketch(){ # build_sketch <ide_path> <user_path> <path-to-ino> [ex
226
243
# $xtra_opts "${sketchdir}/${sketchname}.ino"
227
244
fi
228
245
done
246
+
247
+ # echo end of sketches sizes_file json
248
+ echo " ]}" >> " $sizes_file "
249
+ # echo end of board sizes_file json
250
+ echo " }," >> " $sizes_file "
251
+
229
252
unset fqbn
230
253
unset xtra_opts
231
254
unset options
0 commit comments