Skip to content

Commit 531dad7

Browse files
authored
builder updates (#84)
* Update GH actions * Update python * CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y * Use MacOS ARM * Update push.yml * Update push.yml * add lib Builder branch * add env * add comments * CONFIG_ETH_TRANSMIT_MUTEX * Fix build of build Platformio manifest (fail in second run) * fix manifest script build error * rm outdated code * don't know why it needs to be restored?!? * Build Pio framework manifest (#78) * Update build.sh * Update gen_pio_frmwk_manifest.py * Delete core_version.h * generate core version.h * Update build.sh
1 parent 07de5dd commit 531dad7

12 files changed

+150
-47
lines changed

.github/workflows/push.yml

+8-5
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,22 @@ on:
55
jobs:
66
build-libs:
77
name: Build Arduino Libs
8-
runs-on: ubuntu-22.04
8+
runs-on: macos-14
99
steps:
10-
- uses: actions/checkout@v3
10+
- uses: actions/checkout@v4
1111
- name: Set up Python
12-
uses: actions/setup-python@v4
12+
uses: actions/setup-python@v5
1313
with:
14-
python-version: '3.10'
14+
python-version: '3.11'
1515
- name: Install dependencies
1616
run: bash ./tools/prepare-ci.sh
17+
- name: Get current branch
18+
run: |
19+
echo "GIT_BRANCH=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_ENV
1720
- name: Build Arduino Libs
1821
run: bash ./build.sh
1922
- name: Release
20-
uses: jason2866/action-gh-release@v1.2
23+
uses: jason2866/action-gh-release@v1.3
2124
with:
2225
tag_name: ${{ github.run_number }}
2326
body_path: release-info.txt

build.sh

+25-5
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,10 @@ mkdir -p "$AR_TOOLS/esp32-arduino-libs"
144144
rm -rf release-info.txt
145145
IDF_Commit_short=$(git -C "$IDF_PATH" rev-parse --short HEAD || echo "")
146146
AR_Commit_short=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "")
147-
echo "Framework built from
148-
- $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)
149-
- $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)" >> release-info.txt
147+
echo "Framework built from
148+
- $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)
149+
- $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)
150+
- Arduino lib builder branch: $GIT_BRANCH" >> release-info.txt
150151

151152
#targets_count=`jq -c '.targets[] | length' configs/builds.json`
152153
for target_json in `jq -c '.targets[]' configs/builds.json`; do
@@ -234,19 +235,38 @@ for component in `ls "$AR_MANAGED_COMPS"`; do
234235
fi
235236
done
236237

238+
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
239+
237240
# update package_esp32_index.template.json
238241
if [ "$BUILD_TYPE" = "all" ]; then
239242
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -j "$AR_COMPS/arduino/package/package_esp32_index.template.json" -o "$AR_OUT/"
240243
python3 ./tools/gen_tools_json.py -i "$IDF_PATH" -o "$TOOLS_JSON_OUT/"
241244
if [ $? -ne 0 ]; then exit 1; fi
242245
fi
243246

244-
# Generate PlatformIO manifest file
247+
# Generate PlatformIO library manifest file
245248
if [ "$BUILD_TYPE" = "all" ]; then
246-
python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s $(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD) -c $(git -C "$IDF_PATH" rev-parse --short HEAD)
249+
python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT"
247250
if [ $? -ne 0 ]; then exit 1; fi
248251
fi
249252

253+
AR_VERSION=$(jq -c '.version' "$AR_COMPS/arduino/package.json" | tr -d '"')
254+
AR_VERSION_UNDERSCORE=`echo "$AR_VERSION" | tr . _`
255+
256+
# Generate PlatformIO framework manifest file
257+
rm -rf "$AR_ROOT/package.json"
258+
if [ "$BUILD_TYPE" = "all" ]; then
259+
python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "v$AR_VERSION" -c "$IDF_COMMIT"
260+
if [ $? -ne 0 ]; then exit 1; fi
261+
fi
262+
263+
# Generate core_version.h
264+
rm -rf "$AR_ROOT/core_version.h"
265+
echo "#define ARDUINO_ESP32_GIT_VER 0x$AR_Commit_short
266+
#define ARDUINO_ESP32_GIT_DESC $AR_VERSION
267+
#define ARDUINO_ESP32_RELEASE_$AR_VERSION_UNDERSCORE
268+
#define ARDUINO_ESP32_RELEASE \"$AR_VERSION_UNDERSCORE\"" >> "$AR_ROOT/core_version.h"
269+
250270
# copy everything to arduino-esp32 installation
251271
if [ $COPY_OUT -eq 1 ] && [ -d "$ESP32_ARDUINO" ]; then
252272
./tools/copy-to-arduino.sh

configs/defconfig.common

+2
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ CONFIG_ESP_WIFI_CSI_ENABLED=n
4242
CONFIG_ESP_WIFI_ENABLE_WPA3_SAE=y
4343
# CONFIG_ESP_WIFI_IRAM_OPT is not set
4444
# CONFIG_ESP_WIFI_RX_IRAM_OPT is not set
45+
CONFIG_ETH_TRANSMIT_MUTEX=y
4546
CONFIG_ETH_SPI_ETHERNET_DM9051=y
4647
CONFIG_ETH_SPI_ETHERNET_W5500=y
4748
CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL=y
@@ -188,6 +189,7 @@ CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y
188189
CONFIG_OPENSSL_ASSERT_DO_NOTHING=y
189190
CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048
190191
CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED=y
192+
CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y
191193
CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=10
192194
CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=2
193195
CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=4096

core_version.h

-4
This file was deleted.

package.json

-17
This file was deleted.

tools/archive-build.sh

-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
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

75
archive_path="dist/arduino-esp32-libs-$idf_version_string.tar.gz"

tools/config.sh

+12-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if [ -z $IDF_PATH ]; then
66
fi
77

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

1212
# Arduino branch to use
@@ -60,17 +60,20 @@ TOOLS_JSON_OUT="$AR_TOOLS/esp32-arduino-libs"
6060
IDF_LIBS_DIR="$AR_ROOT/../esp32-arduino-libs"
6161

6262
if [ "$IDF_COMMIT" ]; then
63-
echo "Using IDF commit $IDF_COMMIT"
6463
export IDF_COMMIT
65-
elif [ -d "$IDF_PATH" ]; then
66-
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
67-
export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)
6864
fi
6965

66+
if [ -d "$IDF_PATH" ]; then
67+
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
68+
fi
69+
70+
echo "Using IDF branch $IDF_BRANCH"
71+
echo "Using IDF commit $IDF_COMMIT"
72+
7073
if [ "$AR_COMMIT" ]; then
71-
echo "Using commit $AR_COMMIT for Arduino"
74+
echo "Using Arduino commit $AR_COMMIT"
7275
else
73-
AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "")
76+
export AR_COMMIT=$(git -C "$AR_COMPS/arduino" rev-parse --short HEAD || echo "")
7477
fi
7578

