Skip to content

Commit ad061a6

Browse files
authored
Update build.sh
1 parent d77f336 commit ad061a6

File tree

1 file changed

+67
-29
lines changed

1 file changed

+67
-29
lines changed

build.sh

Lines changed: 67 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if ! [ -x "$(command -v git)" ]; then
1010
exit 1
1111
fi
1212

13-
TARGET="all"
13+
export TARGET="all"
1414
BUILD_TYPE="all"
1515
SKIP_ENV=0
1616
COPY_OUT=0
@@ -20,15 +20,15 @@ if [ -z $DEPLOY_OUT ]; then
2020
fi
2121

2222
function print_help() {
23-
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 ...]"
23+
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 ...]"
2424
echo " -s Skip installing/updating of ESP-IDF and all components"
2525
echo " -A Set which branch of arduino-esp32 to be used for compilation"
2626
echo " -I Set which branch of ESP-IDF to be used for compilation"
2727
echo " -i Set which commit of ESP-IDF to be used for compilation"
2828
echo " -e Archive the build to dist"
2929
echo " -d Deploy the build to github arduino-esp32"
3030
echo " -c Set the arduino-esp32 folder to copy the result to. ex. '$HOME/Arduino/hardware/espressif/esp32'"
31-
echo " -t Set the build target(chip). ex. 'esp32s3'"
31+
echo " -t Set the build target(chip) ex. 'esp32s3' or select multiple targets(chips) by separating them with comma ex. 'esp32,esp32s3,esp32c3'"
3232
echo " -b Set the build type. ex. 'build' to build the project and prepare for uploading to a board"
3333
echo " ... Specify additional configs to be applied. ex. 'qio 80m' to compile for QIO Flash@80MHz. Requires -b"
3434
exit 1
@@ -59,16 +59,16 @@ while getopts ":A:I:i:c:t:b:sde" opt; do
5959
export IDF_COMMIT="$OPTARG"
6060
;;
6161
t )
62-
TARGET=$OPTARG
62+
IFS=',' read -ra TARGET <<< "$OPTARG"
6363
;;
6464
b )
6565
b=$OPTARG
66-
if [ "$b" != "build" ] &&
67-
[ "$b" != "menuconfig" ] &&
68-
[ "$b" != "reconfigure" ] &&
69-
[ "$b" != "idf_libs" ] &&
70-
[ "$b" != "copy_bootloader" ] &&
71-
[ "$b" != "mem_variant" ]; then
66+
if [ "$b" != "build" ] &&
67+
[ "$b" != "menuconfig" ] &&
68+
[ "$b" != "reconfigure" ] &&
69+
[ "$b" != "idf-libs" ] &&
70+
[ "$b" != "copy-bootloader" ] &&
71+
[ "$b" != "mem-variant" ]; then
7272
print_help
7373
fi
7474
BUILD_TYPE="$b"
@@ -86,6 +86,9 @@ done
8686
shift $((OPTIND -1))
8787
CONFIGS=$@
8888

89+
# Output the TARGET array
90+
echo "TARGET(s): ${TARGET[@]}"
91+
8992
mkdir -p dist
9093
rm -rf dependencies.lock
9194

@@ -113,27 +116,42 @@ if [ "$BUILD_TYPE" != "all" ]; then
113116
echo "ERROR: You need to specify target for non-default builds"
114117
print_help
115118
fi
116-
configs="configs/defconfig.common;configs/defconfig.$TARGET"
117119

118120
# Target Features Configs
119121
for target_json in `jq -c '.targets[]' configs/builds.json`; do
120122
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
121-
if [ "$TARGET" == "$target" ]; then
122-
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
123-
configs="$configs;configs/defconfig.$defconf"
124-
done
123+
124+
# Check if $target is in the $TARGET array
125+
target_in_array=false
126+
for item in "${TARGET[@]}"; do
127+
if [ "$item" = "$target" ]; then
128+
target_in_array=true
129+
break
130+
fi
131+
done
132+
133+
if [ "$target_in_array" = false ]; then
134+
# Skip building for targets that are not in the $TARGET array
135+
continue
125136
fi
126-
done
137+
138+
configs="configs/defconfig.common;configs/defconfig.$target"
139+
for defconf in `echo "$target_json" | jq -c '.features[]' | tr -d '"'`; do
140+
configs="$configs;configs/defconfig.$defconf"
141+
done
127142

