22
33build_all=false
44chunks_count=0
5+ networking_sketches=()
6+ fs_sketches=()
7+ lib_sketches=()
8+ sketches=()
59
610if [[ $CORE_CHANGED == ' true' ]] || [[ $IS_PR != ' true' ]]; then
711 echo " Core files changed or not a PR. Building all."
@@ -11,56 +15,59 @@ elif [[ $LIB_CHANGED == 'true' ]]; then
1115 echo " Libraries changed. Building only affected sketches."
1216 if [[ $NETWORKING_CHANGED == ' true' ]]; then
1317 echo " Networking libraries changed. Building networking related sketches."
14- networking_sketches= " $ ( find libraries/WiFi -name ' *.ino' ) "
15- networking_sketches+=" $ ( find libraries/Ethernet -name ' *.ino' ) "
16- networking_sketches+=" $ ( find libraries/PPP -name ' *.ino' ) "
17- networking_sketches+=" $ ( find libraries/NetworkClientSecure -name ' *.ino' ) "
18- networking_sketches+=" $ ( find libraries/WebServer -name ' *.ino' ) "
18+ while IFS= ' ' read -r line ; do networking_sketches+=( " $line " ) ; done < < ( find libraries/WiFi -name ' *.ino' )
19+ while IFS= ' ' read -r line ; do networking_sketches+=( " $line " ) ; done < < ( find libraries/Ethernet -name ' *.ino' )
20+ while IFS= ' ' read -r line ; do networking_sketches+=( " $line " ) ; done < < ( find libraries/PPP -name ' *.ino' )
21+ while IFS= ' ' read -r line ; do networking_sketches+=( " $line " ) ; done < < ( find libraries/NetworkClientSecure -name ' *.ino' )
22+ while IFS= ' ' read -r line ; do networking_sketches+=( " $line " ) ; done < < ( find libraries/WebServer -name ' *.ino' )
1923 fi
2024 if [[ $FS_CHANGED == ' true' ]]; then
2125 echo " FS libraries changed. Building FS related sketches."
22- fs_sketches= " $ ( find libraries/SD -name ' *.ino' ) "
23- fs_sketches+=" $ ( find libraries/SD_MMC -name ' *.ino' ) "
24- fs_sketches+=" $ ( find libraries/SPIFFS -name ' *.ino' ) "
25- fs_sketches+=" $ ( find libraries/LittleFS -name ' *.ino' ) "
26- fs_sketches+=" $ ( find libraries/FFat -name ' *.ino' ) "
26+ while IFS= ' ' read -r line ; do fs_sketches+=( " $line " ) ; done < < ( find libraries/SD -name ' *.ino' )
27+ while IFS= ' ' read -r line ; do fs_sketches+=( " $line " ) ; done < < ( find libraries/SD_MMC -name ' *.ino' )
28+ while IFS= ' ' read -r line ; do fs_sketches+=( " $line " ) ; done < < ( find libraries/SPIFFS -name ' *.ino' )
29+ while IFS= ' ' read -r line ; do fs_sketches+=( " $line " ) ; done < < ( find libraries/LittleFS -name ' *.ino' )
30+ while IFS= ' ' read -r line ; do fs_sketches+=( " $line " ) ; done < < ( find libraries/FFat -name ' *.ino' )
2731 fi
28- sketches=" $ networking_sketches $ fs_sketches"
32+ sketches=( " ${ networking_sketches[@]} " " ${ fs_sketches[@]} " )
2933 for file in $LIB_FILES ; do
3034 lib=$( echo " $file " | awk -F " /" ' {print $1"/"$2}' )
3135 if [[ " $file " == * .ino ]]; then
3236 # If file ends with .ino, add it to the list of sketches
3337 echo " Sketch found: $file "
34- sketches+=" $file "
38+ sketches+=( " $file " )
3539 elif [[ " $file " == " $lib /src/" * ]]; then
3640 # If file is inside the src directory, find all sketches in the lib/examples directory
3741 echo " Library src file found: $file "
3842 if [[ -d $lib /examples ]]; then
39- lib_sketches= $ ( find " $lib " /examples -name ' *.ino' )
40- sketches+=" $ lib_sketches "
41- echo " Library sketches: $ lib_sketches"
43+ while IFS= ' ' read -r line ; do lib_sketches+=( " $line " ) ; done < < ( find " $lib " /examples -name ' *.ino' )
44+ sketches+=( " ${ lib_sketches[@]} " )
45+ printf " Library sketches: %s\n " " ${ lib_sketches[@]} "
4246 fi
4347 else
4448 # If file is in a example folder but it is not a sketch, find all sketches in the current directory
4549 echo " File in example folder found: $file "
46- sketch=$( find " $( dirname " $file " ) " -name ' *.ino' )
47- sketches+=" $sketch "
48- echo " Sketch in example folder: $sketch "
50+ sketch=()
51+ while IFS=' ' read -r line; do sketch+=(" $line " ); done < <( find " $( dirname " $file " ) " -name ' *.ino' )
52+ sketches+=(" ${sketch[@]} " )
53+ printf " Sketch in example folder: %s\n" " ${sketch[@]} "
4954 fi
5055 echo " "
5156 done
5257fi
5358
54- if [[ -n $ sketches ]]; then
59+ if [[ ${ # sketches[@]} -gt 0 ]]; then
5560 # Remove duplicates
56- sketches=$( echo " $sketches " | tr ' ' ' \n' | sort | uniq)
57- for sketch in $sketches ; do
61+ duped_sketches=(" ${sketches[@]} " )
62+ sketches=()
63+ while IFS=' ' read -r line; do sketches+=(" $line " ); done < <( printf " %s\n" " ${duped_sketches[@]} " | sort | uniq)
64+ for sketch in " ${sketches[@]} " ; do
5865 echo " $sketch " >> sketches_found.txt
5966 chunks_count=$(( chunks_count+ 1 ))
6067 done
6168 echo " Number of sketches found: $chunks_count "
6269 echo " Sketches:"
63- echo " $ sketches"
70+ printf " %s\n " " ${ sketches[@]} "
6471
6572 if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
6673 echo " More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
0 commit comments