7679
#rm -rf release-info.txt
@@ -103,6 +106,7 @@ function get_os(){
103106
AR_OS=`get_os`
104107

105108
export SED="sed"
109+
export AWK="awk"
106110
export SSTAT="stat -c %s"
107111

108112
if [[ "$AR_OS" == "macos" ]]; then
@@ -115,6 +119,7 @@ if [[ "$AR_OS" == "macos" ]]; then
115119
exit 1
116120
fi
117121
export SED="gsed"
122+
export AWK="gawk"
118123
export SSTAT="stat -f %z"
119124
fi
120125

tools/gen_pio_frmwk_manifest.py

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
import argparse
2+
import json
3+
import os
4+
import re
5+
import sys
6+
7+
MANIFEST_DATA = {
8+
"name": "framework-arduinoespressif32",
9+
"description": "Platformio Tasmota Arduino framework for the Espressif ESP32 series of SoCs",
10+
"keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"],
11+
"license": "LGPL-2.1-or-later",
12+
"repository": {
13+
"type": "git",
14+
"url": "https://github.com/tasmota/arduino-esp32",
15+
},
16+
}
17+
18+
19+
def convert_version(version_string):
20+
"""A helper function that converts a custom IDF version string
21+
extracted from a Git repository to a suitable SemVer alternative. For example:
22+
'release/v5.1' becomes '5.1.0',
23+
'v7.7.7' becomes '7.7.7'
24+
"""
25+
26+
regex_pattern = (
27+
r"v(?P<MAJOR>0|[1-9]\d*)\.(?P<MINOR>0|[1-9]\d*)\.*(?P<PATCH>0|[1-9]\d*)*"
28+
)
29+
match = re.search(regex_pattern, version_string)
30+
if not match:
31+
sys.stderr.write(
32+
f"Failed to find a regex match for '{regex_pattern}' in '{version_string}'\n"
33+
)
34+
return ""
35+
36+
major, minor, patch = match.groups()
37+
if not patch:
38+
patch = "0"
39+
40+
return ".".join((major, minor, patch))
41+
42+
43+
def main(dst_dir, version_string, commit_hash):
44+
45+
converted_version = convert_version(version_string)
46+
if not converted_version:
47+
sys.stderr.write(f"Failed to convert version '{version_string}'\n")
48+
return -1
49+
50+
manifest_file_path = os.path.join(dst_dir, "package.json")
51+
with open(manifest_file_path, "w", encoding="utf8") as fp:
52+
MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}"
53+
json.dump(MANIFEST_DATA, fp, indent=2)
54+
55+
print(
56+
f"Generated PlatformIO framework manifest file '{manifest_file_path}' with '{converted_version}' version"
57+
)
58+
return 0
59+
60+
61+
if __name__ == "__main__":
62+
parser = argparse.ArgumentParser()
63+
parser.add_argument(
64+
"-o",
65+
"--dst-dir",
66+
dest="dst_dir",
67+
required=True,
68+
help="Destination folder where the 'package.json' manifest will be located",
69+
)
70+
parser.add_argument(
71+
"-s",
72+
"--version-string",
73+
dest="version_string",
74+
required=True,
75+
help="ESP-IDF version string used for compiling libraries",
76+
)
77+
parser.add_argument(
78+
"-c",
79+
"--commit-hash",
80+
dest="commit_hash",
81+
required=True,
82+
help="ESP-IDF revision in form of a commit hash",
83+
)
84+
args = parser.parse_args()
85+
86+
sys.exit(main(args.dst_dir, args.version_string, args.commit_hash))

tools/gen_platformio_manifest.py renamed to tools/gen_pio_lib_manifest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
MANIFEST_DATA = {
88
"name": "framework-arduinoespressif32-libs",
99
"description": "Precompiled libraries for Arduino Wiring-based Framework for the Espressif ESP32 series of SoCs",
10-
"keywords": ["framework", "arduino", "espressif", "esp32"],
10+
"keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"],
1111
"license": "LGPL-2.1-or-later",
1212
"repository": {
1313
"type": "git",
@@ -53,7 +53,7 @@ def main(dst_dir, version_string, commit_hash):
5353
json.dump(MANIFEST_DATA, fp, indent=2)
5454

5555
print(
56-
f"Generated PlatformIO manifest file '{manifest_file_path}' with '{converted_version}' version"
56+
f"Generated PlatformIO libraries manifest file '{manifest_file_path}' with '{converted_version}' version"
5757
)
5858
return 0
5959

tools/gen_tools_json.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
if tool_name.endswith('-elf'):
6060
tool_name += '-gcc'
6161
print('Found {0}, version: {1}'.format(tool_name, tool_version))
62-
62+
6363
if simple_output == False:
6464
dep_found = False
6565
dep_skip = False

tools/install-esp-idf.sh

-2
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ fi
6363
if [ ! -x $idf_was_installed ] || [ ! -x $commit_predefined ]; then
6464
git submodule update --recursive
6565
$IDF_PATH/install.sh
66-
export IDF_COMMIT=$(git -C "$IDF_PATH" rev-parse --short HEAD)
67-
export IDF_BRANCH=$(git -C "$IDF_PATH" symbolic-ref --short HEAD || git -C "$IDF_PATH" tag --points-at HEAD)
6866

6967
# Temporarily patch the ESP32-S2 I2C LL driver to keep the clock source
7068
cd $IDF_PATH

tools/prepare-ci.sh

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
#!/bin/bash
22

3-
sudo apt-get install -y gperf cmake ninja-build
4-
pip3 install wheel future pyelftools
3+
# Ubuntu setup
4+
# Change in archive-build.sh gawk to awk
5+
#sudo apt-get install -y gperf cmake ninja-build
6+
#pip3 install wheel future pyelftools
7+
8+
# MacOS (ARM) setup
9+
# Change in archive-build.sh awk to gawk
10+
brew install gsed
11+
brew install gawk
12+
brew install gperf
13+
brew install ninja
14+
brew install ccache
15+
python -m pip install --upgrade pip
16+
pip install wheel future pyelftools

0 commit comments

Comments
 (0)