6
6
7
7
OSBITS=` arch`
8
8
if [[ " $OSTYPE " == " linux" * ]]; then
9
- export OS_IS_LINUX=" 1"
10
- ARCHIVE_FORMAT=" tar.xz"
11
- if [[ " $OSBITS " == " i686" ]]; then
12
- OS_NAME=" linux32"
13
- elif [[ " $OSBITS " == " x86_64" ]]; then
14
- OS_NAME=" linux64"
15
- elif [[ " $OSBITS " == " armv7l" || " $OSBITS " == " aarch64" ]]; then
16
- OS_NAME=" linuxarm"
17
- else
18
- OS_NAME=" $OSTYPE -$OSBITS "
19
- echo " Unknown OS '$OS_NAME '"
20
- exit 1
21
- fi
9
+ export OS_IS_LINUX=" 1"
10
+ ARCHIVE_FORMAT=" tar.xz"
11
+ if [[ " $OSBITS " == " i686" ]]; then
12
+ OS_NAME=" linux32"
13
+ elif [[ " $OSBITS " == " x86_64" ]]; then
14
+ OS_NAME=" linux64"
15
+ elif [[ " $OSBITS " == " armv7l" || " $OSBITS " == " aarch64" ]]; then
16
+ OS_NAME=" linuxarm"
17
+ else
18
+ OS_NAME=" $OSTYPE -$OSBITS "
19
+ echo " Unknown OS '$OS_NAME '"
20
+ exit 1
21
+ fi
22
22
elif [[ " $OSTYPE " == " darwin" * ]]; then
23
- export OS_IS_MACOS=" 1"
24
- ARCHIVE_FORMAT=" zip"
25
- OS_NAME=" macosx"
23
+ export OS_IS_MACOS=" 1"
24
+ ARCHIVE_FORMAT=" zip"
25
+ OS_NAME=" macosx"
26
26
elif [[ " $OSTYPE " == " cygwin" ]] || [[ " $OSTYPE " == " msys" ]] || [[ " $OSTYPE " == " win32" ]]; then
27
- export OS_IS_WINDOWS=" 1"
28
- ARCHIVE_FORMAT=" zip"
29
- OS_NAME=" windows"
27
+ export OS_IS_WINDOWS=" 1"
28
+ ARCHIVE_FORMAT=" zip"
29
+ OS_NAME=" windows"
30
30
else
31
- OS_NAME=" $OSTYPE -$OSBITS "
32
- echo " Unknown OS '$OS_NAME '"
33
- exit 1
31
+ OS_NAME=" $OSTYPE -$OSBITS "
32
+ echo " Unknown OS '$OS_NAME '"
33
+ exit 1
34
34
fi
35
35
export OS_NAME
36
36
37
37
ARDUINO_BUILD_DIR=" $HOME /.arduino/build.tmp"
38
38
ARDUINO_CACHE_DIR=" $HOME /.arduino/cache.tmp"
39
39
40
40
if [ " $OS_IS_MACOS " == " 1" ]; then
41
- export ARDUINO_IDE_PATH=" /Applications/Arduino.app/Contents/Java"
42
- export ARDUINO_USR_PATH=" $HOME /Documents/Arduino"
41
+ export ARDUINO_IDE_PATH=" /Applications/Arduino.app/Contents/Java"
42
+ export ARDUINO_USR_PATH=" $HOME /Documents/Arduino"
43
43
elif [ " $OS_IS_WINDOWS " == " 1" ]; then
44
- export ARDUINO_IDE_PATH=" $HOME /arduino_ide"
45
- export ARDUINO_USR_PATH=" $HOME /Documents/Arduino"
44
+ export ARDUINO_IDE_PATH=" $HOME /arduino_ide"
45
+ export ARDUINO_USR_PATH=" $HOME /Documents/Arduino"
46
46
else
47
- export ARDUINO_IDE_PATH=" $HOME /arduino_ide"
48
- export ARDUINO_USR_PATH=" $HOME /Arduino"
47
+ export ARDUINO_IDE_PATH=" $HOME /arduino_ide"
48
+ export ARDUINO_USR_PATH=" $HOME /Arduino"
49
49
fi
50
50
51
51
# Updated as of Nov 3rd 2020
@@ -55,76 +55,75 @@ ARDUINO_IDE_URL="https://github.com/espressif/arduino-esp32/releases/download/1.
55
55
# ARDUINO_IDE_URL="https://www.arduino.cc/download.php?f=/arduino-nightly-"
56
56
57
57
if [ ! -d " $ARDUINO_IDE_PATH " ]; then
58
- echo " Installing Arduino IDE on $OS_NAME ..."
59
- echo " Downloading '$ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT ' to 'arduino.$ARCHIVE_FORMAT ' ..."
60
- if [ " $OS_IS_LINUX " == " 1" ]; then
61
- wget -O " arduino.$ARCHIVE_FORMAT " " $ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT " > /dev/null 2>&1
62
- echo " Extracting 'arduino.$ARCHIVE_FORMAT ' ..."
63
- tar xf " arduino.$ARCHIVE_FORMAT " > /dev/null
64
- mv arduino-nightly " $ARDUINO_IDE_PATH "
65
- else
66
- curl -o " arduino.$ARCHIVE_FORMAT " -L " $ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT " > /dev/null 2>&1
67
- echo " Extracting 'arduino.$ARCHIVE_FORMAT ' ..."
68
- unzip " arduino.$ARCHIVE_FORMAT " > /dev/null
69
- if [ " $OS_IS_MACOS " == " 1" ]; then
70
- mv " Arduino.app" " /Applications/Arduino.app"
71
- else
72
- mv arduino-nightly " $ARDUINO_IDE_PATH "
73
- fi
74
- fi
75
- rm -rf " arduino.$ARCHIVE_FORMAT "
76
-
77
- mkdir -p " $ARDUINO_USR_PATH /libraries"
78
- mkdir -p " $ARDUINO_USR_PATH /hardware"
79
-
80
- echo " Arduino IDE Installed in '$ARDUINO_IDE_PATH '"
81
- echo " "
58
+ echo " Installing Arduino IDE on $OS_NAME ..."
59
+ echo " Downloading '$ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT ' to 'arduino.$ARCHIVE_FORMAT ' ..."
60
+ if [ " $OS_IS_LINUX " == " 1" ]; then
61
+ wget -O " arduino.$ARCHIVE_FORMAT " " $ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT " > /dev/null 2>&1
62
+ echo " Extracting 'arduino.$ARCHIVE_FORMAT ' ..."
63
+ tar xf " arduino.$ARCHIVE_FORMAT " > /dev/null
64
+ mv arduino-nightly " $ARDUINO_IDE_PATH "
65
+ else
66
+ curl -o " arduino.$ARCHIVE_FORMAT " -L " $ARDUINO_IDE_URL$OS_NAME .$ARCHIVE_FORMAT " > /dev/null 2>&1
67
+ echo " Extracting 'arduino.$ARCHIVE_FORMAT ' ..."
68
+ unzip " arduino.$ARCHIVE_FORMAT " > /dev/null
69
+ if [ " $OS_IS_MACOS " == " 1" ]; then
70
+ mv " Arduino.app" " /Applications/Arduino.app"
71
+ else
72
+ mv arduino-nightly " $ARDUINO_IDE_PATH "
73
+ fi
74
+ fi
75
+ rm -rf " arduino.$ARCHIVE_FORMAT "
76
+
77
+ mkdir -p " $ARDUINO_USR_PATH /libraries"
78
+ mkdir -p " $ARDUINO_USR_PATH /hardware"
79
+
80
+ echo " Arduino IDE Installed in '$ARDUINO_IDE_PATH '"
81
+ echo " "
82
82
fi
83
83
84
84
function build_sketch(){ # build_sketch <fqbn> <path-to-ino> [extra-options]
85
85
if [ " $# " -lt 2 ]; then
86
- echo " ERROR: Illegal number of parameters"
87
- echo " USAGE: build_sketch <fqbn> <path-to-ino> [extra-options]"
88
- return 1
89
- fi
90
-
91
- local fqbn=" $1 "
92
- local sketch=" $2 "
93
- local xtra_opts=" $3 "
94
- local win_opts=" "
95
- if [ " $OS_IS_WINDOWS " == " 1" ]; then
96
- local ctags_version=` ls " $ARDUINO_IDE_PATH /tools-builder/ctags/" `
97
- local preprocessor_version=` ls " $ARDUINO_IDE_PATH /tools-builder/arduino-preprocessor/" `
98
- win_opts=" -prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH /tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH /tools-builder/arduino-preprocessor/$preprocessor_version "
99
- fi
100
-
101
- # echo ""
102
- # echo "Compiling '"$(basename "$sketch")"' ..."
103
- mkdir -p " $ARDUINO_BUILD_DIR "
104
- mkdir -p " $ARDUINO_CACHE_DIR "
105
- $ARDUINO_IDE_PATH /arduino-builder -compile -logger=human -core-api-version=10810 \
106
- -fqbn=$fqbn \
107
- -warnings=" all" \
108
- -tools " $ARDUINO_IDE_PATH /tools-builder" \
109
- -tools " $ARDUINO_IDE_PATH /tools" \
110
- -built-in-libraries " $ARDUINO_IDE_PATH /libraries" \
111
- -hardware " $ARDUINO_IDE_PATH /hardware" \
112
- -hardware " $ARDUINO_USR_PATH /hardware" \
113
- -libraries " $ARDUINO_USR_PATH /libraries" \
114
- -build-cache " $ARDUINO_CACHE_DIR " \
115
- -build-path " $ARDUINO_BUILD_DIR " \
116
- $win_opts $xtra_opts " $sketch "
86
+ echo " ERROR: Illegal number of parameters"
87
+ echo " USAGE: build_sketch <fqbn> <path-to-ino> [extra-options]"
88
+ return 1
89
+ fi
90
+
91
+ local fqbn=" $1 "
92
+ local sketch=" $2 "
93
+ local xtra_opts=" $3 "
94
+ local win_opts=" "
95
+ if [ " $OS_IS_WINDOWS " == " 1" ]; then
96
+ local ctags_version=` ls " $ARDUINO_IDE_PATH /tools-builder/ctags/" `
97
+ local preprocessor_version=` ls " $ARDUINO_IDE_PATH /tools-builder/arduino-preprocessor/" `
98
+ win_opts=" -prefs=runtime.tools.ctags.path=$ARDUINO_IDE_PATH /tools-builder/ctags/$ctags_version -prefs=runtime.tools.arduino-preprocessor.path=$ARDUINO_IDE_PATH /tools-builder/arduino-preprocessor/$preprocessor_version "
99
+ fi
100
+
101
+ # echo ""
102
+ # echo "Compiling '"$(basename "$sketch")"' ..."
103
+ mkdir -p " $ARDUINO_BUILD_DIR "
104
+ mkdir -p " $ARDUINO_CACHE_DIR "
105
+ $ARDUINO_IDE_PATH /arduino-builder -compile -logger=human -core-api-version=10810 \
106
+ -fqbn=$fqbn \
107
+ -warnings=" all" \
108
+ -tools " $ARDUINO_IDE_PATH /tools-builder" \
109
+ -tools " $ARDUINO_IDE_PATH /tools" \
110
+ -built-in-libraries " $ARDUINO_IDE_PATH /libraries" \
111
+ -hardware " $ARDUINO_IDE_PATH /hardware" \
112
+ -hardware " $ARDUINO_USR_PATH /hardware" \
113
+ -libraries " $ARDUINO_USR_PATH /libraries" \
114
+ -build-cache " $ARDUINO_CACHE_DIR " \
115
+ -build-path " $ARDUINO_BUILD_DIR " \
116
+ $win_opts $xtra_opts " $sketch "
117
117
}
118
118
119
- function count_sketches() # count_sketches <examples-path> <target-mcu>
120
- {
121
- local examples=" $1 "
122
- local target=" $2 "
119
+ function count_sketches(){ # count_sketches <examples-path> <target-mcu>
120
+ local examples=" $1 "
121
+ local target=" $2 "
123
122
rm -rf sketches.txt
124
- if [ ! -d " $examples " ]; then
125
- touch sketches.txt
126
- return 0
127
- fi
123
+ if [ ! -d " $examples " ]; then
124
+ touch sketches.txt
125
+ return 0
126
+ fi
128
127
local sketches=$( find $examples -name * .ino)
129
128
local sketchnum=0
130
129
for sketch in $sketches ; do
@@ -136,73 +135,72 @@ function count_sketches() # count_sketches <examples-path> <target-mcu>
136
135
elif [[ -f " $sketchdir /.skip.$target " ]]; then
137
136
continue
138
137
else
139
- echo $sketch >> sketches.txt
140
- sketchnum=$(( $sketchnum + 1 ))
138
+ echo $sketch >> sketches.txt
139
+ sketchnum=$(( $sketchnum + 1 ))
141
140
fi
142
141
done
143
142
return $sketchnum
144
143
}
145
144
146
- function build_sketches() # build_sketches <fqbn> <target-mcu> <examples-path> <chunk> <total-chunks> [extra-options]
147
- {
145
+ function build_sketches(){ # build_sketches <fqbn> <target-mcu> <examples-path> <chunk> <total-chunks> [extra-options]
148
146
local fqbn=$1
149
- local target=" $2 "
147
+ local target=" $2 "
150
148
local examples=$3
151
149
local chunk_idex=$4
152
150
local chunks_num=$5
153
151
local xtra_opts=$6
154
152
155
153
if [ " $# " -lt 3 ]; then
156
- echo " ERROR: Illegal number of parameters"
157
- echo " USAGE: build_sketches <fqbn> <target-mcu <examples-path> [<chunk> <total-chunks>] [extra-options]"
158
- return 1
159
- fi
154
+ echo " ERROR: Illegal number of parameters"
155
+ echo " USAGE: build_sketches <fqbn> <target-mcu <examples-path> [<chunk> <total-chunks>] [extra-options]"
156
+ return 1
157
+ fi
160
158
161
159
if [ " $# " -lt 5 ]; then
162
- chunk_idex=" 0"
163
- chunks_num=" 1"
164
- xtra_opts=$4
165
- fi
166
-
167
- if [ " $chunks_num " -le 0 ]; then
168
- echo " ERROR: Chunks count must be positive number"
169
- return 1
170
- fi
171
- if [ " $chunk_idex " -ge " $chunks_num " ] && [ " $chunks_num " -ge 2 ]; then
172
- echo " ERROR: Chunk index must be less than chunks count"
173
- return 1
174
- fi
175
-
176
- set +e
160
+ chunk_idex=" 0"
161
+ chunks_num=" 1"
162
+ xtra_opts=$4
163
+ fi
164
+
165
+ if [ " $chunks_num " -le 0 ]; then
166
+ echo " ERROR: Chunks count must be positive number"
167
+ return 1
168
+ fi
169
+ if [ " $chunk_idex " -ge " $chunks_num " ] && [ " $chunks_num " -ge 2 ]; then
170
+ echo " ERROR: Chunk index must be less than chunks count"
171
+ return 1
172
+ fi
173
+
174
+ set +e
177
175
count_sketches " $examples " " $target "
178
176
local sketchcount=$?
179
- set -e
177
+ set -e
180
178
local sketches=$( cat sketches.txt)
181
179
rm -rf sketches.txt
182
180
183
181
local chunk_size=$(( $sketchcount / $chunks_num ))
184
182
local all_chunks=$(( $chunks_num * $chunk_size ))
185
183
if [ " $all_chunks " -lt " $sketchcount " ]; then
186
- chunk_size=$(( $chunk_size + 1 ))
184
+ chunk_size=$(( $chunk_size + 1 ))
187
185
fi
188
186
189
187
local start_index=0
190
188
local end_index=0
191
189
if [ " $chunk_idex " -ge " $chunks_num " ]; then
192
- start_index=$chunk_idex
193
- end_index=$sketchcount
190
+ start_index=$chunk_idex
191
+ end_index=$sketchcount
194
192
else
195
- start_index=$(( $chunk_idex * $chunk_size ))
196
- if [ " $sketchcount " -le " $start_index " ]; then
197
- echo " Skipping job"
198
- return 0
199
- fi
200
-
201
- end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
202
- if [ " $end_index " -gt " $sketchcount " ]; then
203
- end_index=$sketchcount
204
- fi
205
- fi
193
+ start_index=$(( $chunk_idex * $chunk_size ))
194
+ if [ " $sketchcount " -le " $start_index " ]; then
195
+ echo " Skipping job"
196
+ return 0
197
+ fi
198
+
199
+ end_index=$(( $(( $chunk_idex + 1 )) * $chunk_size ))
200
+ if [ " $end_index " -gt " $sketchcount " ]; then
201
+ end_index=$sketchcount
202
+ fi
203
+ fi
206
204
207
205
local start_num=$(( $start_index + 1 ))
208
206
echo " Found $sketchcount Sketches for target '$target '" ;
@@ -224,7 +222,7 @@ function build_sketches() # build_sketches <fqbn> <target-mcu> <examples-path> <
224
222
sketchnum=$(( $sketchnum + 1 ))
225
223
if [ " $sketchnum " -le " $start_index " ] \
226
224
|| [ " $sketchnum " -gt " $end_index " ]; then
227
- continue
225
+ continue
228
226
fi
229
227
echo " "
230
228
echo " Building Sketch Index $(( $sketchnum - 1 )) - $sketchdirname "
0 commit comments