Skip to content

Commit d185350

Browse files
committed
Updates and enhances scripts
1 parent 3ec6ec9 commit d185350

11 files changed

+393
-128
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ version.txt
2222
dependencies.lock
2323
managed_components/
2424
target/
25+
core_version.h
26+
package.json
27+
release-info.txt

build.sh

Lines changed: 53 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,18 @@ export IDF_COMPONENT_OVERWRITE_MANAGED_COMPONENTS=1
2020

2121
CCACHE_ENABLE=1
2222

23-
TARGET="all"
23+
export TARGET="all"
2424
BUILD_TYPE="all"
2525
BUILD_DEBUG="default"
2626
SKIP_ENV=0
2727
COPY_OUT=0
28-
ARCHIVE_OUT=0
28+
ARCHIVE_OUT=1
2929
if [ -z $DEPLOY_OUT ]; then
3030
DEPLOY_OUT=0
3131
fi
3232

3333
function print_help() {
34+
3435
echo "Usage: build.sh [-s] [-n] [-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 ...]"
3536
echo " -s Skip installing/updating of ESP-IDF and all components"
3637
echo " -n Disable ccache"
@@ -47,17 +48,17 @@ function print_help() {
4748
exit 1
4849
}
4950

50-
while getopts ":A:I:i:c:t:b:D:sde" opt; do
51+
while getopts ":A:I:i:c:t:b:D:sdne" opt; do
5152
case ${opt} in
5253
s )
5354
SKIP_ENV=1
5455
;;
55-
n )
56-
CCACHE_ENABLE=0
57-
;;
5856
d )
5957
DEPLOY_OUT=1
6058
;;
59+
n )
60+
CCACHE_ENABLE=0
61+
;;
6162
e )
6263
ARCHIVE_OUT=1
6364
;;
@@ -112,6 +113,8 @@ echo "TARGET(s): ${TARGET[@]}"
112113

113114
mkdir -p dist
114115

116+
rm -rf dependencies.lock
117+
115118
if [ $SKIP_ENV -eq 0 ]; then
116119
echo "* Installing/Updating ESP-IDF and all components..."
117120
# update components from git
@@ -131,6 +134,10 @@ else
131134
source ./tools/config.sh
132135
fi
133136

137+
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
138+
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
139+
fi
140+
134141
if [ "$BUILD_TYPE" != "all" ]; then
135142
if [ "$TARGET" = "all" ]; then
136143
echo "ERROR: You need to specify target for non-default builds"
@@ -175,9 +182,20 @@ if [ "$BUILD_TYPE" != "all" ]; then
175182
exit 0
176183
fi
177184

185+
git submodule update --init --recursive
186+
178187
rm -rf build sdkconfig out
179188
mkdir -p "$AR_TOOLS/esp32-arduino-libs"
180189

190+
# Add release-info
191+
rm -rf release-info.txt
192+
IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "")
193+
AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "")
194+
echo "Framework built from
195+
- $IDF_REPO branch [$IDF_BRANCH](https://github.com/$IDF_REPO/tree/$IDF_BRANCH) commit [$IDF_Commit_short](https://github.com/$IDF_REPO/commits/$IDF_BRANCH/#:~:text=$IDF_Commit_short)
196+
- $AR_REPO branch [$AR_BRANCH](https://github.com/$AR_REPO/tree/$AR_BRANCH) commit [$AR_Commit_short](https://github.com/$AR_REPO/commits/$AR_BRANCH/#:~:text=$AR_Commit_short)
197+
- Arduino lib builder branch: $GIT_BRANCH" >> release-info.txt
198+
181199
#targets_count=`jq -c '.targets[] | length' configs/builds.json`
182200
for target_json in `jq -c '.targets[]' configs/builds.json`; do
183201
target=$(echo "$target_json" | jq -c '.target' | tr -d '"')
@@ -221,6 +239,9 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
221239
idf_libs_configs="$idf_libs_configs;configs/defconfig.$defconf"
222240
done
223241

242+
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
243+
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
244+
fi
224245
echo "* Build IDF-Libs: $idf_libs_configs"
225246
rm -rf build sdkconfig
226247
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$idf_libs_configs" idf-libs
@@ -246,6 +267,10 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
246267
bootloader_configs="$bootloader_configs;configs/defconfig.$defconf";
247268
done
248269

270+
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
271+
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
272+
fi
273+
249274
echo "* Build BootLoader: $bootloader_configs"
250275
rm -rf build sdkconfig
251276
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$bootloader_configs" copy-bootloader
@@ -259,6 +284,10 @@ for target_json in `jq -c '.targets[]' configs/builds.json`; do
259284
mem_configs="$mem_configs;configs/defconfig.$defconf";
260285
done
261286

287+
if [ -f "$AR_MANAGED_COMPS/espressif__esp-sr/.component_hash" ]; then
288+
rm -rf $AR_MANAGED_COMPS/espressif__esp-sr/.component_hash
289+
fi
290+
262291
echo "* Build Memory Variant: $mem_configs"
263292
rm -rf build sdkconfig
264293
idf.py -DIDF_TARGET="$target" -DSDKCONFIG_DEFAULTS="$mem_configs" mem-variant
@@ -304,6 +333,7 @@ if [ "$BUILD_TYPE" = "all" ]; then
304333
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/"
305334
if [ $? -ne 0 ]; then exit 1; fi
306335
fi
336+
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
307337

308338
# Generate pioarduino manifest file
309339
if [ "$BUILD_TYPE" = "all" ]; then
@@ -316,12 +346,29 @@ if [ "$BUILD_TYPE" = "all" ]; then
316346
if [ $? -ne 0 ]; then exit 1; fi
317347
fi
318348

349+
AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"')
350+
AR_VERSION_UNDERSCORE=`echo "$AR_VERSION" | tr . _`
351+
352+
# Generate PlatformIO framework manifest file
353+
rm -rf "$AR_ROOT/package.json"
354+
319355
# copy everything to arduino-esp32 installation
320356
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
321357
echo "* Copying to Arduino..."
322358
./tools/copy-to-arduino.sh
323359
if [ $? -ne 0 ]; then exit 1; fi
324360
fi
361+
AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"')
362+
AR_VERSION_UNDERSCORE=`echo "$AR_VERSION" | tr . _`
363+
364+
365+
366+
# Generate core_version.h
367+
rm -rf "$AR_ROOT/core_version.h"
368+
echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short
369+
#define ARDUINO_ESP32_GIT_DESC $AR_VERSION
370+
#define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE
371+
#define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h"
325372

326373
# push changes to esp32-arduino-libs and create pull request into arduino-esp32
327374
if [ $DEPLOY_OUT -eq 1 ]; then

tools/archive-build.sh

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
11
#!/bin/bash
22

3-
IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "")
4-
IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD || echo "")
53
idf_version_string=${IDF_BRANCH//\//_}"-$IDF_COMMIT"
64

7-
archive_path="dist/arduino-esp32-libs-$1-$idf_version_string.tar.gz"
5+
archive_path="dist/arduino-esp32-libs-$TARGET-$idf_version_string.tar.gz"
6+
build_archive_path="dist/arduino-esp32-build-$TARGET-$idf_version_string.tar.gz"
7+
pio_archive_path="dist/framework-arduinoespressif32-$TARGET-$idf_version_string.tar.gz"
8+
pio_zip_archive_path="dist/framework-arduinoespressif32-$TARGET-$idf_version_string.zip"
9+
libs_archive_path="dist/framework-arduinoespressif32-libs-$TARGET-$idf_version_string"
10+
libs_zip_archive_path="$libs_archive_path.zip"
11+
libs_tar_archive_path="$libs_archive_path.tar.gz"
812

9-
mkdir -p dist && rm -rf "$archive_path"
10-
if [ -d "out" ]; then
11-
cd out && tar zcf "../$archive_path" * && cd ..
12-
fi
13+
mkdir -p dist && rm -rf "$archive_path" "$build_archive_path"
14+
15+
cd out
16+
echo "Creating PlatformIO Tasmota framework-arduinoespressif32"
17+
mkdir -p arduino-esp32/cores/esp32
18+
mkdir -p arduino-esp32/tools/partitions
19+
cp -rf ../components/arduino/tools arduino-esp32
20+
cp -rf ../components/arduino/cores arduino-esp32
21+
cp -rf ../components/arduino/libraries arduino-esp32
22+
cp -rf ../components/arduino/variants arduino-esp32
23+
cp -f ../components/arduino/CMa* arduino-esp32
24+
cp -f ../components/arduino/idf* arduino-esp32
25+
cp -f ../components/arduino/Kco* arduino-esp32
26+
cp -f ../components/arduino/pac* arduino-esp32
27+
# rm -rf arduino-esp32/docs
28+
# rm -rf arduino-esp32/tests
29+
# rm -rf arduino-esp32/idf_component_examples
30+
# rm -rf arduino-esp32/libraries/RainMaker
31+
# rm -rf arduino-esp32/libraries/Insights
32+
# rm -rf arduino-esp32/libraries/ESP_I2S
33+
# rm -rf arduino-esp32/libraries/SPIFFS
34+
# rm -rf arduino-esp32/libraries/BLE
35+
# rm -rf arduino-esp32/libraries/SimpleBLE
36+
# rm -rf arduino-esp32/libraries/BluetoothSerial
37+
# rm -rf arduino-esp32/libraries/WiFiProv
38+
# rm -rf arduino-esp32/libraries/WiFiClientSecure
39+
# rm -rf arduino-esp32/libraries/NetworkClientSecure
40+
# rm -rf arduino-esp32/libraries/ESP_SR
41+
# rm -rf arduino-esp32/libraries/ESP_NOW
42+
# rm -rf arduino-esp32/libraries/TFLiteMicro
43+
# rm -rf arduino-esp32/libraries/ESP32
44+
rm -rf arduino-esp32/package
45+
rm -rf arduino-esp32/tools/esp32-arduino-libs
46+
rm -rf arduino-esp32/tools/*.exe
47+
rm -rf arduino-esp32/tools/esptool.py
48+
rm -rf arduino-esp32/tools/get.py
49+
rm -rf arduino-esp32/tools/ide-debug
50+
rm -rf arduino-esp32/tools/gen_insights_package.py
51+
rm -rf arduino-esp32/platform.txt
52+
rm -rf arduino-esp32/programmers.txt
53+
rm -rf arduino-esp32/boards.txt
54+
rm -rf arduino-esp32/package.json
55+
rm -rf arduino-esp32/*.md
56+
cp -Rf tools/esp32-arduino-libs arduino-esp32/tools/
57+
cp ../package.json arduino-esp32/package.json
58+
cp ../core_version.h arduino-esp32/cores/esp32/core_version.h
59+
mv arduino-esp32/ framework-arduinoespressif32/
60+
cd framework-arduinoespressif32/libraries
61+
rm -rf **/examples
62+
cd ../tools/esp32-arduino-libs
63+
#rm -rf **/flags
64+
cd ../../../
65+
# If the framework is needed as tar.gz uncomment next line
66+
# tar --exclude=.* -zcf ../$pio_archive_path framework-arduinoespressif32/
67+
mv framework-arduinoespressif32/tools/esp32-arduino-libs framework-arduinoespressif32-libs
68+
69+
7z a -mx=9 -tzip -xr'!.*' ../$pio_zip_archive_path framework-arduinoespressif32/
70+
7z a -mx=9 -tzip -xr'!.*' ../$libs_zip_archive_path framework-arduinoespressif32-libs/

tools/config.sh

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ if [ -z $IDF_PATH ]; then
66
fi
77

88
if [ -z $IDF_BRANCH ]; then
9-
IDF_BRANCH="release/v5.3"
9+
export IDF_BRANCH="release/v5.3"
1010
fi
1111

12+
# Arduino branch to use
1213
if [ -z $AR_PR_TARGET_BRANCH ]; then
1314
AR_PR_TARGET_BRANCH="master"
1415
fi
@@ -27,6 +28,12 @@ fi
2728
# Owner of the target ESP32 Arduino repository
2829
AR_USER="${GITHUB_REPOSITORY_OWNER:-espressif}"
2930

31+
# IDF commit to use
32+
#IDF_COMMIT=""
33+
34+
# Arduino commit to use
35+
#AR_COMMIT=""
36+
3037
# The full name of the repository
3138
AR_REPO="$AR_USER/arduino-esp32"
3239
IDF_REPO="$AR_USER/esp-idf"
@@ -52,9 +59,21 @@ AR_SDK="$AR_TOOLS/esp32-arduino-libs/$IDF_TARGET"
5259
PIOARDUINO_SDK="FRAMEWORK_SDK_DIR, \"$IDF_TARGET\""
5360
TOOLS_JSON_OUT="$AR_TOOLS/esp32-arduino-libs"
5461

62+
if [ "$IDF_COMMIT" ]; then
63+
export IDF_COMMIT
64+
fi
65+
5566
if [ -d "$IDF_PATH" ]; then
5667
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
57-
export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)
68+
fi
69+
70+
echo "Using IDF branch $IDF_BRANCH"
71+
echo "Using IDF commit $IDF_COMMIT"
72+
73+
if [ "$AR_COMMIT" ]; then
74+
echo "Using Arduino commit $AR_COMMIT"
75+
else
76+
export AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "")
5877
fi
5978

