From 3dcd8d7f13b301c20eda33c1184dbe91296f50e1 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 25 Feb 2024 20:28:30 +0100 Subject: [PATCH] Add some checks for valid env (#20805) --- pio-tools/post_esp32.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/pio-tools/post_esp32.py b/pio-tools/post_esp32.py index 6cae0997c..9753c04d4 100644 --- a/pio-tools/post_esp32.py +++ b/pio-tools/post_esp32.py @@ -126,11 +126,21 @@ def patch_partitions_bin(size_string): print("New partition hash:",result.digest().hex()) def esp32_create_chip_string(chip): - tasmota_platform = env.subst("$BUILD_DIR").split(os.path.sep)[-1] - tasmota_platform = tasmota_platform.split('-')[0] - if 'tasmota' + chip[3:] not in tasmota_platform: # quick check for a valid name like 'tasmota' + '32c3' - print('Unexpected naming conventions in this build environment -> Undefined behavior for further build process!!') + tasmota_platform_org = env.subst("$BUILD_DIR").split(os.path.sep)[-1] + tasmota_platform = tasmota_platform_org.split('-')[0] + if "tasmota" + chip[3:] not in tasmota_platform: # quick check for a valid name like 'tasmota' + '32c3' + print("Unexpected naming convention in this build environment:", tasmota_platform_org) print("Expected build environment name like 'tasmota32-whatever-you-want'") + print("Please correct your actual build environment, to avoid undefined behavior in build process!!") + if "-DUSE_USB_CDC_CONSOLE" in env.BoardConfig().get("build.extra_flags") and "cdc" not in tasmota_platform: + tasmota_platform += "cdc" + print("WARNING: board definition uses CDC configuration, but environment name does not -> adding 'cdc' to environment name") + print("Please correct your actual build environment, to avoid undefined behavior in build process!!") + if ("CORE32SOLO1" in extra_flags or "FRAMEWORK_ARDUINO_SOLO1" in build_flags) and "tasmota32solo1" not in tasmota_platform_org: + print("Unexpected naming convention in this build environment:", tasmota_platform_org) + print("Expected build environment name like 'tasmota32solo1-whatever-you-want'") + print("Please correct your actual build environment, to avoid undefined behavior in build process!!") + tasmota_platform = "tasmota32solo1" return tasmota_platform def esp32_build_filesystem(fs_size): @@ -222,10 +232,6 @@ def esp32_create_combined_bin(source, target, env): firmware_name = env.subst("$BUILD_DIR/${PROGNAME}.bin") tasmota_platform = esp32_create_chip_string(chip) - if "-DUSE_USB_CDC_CONSOLE" in env.BoardConfig().get("build.extra_flags") and "cdc" not in tasmota_platform: - tasmota_platform += "cdc" - print("WARNING: board definition uses CDC configuration, but environment name does not -> changing tasmota safeboot binary to:", tasmota_platform + "-safeboot.bin") - if not os.path.exists(variants_dir): os.makedirs(variants_dir) if "safeboot" in firmware_name: