12
12
13
13
export TARGET=" all"
14
14
BUILD_TYPE=" all"
15
+ BUILD_DEBUG=" default"
15
16
SKIP_ENV=0
16
17
COPY_OUT=0
17
18
ARCHIVE_OUT=1
18
- DEPLOY_OUT=0
19
+ if [ -z $DEPLOY_OUT ]; then
20
+ DEPLOY_OUT=0
21
+ fi
19
22
20
23
function print_help() {
21
- echo " Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]"
24
+ echo " Usage: build.sh [-s] [-A <arduino_branch>] [-I <idf_branch>] [-D <debug_level>] [- i <idf_commit>] [-c <path>] [-t <target>] [-b <build|menuconfig|reconfigure|idf-libs|copy-bootloader|mem-variant>] [config ...]"
22
25
echo " -s Skip installing/updating of ESP-IDF and all components"
23
26
echo " -A Set which branch of arduino-esp32 to be used for compilation"
24
27
echo " -I Set which branch of ESP-IDF to be used for compilation"
25
28
echo " -i Set which commit of ESP-IDF to be used for compilation"
26
29
echo " -e Archive the build to dist"
30
+ echo " -d Deploy the build to github arduino-esp32"
31
+ echo " -D Debug level to be set to ESP-IDF. One of default,none,error,warning,info,debug or verbose"
32
+ echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME /Arduino/hardware/espressif/esp32'"
27
33
echo " -t Set the build target(chip) ex. 'esp32s3' or select multiple targets(chips) by separating them with comma ex. 'esp32,esp32s3,esp32c3'"
28
34
echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board"
29
35
echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b"
30
36
exit 1
31
37
}
32
38
33
- while getopts " :A:I:i:c:t:b:sde" opt; do
39
+ while getopts " :A:I:i:c:t:b:D: sde" opt; do
34
40
case ${opt} in
35
41
s )
36
42
SKIP_ENV=1
37
43
;;
44
+ d )
45
+ DEPLOY_OUT=1
46
+ ;;
38
47
e )
39
48
ARCHIVE_OUT=1
40
49
;;
50
+ c )
51
+ export ESP32_ARDUINO=" $OPTARG "
52
+ COPY_OUT=1
53
+ ;;
41
54
A )
42
55
export AR_BRANCH=" $OPTARG "
43
56
;;
@@ -47,16 +60,19 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
47
60
i )
48
61
export IDF_COMMIT=" $OPTARG "
49
62
;;
63
+ D )
64
+ BUILD_DEBUG=" $OPTARG "
65
+ ;;
50
66
t )
51
67
IFS=' ,' read -ra TARGET <<< " $OPTARG"
52
68
;;
53
69
b )
54
70
b=$OPTARG
55
- if [ " $b " != " build" ] &&
56
- [ " $b " != " menuconfig" ] &&
57
- [ " $b " != " reconfigure" ] &&
58
- [ " $b " != " idf-libs" ] &&
59
- [ " $b " != " copy-bootloader" ] &&
71
+ if [ " $b " != " build" ] &&
72
+ [ " $b " != " menuconfig" ] &&
73
+ [ " $b " != " reconfigure" ] &&
74
+ [ " $b " != " idf-libs" ] &&
75
+ [ " $b " != " copy-bootloader" ] &&
60
76
[ " $b " != " mem-variant" ]; then
61
77
print_help
62
78
fi
@@ -100,6 +116,10 @@ else
100
116
source ./tools/config.sh
101
117
fi
102
118
119
+ if [ -f " $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash" ]; then
120
+ rm -rf $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash
121
+ fi
122
+
103
123
if [ " $BUILD_TYPE " != " all" ]; then
104
124
if [ " $TARGET " = " all" ]; then
105
125
echo " ERROR: You need to specify target for non-default builds"
@@ -123,8 +143,8 @@ if [ "$BUILD_TYPE" != "all" ]; then
123
143
# Skip building for targets that are not in the $TARGET array
124
144
continue
125
145
fi
126
-
127
- configs=" configs/defconfig.common;configs/defconfig.$target "
146
+
147
+ configs=" configs/defconfig.common;configs/defconfig.$target ;configs/defconfig.debug_ $BUILD_DEBUG "
128
148
for defconf in ` echo " $target_json " | jq -c ' .features[]' | tr -d ' "' ` ; do
129
149
configs=" $configs ;configs/defconfig.$defconf "
130
150
done
@@ -179,7 +199,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
179
199
continue
180
200
fi
181
201
fi
182
-
202
+
183
203
# Skip chips that should not be a part of the final libs
184
204
# WARNING!!! this logic needs to be updated when cron builds are split into jobs
185
205
if [ " $TARGET " = " all" ] && [ $target_skip -eq 1 ]; then
@@ -190,7 +210,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
190
210
echo " * Target: $target "
191
211
192
212
# Build Main Configs List
193
- main_configs=" configs/defconfig.common;configs/defconfig.$target "
213
+ main_configs=" configs/defconfig.common;configs/defconfig.$target ;configs/defconfig.debug_ $BUILD_DEBUG "
194
214
for defconf in ` echo " $target_json " | jq -c ' .features[]' | tr -d ' "' ` ; do
195
215
main_configs=" $main_configs ;configs/defconfig.$defconf "
196
216
done
@@ -201,18 +221,37 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
201
221
idf_libs_configs=" $idf_libs_configs ;configs/defconfig.$defconf "
202
222
done
203
223
224
+ if [ -f " $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash" ]; then
225
+ rm -rf $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash
226
+ fi
204
227
echo " * Build IDF-Libs: $idf_libs_configs "
205
228
rm -rf build sdkconfig
206
229
idf.py -DIDF_TARGET=" $target " -DSDKCONFIG_DEFAULTS=" $idf_libs_configs " idf-libs
207
230
if [ $? -ne 0 ]; then exit 1; fi
208
231
232
+ if [ " $target " == " esp32s3" ]; then
233
+ idf.py -DIDF_TARGET=" $target " -DSDKCONFIG_DEFAULTS=" $idf_libs_configs " srmodels_bin
234
+ if [ $? -ne 0 ]; then exit 1; fi
235
+ AR_SDK=" $AR_TOOLS /esp32-arduino-libs/$target "
236
+ # sr model.bin
237
+ if [ -f " build/srmodels/srmodels.bin" ]; then
238
+ echo " $AR_SDK /esp_sr"
239
+ mkdir -p " $AR_SDK /esp_sr"
240
+ cp -f " build/srmodels/srmodels.bin" " $AR_SDK /esp_sr/"
241
+ cp -f " partitions.csv" " $AR_SDK /esp_sr/"
242
+ fi
243
+ fi
209
244
# Build Bootloaders
210
245
for boot_conf in ` echo " $target_json " | jq -c ' .bootloaders[]' ` ; do
211
246
bootloader_configs=" $main_configs "
212
247
for defconf in ` echo " $boot_conf " | jq -c ' .[]' | tr -d ' "' ` ; do
213
248
bootloader_configs=" $bootloader_configs ;configs/defconfig.$defconf " ;
214
249
done
215
250
251
+ if [ -f " $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash" ]; then
252
+ rm -rf $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash
253
+ fi
254
+
216
255
echo " * Build BootLoader: $bootloader_configs "
217
256
rm -rf build sdkconfig
218
257
idf.py -DIDF_TARGET=" $target " -DSDKCONFIG_DEFAULTS=" $bootloader_configs " copy-bootloader
@@ -226,6 +265,9 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
226
265
mem_configs=" $mem_configs ;configs/defconfig.$defconf " ;
227
266
done
228
267
268
+ if [ -f " $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash" ]; then
269
+ rm -rf $AR_MANAGED_COMPS /espressif__esp-sr/.component_hash
270
+ fi
229
271
echo " * Build Memory Variant: $mem_configs "
230
272
rm -rf build sdkconfig
231
273
idf.py -DIDF_TARGET=" $target " -DSDKCONFIG_DEFAULTS=" $mem_configs " mem-variant
@@ -264,23 +306,33 @@ for component in `ls "$AR_MANAGED_COMPS"`; do
264
306
fi
265
307
done
266
308
309
+ # update package_esp32_index.template.json
310
+ if [ " $BUILD_TYPE " = " all" ]; then
311
+ python3 ./tools/gen_tools_json.py -i " $IDF_PATH " -j " $AR_COMPS /arduino/package/package_esp32_index.template.json" -o " $AR_OUT /"
312
+ python3 ./tools/gen_tools_json.py -i " $IDF_PATH " -o " $TOOLS_JSON_OUT /"
313
+ if [ $? -ne 0 ]; then exit 1; fi
314
+ fi
267
315
export IDF_COMMIT=$( git -C " $IDF_PATH " rev-parse --short HEAD)
268
316
269
- # Generate PlatformIO library manifest file
317
+ # Generate PlatformIO manifest file
270
318
if [ " $BUILD_TYPE " = " all" ]; then
271
- python3 ./tools/gen_pio_lib_manifest.py -o " $TOOLS_JSON_OUT /" -s " v$IDF_VERSION " -c " $IDF_COMMIT "
319
+ pushd $IDF_PATH
320
+ ibr=$( git describe --all --exact-match 2> /dev/null)
321
+ ic=$( git -C " $IDF_PATH " rev-parse --short HEAD)
322
+ popd
323
+ python3 ./tools/gen_platformio_manifest.py -o " $TOOLS_JSON_OUT /" -s " $ibr " -c " $ic "
272
324
if [ $? -ne 0 ]; then exit 1; fi
273
325
fi
274
326
327
+ # copy everything to arduino-esp32 installation
328
+ if [ $COPY_OUT -eq 1 ] && [ -d " $ESP32_ARDUINO " ]; then
329
+ ./tools/copy-to-arduino.sh
330
+ if [ $? -ne 0 ]; then exit 1; fi
331
+ fi
275
332
AR_VERSION=$( jq -c ' .version' " $AR_COMPS /arduino/package.json" | tr -d ' "' )
276
333
AR_VERSION_UNDERSCORE=` echo " $AR_VERSION " | tr . _`
277
334
278
- # Generate PlatformIO framework manifest file
279
- rm -rf " $AR_ROOT /package.json"
280
- if [ " $BUILD_TYPE " = " all" ]; then
281
- python3 ./tools/gen_pio_frmwk_manifest.py -o " $AR_ROOT /" -s " v$AR_VERSION " -c " $IDF_COMMIT "
282
- if [ $? -ne 0 ]; then exit 1; fi
283
- fi
335
+
284
336
285
337
# Generate core_version.h
286
338
rm -rf " $AR_ROOT /core_version.h"
@@ -289,6 +341,11 @@ echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short
289
341
#define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE
290
342
#define ARDUINO_ESP32_RELEASE \" $AR_VERSION_UNDERSCORE \" " >> " $AR_ROOT /core_version.h"
291
343
344
+ # push changes to esp32-arduino-libs and create pull request into arduino-esp32
345
+ if [ $DEPLOY_OUT -eq 1 ]; then
346
+ ./tools/push-to-arduino.sh
347
+ if [ $? -ne 0 ]; then exit 1; fi
348
+ fi
292
349
# archive the build
293
350
if [ $ARCHIVE_OUT -eq 1 ]; then
294
351
./tools/archive-build.sh " $TARGET "
0 commit comments