128-
# Configs From Arguments
129-
for conf in $CONFIGS; do
130-
configs="$configs;configs/defconfig.$conf"
131-
done
143+
echo "* Building for $target"
132144

133-
echo "idf.py -DIDF_TARGET=\"$TARGET\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE"
134-
rm -rf build sdkconfig
135-
idf.py -DIDF_TARGET="$TARGET" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE
136-
if [ $? -ne 0 ]; then exit 1; fi
145+
# Configs From Arguments
146+
for conf in $CONFIGS; do
147+
configs="$configs;configs/defconfig.$conf"
148+
done
149+
150+
echo "idf.py -DIDF_TARGET=\"$target\" -DSDKCONFIG_DEFAULTS=\"$configs\" $BUILD_TYPE"
151+
rm -rf build sdkconfig
152+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$configs" $BUILD_TYPE
153+
if [ $? -ne 0 ]; then exit 1; fi
154+
done
137155
exit 0
138156
fi
139157

@@ -152,8 +170,28 @@ echo "Framework built from
152170
#targets_count=`jq -c '.targets[] | length' configs/builds.json`
153171
for target_json in `jq -c '.targets[]' configs/builds.json`; do
154172
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
173+
target_skip=$(echo "$target_json" | jq -c '.skip // 0')
174+
175+
# Check if $target is in the $TARGET array if not "all"
176+
if [ "$TARGET" != "all" ]; then
177+
target_in_array=false
178+
for item in "${TARGET[@]}"; do
179+
if [ "$item" = "$target" ]; then
180+
target_in_array=true
181+
break
182+
fi
183+
done
155184

156-
if [ "$TARGET" != "all" ] && [ "$TARGET" != "$target" ]; then
185+
# If $target is not in the $TARGET array, skip processing
186+
if [ "$target_in_array" = false ]; then
187+
echo "* Skipping Target: $target"
188+
continue
189+
fi
190+
fi
191+
192+
# Skip chips that should not be a part of the final libs
193+
# WARNING!!! this logic needs to be updated when cron builds are split into jobs
194+
if [ "$TARGET" = "all" ] && [ $target_skip -eq 1 ]; then
157195
echo "* Skipping Target: $target"
158196
continue
159197
fi
@@ -174,7 +212,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
174212

175213
echo "* Build IDF-Libs: $idf_libs_configs"
176214
rm -rf build sdkconfig
177-
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf_libs
215+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs
178216
if [ $? -ne 0 ]; then exit 1; fi
179217

180218
# Build Bootloaders
@@ -186,7 +224,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
186224

187225
echo "* Build BootLoader: $bootloader_configs"
188226
rm -rf build sdkconfig
189-
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy_bootloader
227+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader
190228
if [ $? -ne 0 ]; then exit 1; fi
191229
done
192230

@@ -199,7 +237,7 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
199237

200238
echo "* Build Memory Variant: $mem_configs"
201239
rm -rf build sdkconfig
202-
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem_variant
240+
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant
203241
if [ $? -ne 0 ]; then exit 1; fi
204242
done
205243
done
@@ -246,7 +284,7 @@ fi
246284

247285
# Generate PlatformIO library manifest file
248286
if [ "$BUILD_TYPE" = "all" ]; then
249-
python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT"
287+
python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "v$IDF_VERSION" -c "$IDF_COMMIT"
250288
if [ $? -ne 0 ]; then exit 1; fi
251289
fi
252290

0 commit comments

Comments
 (0)