6079
function get_os(){
@@ -84,6 +103,7 @@ function get_os(){
84103
AR_OS=`get_os`
85104

86105
export SED="sed"
106+
export AWK="awk"
87107
export SSTAT="stat -c %s"
88108

89109
if [[ "$AR_OS" == "macos" ]]; then
@@ -96,6 +116,7 @@ if [[ "$AR_OS" == "macos" ]]; then
96116
exit 1
97117
fi
98118
export SED="gsed"
119+
export AWK="gawk"
99120
export SSTAT="stat -f %z"
100121
fi
101122

tools/gen_pioarduino_manifest.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import os
44
import re
55
import sys
6+
import datetime
67

78
MANIFEST_DATA = {
89
"name": "framework-arduinoespressif32-libs",
@@ -11,7 +12,7 @@
1112
"license": "LGPL-2.1-or-later",
1213
"repository": {
1314
"type": "git",
14-
"url": "https://github.com/espressif/esp32-arduino-lib-builder",
15+
"url": "https://github.com/hamzahajeir/esp32-arduino-lib-builder",
1516
},
1617
}
1718

@@ -48,8 +49,10 @@ def main(dst_dir, version_string, commit_hash):
4849
return -1
4950

5051
manifest_file_path = os.path.join(dst_dir, "package.json")
52+
build_date = datetime.date.today()
5153
with open(manifest_file_path, "w", encoding="utf8") as fp:
5254
MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}"
55+
MANIFEST_DATA["date"] = f"{build_date}"
5356
json.dump(MANIFEST_DATA, fp, indent=2)
5457

5558
print(

tools/gen_tools_json.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def replace_if_xz(system):
3535
# let's get the checksum file from the release
3636
release_manifest_url = ""
3737
# parse the download url to extract all info needed for the checksum file url
38-
urlx = re.findall("^https://github.com/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/releases/download/([a-zA-Z0-9_\-.]+)/([a-zA-Z0-9_\-.]+)$", new_url)
38+
urlx = re.findall("^https://github.com/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)/releases/download/([a-zA-Z0-9_\\-.]+)/([a-zA-Z0-9_\-.]+)$", new_url)
3939
if urlx and len(urlx) > 0:
4040
(owner, proj, version, filename) = urlx[0]
4141
release_manifest_url = "https://github.com/%s/%s/releases/download/%s/%s-%s-checksum.sha256" % (owner, proj, version, proj, version)
@@ -59,7 +59,7 @@ def replace_if_xz(system):
5959
"files": []
6060
}
6161
release_manifest_contents = requests.get(release_manifest_url).text
62-
x = re.findall("\s([a-zA-Z0-9_\-.]+):\s([0-9]+)\s[a-z]+\\n([a-f0-9]+)\s\*.*", release_manifest_contents)
62+
x = re.findall("\s([a-zA-Z0-9_\-.]+):\s([0-9]+)\s[a-z]+\\n([a-f0-9]+)\\s\*.*", release_manifest_contents)
6363
if x and len(x) > 0:
6464
for line in x:
6565
(filename, size, checksum) = line

0 commit comments

Comments
 (0)