Skip to content

Commit 89add57

Browse files
authored
Build Pio framework manifest (#78)
1 parent 7a56bef commit 89add57

File tree

4 files changed

+98
-21
lines changed

4 files changed

+98
-21
lines changed

build.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -244,9 +244,16 @@ if [ "$BUILD_TYPE" = "all" ]; then
244244
if [ $? -ne 0 ]; then exit 1; fi
245245
fi
246246

247-
# Generate PlatformIO manifest file
247+
# Generate PlatformIO library manifest file
248248
if [ "$BUILD_TYPE" = "all" ]; then
249-
python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT"
249+
python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT"
250+
if [ $? -ne 0 ]; then exit 1; fi
251+
fi
252+
253+
# Generate PlatformIO framework manifest file
254+
rm -rf "$AR_ROOT/package.json"
255+
if [ "$BUILD_TYPE" = "all" ]; then
256+
python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT"
250257
if [ $? -ne 0 ]; then exit 1; fi
251258
fi
252259

package.json

-17
This file was deleted.

tools/gen_pio_frmwk_manifest.py

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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"3.0.0+sha.{commit_hash}"
53+
#MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}"
54+
json.dump(MANIFEST_DATA, fp, indent=2)
55+
56+
print(
57+
f"Generated PlatformIO framework manifest file '{manifest_file_path}' with '{converted_version}' version"
58+
)
59+
return 0
60+
61+
62+
if __name__ == "__main__":
63+
parser = argparse.ArgumentParser()
64+
parser.add_argument(
65+
"-o",
66+
"--dst-dir",
67+
dest="dst_dir",
68+
required=True,
69+
help="Destination folder where the 'package.json' manifest will be located",
70+
)
71+
parser.add_argument(
72+
"-s",
73+
"--version-string",
74+
dest="version_string",
75+
required=True,
76+
help="ESP-IDF version string used for compiling libraries",
77+
)
78+
parser.add_argument(
79+
"-c",
80+
"--commit-hash",
81+
dest="commit_hash",
82+
required=True,
83+
help="ESP-IDF revision in form of a commit hash",
84+
)
85+
args = parser.parse_args()
86+
87+
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

0 commit comments

Comments
 (0)