2
2
3
3
build_all=false
4
4
chunks_count=0
5
+ networking_sketches=()
6
+ fs_sketches=()
7
+ lib_sketches=()
8
+ sketches=()
5
9
6
10
if [[ $CORE_CHANGED == ' true' ]] || [[ $IS_PR != ' true' ]]; then
7
11
echo " Core files changed or not a PR. Building all."
@@ -11,56 +15,59 @@ elif [[ $LIB_CHANGED == 'true' ]]; then
11
15
echo " Libraries changed. Building only affected sketches."
12
16
if [[ $NETWORKING_CHANGED == ' true' ]]; then
13
17
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' )
19
23
fi
20
24
if [[ $FS_CHANGED == ' true' ]]; then
21
25
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' )
27
31
fi
28
- sketches=" $ networking_sketches $ fs_sketches"
32
+ sketches=( " ${ networking_sketches[@]} " " ${ fs_sketches[@]} " )
29
33
for file in $LIB_FILES ; do
30
34
lib=$( echo " $file " | awk -F " /" ' {print $1"/"$2}' )
31
35
if [[ " $file " == * .ino ]]; then
32
36
# If file ends with .ino, add it to the list of sketches
33
37
echo " Sketch found: $file "
34
- sketches+=" $file "
38
+ sketches+=( " $file " )
35
39
elif [[ " $file " == " $lib /src/" * ]]; then
36
40
# If file is inside the src directory, find all sketches in the lib/examples directory
37
41
echo " Library src file found: $file "
38
42
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[@]} "
42
46
fi
43
47
else
44
48
# If file is in a example folder but it is not a sketch, find all sketches in the current directory
45
49
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[@]} "
49
54
fi
50
55
echo " "
51
56
done
52
57
fi
53
58
54
- if [[ -n $ sketches ]]; then
59
+ if [[ ${ # sketches[@]} -gt 0 ]]; then
55
60
# 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
58
65
echo " $sketch " >> sketches_found.txt
59
66
chunks_count=$(( chunks_count+ 1 ))
60
67
done
61
68
echo " Number of sketches found: $chunks_count "
62
69
echo " Sketches:"
63
- echo " $ sketches"
70
+ printf " %s\n " " ${ sketches[@]} "
64
71
65
72
if [[ $chunks_count -gt $MAX_CHUNKS ]]; then
66
73
echo " More sketches than the allowed number of chunks found. Limiting to $MAX_CHUNKS chunks."
0 commit comments