diff --git a/build.sh b/build.sh index 87391c5a4..d5c4f5bc5 100755 --- a/build.sh +++ b/build.sh @@ -244,9 +244,16 @@ if [ "$BUILD_TYPE" = "all" ]; then if [ $? -ne 0 ]; then exit 1; fi fi -# Generate PlatformIO manifest file +# Generate PlatformIO library manifest file if [ "$BUILD_TYPE" = "all" ]; then - python3 ./tools/gen_platformio_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + python3 ./tools/gen_pio_lib_manifest.py -o "$TOOLS_JSON_OUT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" + if [ $? -ne 0 ]; then exit 1; fi +fi + +# Generate PlatformIO framework manifest file +rm -rf "$AR_ROOT/package.json" +if [ "$BUILD_TYPE" = "all" ]; then + python3 ./tools/gen_pio_frmwk_manifest.py -o "$AR_ROOT/" -s "$IDF_BRANCH" -c "$IDF_COMMIT" if [ $? -ne 0 ]; then exit 1; fi fi diff --git a/package.json b/package.json deleted file mode 100644 index c184e5481..000000000 --- a/package.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "framework-arduinoespressif32", - "version": "3.0.0", - "description": "Tasmota Arduino Framework for the Espressif ESP32, ESP32-S and ESP32-C series of SoCs", - "keywords": [ - "tasmota", - "framework", - "arduino", - "espressif", - "esp32" - ], - "license": "LGPL-2.1-or-later", - "repository": { - "type": "git", - "url": "https://github.com/tasmota/arduino-esp32" - } -} diff --git a/tools/gen_pio_frmwk_manifest.py b/tools/gen_pio_frmwk_manifest.py new file mode 100644 index 000000000..dc5c26471 --- /dev/null +++ b/tools/gen_pio_frmwk_manifest.py @@ -0,0 +1,87 @@ +import argparse +import json +import os +import re +import sys + +MANIFEST_DATA = { + "name": "framework-arduinoespressif32", + "description": "Platformio Tasmota Arduino framework for the Espressif ESP32 series of SoCs", + "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], + "license": "LGPL-2.1-or-later", + "repository": { + "type": "git", + "url": "https://github.com/tasmota/arduino-esp32", + }, +} + + +def convert_version(version_string): + """A helper function that converts a custom IDF version string + extracted from a Git repository to a suitable SemVer alternative. For example: + 'release/v5.1' becomes '5.1.0', + 'v7.7.7' becomes '7.7.7' + """ + + regex_pattern = ( + r"v(?P0|[1-9]\d*)\.(?P0|[1-9]\d*)\.*(?P0|[1-9]\d*)*" + ) + match = re.search(regex_pattern, version_string) + if not match: + sys.stderr.write( + f"Failed to find a regex match for '{regex_pattern}' in '{version_string}'\n" + ) + return "" + + major, minor, patch = match.groups() + if not patch: + patch = "0" + + return ".".join((major, minor, patch)) + + +def main(dst_dir, version_string, commit_hash): + + converted_version = convert_version(version_string) + if not converted_version: + sys.stderr.write(f"Failed to convert version '{version_string}'\n") + return -1 + + manifest_file_path = os.path.join(dst_dir, "package.json") + with open(manifest_file_path, "w", encoding="utf8") as fp: + MANIFEST_DATA["version"] = f"3.0.0+sha.{commit_hash}" + #MANIFEST_DATA["version"] = f"{converted_version}+sha.{commit_hash}" + json.dump(MANIFEST_DATA, fp, indent=2) + + print( + f"Generated PlatformIO framework manifest file '{manifest_file_path}' with '{converted_version}' version" + ) + return 0 + + +if __name__ == "__main__": + parser = argparse.ArgumentParser() + parser.add_argument( + "-o", + "--dst-dir", + dest="dst_dir", + required=True, + help="Destination folder where the 'package.json' manifest will be located", + ) + parser.add_argument( + "-s", + "--version-string", + dest="version_string", + required=True, + help="ESP-IDF version string used for compiling libraries", + ) + parser.add_argument( + "-c", + "--commit-hash", + dest="commit_hash", + required=True, + help="ESP-IDF revision in form of a commit hash", + ) + args = parser.parse_args() + + sys.exit(main(args.dst_dir, args.version_string, args.commit_hash)) diff --git a/tools/gen_platformio_manifest.py b/tools/gen_pio_lib_manifest.py similarity index 89% rename from tools/gen_platformio_manifest.py rename to tools/gen_pio_lib_manifest.py index 02057d9a2..22df9a730 100644 --- a/tools/gen_platformio_manifest.py +++ b/tools/gen_pio_lib_manifest.py @@ -7,7 +7,7 @@ MANIFEST_DATA = { "name": "framework-arduinoespressif32-libs", "description": "Precompiled libraries for Arduino Wiring-based Framework for the Espressif ESP32 series of SoCs", - "keywords": ["framework", "arduino", "espressif", "esp32"], + "keywords": ["framework", "tasmota", "arduino", "espressif", "esp32"], "license": "LGPL-2.1-or-later", "repository": { "type": "git", @@ -53,7 +53,7 @@ def main(dst_dir, version_string, commit_hash): json.dump(MANIFEST_DATA, fp, indent=2) print( - f"Generated PlatformIO manifest file '{manifest_file_path}' with '{converted_version}' version" + f"Generated PlatformIO libraries manifest file '{manifest_file_path}' with '{converted_version}' version" ) return 0