diff --git a/pio-scripts/load_usermods.py b/pio-scripts/load_usermods.py index ab3c6476a6..8cf625ff6b 100644 --- a/pio-scripts/load_usermods.py +++ b/pio-scripts/load_usermods.py @@ -2,16 +2,21 @@ import os.path from collections import deque from pathlib import Path # For OS-agnostic path manipulation +from click import secho +from SCons.Script import Exit +from platformio.builder.tools.piolib import LibBuilderBase from platformio.package.manager.library import LibraryPackageManager usermod_dir = Path(env["PROJECT_DIR"]) / "usermods" -all_usermods = [f for f in usermod_dir.iterdir() if f.is_dir() and f.joinpath('library.json').exists()] +# "usermods" environment: expand list of usermods to everything in the folder if env['PIOENV'] == "usermods": # Add all usermods + all_usermods = [f for f in usermod_dir.iterdir() if f.is_dir() and f.joinpath('library.json').exists()] env.GetProjectConfig().set(f"env:usermods", 'custom_usermods', " ".join([f.name for f in all_usermods])) -def find_usermod(mod: str): +# Utility functions +def find_usermod(mod: str) -> Path: """Locate this library in the usermods folder. We do this to avoid needing to rename a bunch of folders; this could be removed later @@ -28,6 +33,13 @@ def find_usermod(mod: str): return mp raise RuntimeError(f"Couldn't locate module {mod} in usermods directory!") +def is_wled_module(dep: LibBuilderBase) -> bool: + """Returns true if the specified library is a wled module + """ + return usermod_dir in Path(dep.src_dir).parents or str(dep.name).startswith("wled-") + +## Script starts here +# Process usermod option usermods = env.GetProjectOption("custom_usermods","") if usermods: # Inject usermods in to project lib_deps @@ -82,13 +94,6 @@ def cached_add_includes(dep, dep_cache: set, includes: deque): # Our new wrapper def wrapped_ConfigureProjectLibBuilder(xenv): - # Update usermod properties - # Set libArchive before build actions are added - for um in (um for um in xenv.GetLibBuilders() if usermod_dir in Path(um.src_dir).parents): - build = um._manifest.get("build", {}) - build["libArchive"] = False - um._manifest["build"] = build - # Call the wrapped function result = old_ConfigureProjectLibBuilder.clone(xenv)() @@ -102,12 +107,25 @@ def wrapped_ConfigureProjectLibBuilder(xenv): for dep in result.depbuilders: cached_add_includes(dep, processed_deps, extra_include_dirs) - for um in [dep for dep in result.depbuilders if usermod_dir in Path(dep.src_dir).parents]: - # Add the wled folder to the include path - um.env.PrependUnique(CPPPATH=wled_dir) - # Add WLED's own dependencies - for dir in extra_include_dirs: - um.env.PrependUnique(CPPPATH=dir) + broken_usermods = [] + for dep in result.depbuilders: + if is_wled_module(dep): + # Add the wled folder to the include path + dep.env.PrependUnique(CPPPATH=str(wled_dir)) + # Add WLED's own dependencies + for dir in extra_include_dirs: + dep.env.PrependUnique(CPPPATH=str(dir)) + # Enforce that libArchive is not set; we must link them directly to the executable + if dep.lib_archive: + broken_usermods.append(dep) + + if broken_usermods: + broken_usermods = [usermod.name for usermod in broken_usermods] + secho( + f"ERROR: libArchive=false is missing on usermod(s) {' '.join(broken_usermods)} -- modules will not compile in correctly", + fg="red", + err=True) + Exit(1) return result diff --git a/usermods/ADS1115_v2/library.json b/usermods/ADS1115_v2/library.json index 9f0c021ce4..5e5d7e450a 100644 --- a/usermods/ADS1115_v2/library.json +++ b/usermods/ADS1115_v2/library.json @@ -1,5 +1,6 @@ { "name": "ADS1115_v2", + "build": { "libArchive": false }, "dependencies": { "Adafruit BusIO": "https://github.com/adafruit/Adafruit_BusIO#1.13.2", "Adafruit ADS1X15": "https://github.com/adafruit/Adafruit_ADS1X15#2.4.0" diff --git a/usermods/AHT10_v2/library.json b/usermods/AHT10_v2/library.json index 54f8c1715d..fa6c2a6fee 100644 --- a/usermods/AHT10_v2/library.json +++ b/usermods/AHT10_v2/library.json @@ -1,5 +1,6 @@ { "name": "AHT10_v2", + "build": { "libArchive": false }, "dependencies": { "enjoyneering/AHT10":"~1.1.0" } diff --git a/usermods/Analog_Clock/library.json b/usermods/Analog_Clock/library.json index 3ed596dc79..f76cf42681 100644 --- a/usermods/Analog_Clock/library.json +++ b/usermods/Analog_Clock/library.json @@ -1,3 +1,4 @@ { - "name": "Analog_Clock" + "name": "Analog_Clock", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/Animated_Staircase/library.json b/usermods/Animated_Staircase/library.json index a2c50ea4c1..015b15cef5 100644 --- a/usermods/Animated_Staircase/library.json +++ b/usermods/Animated_Staircase/library.json @@ -1,3 +1,4 @@ { - "name": "Animated_Staircase" + "name": "Animated_Staircase", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/BH1750_v2/library.json b/usermods/BH1750_v2/library.json index 13740e6c92..4e32099b0c 100644 --- a/usermods/BH1750_v2/library.json +++ b/usermods/BH1750_v2/library.json @@ -1,5 +1,6 @@ { "name": "BH1750_v2", + "build": { "libArchive": false }, "dependencies": { "claws/BH1750":"^1.2.0" } diff --git a/usermods/BME280_v2/library.json b/usermods/BME280_v2/library.json index 626fb8b2bc..cfdfe1ba1a 100644 --- a/usermods/BME280_v2/library.json +++ b/usermods/BME280_v2/library.json @@ -1,5 +1,6 @@ { "name": "BME280_v2", + "build": { "libArchive": false }, "dependencies": { "finitespace/BME280":"~3.0.0" } diff --git a/usermods/BME68X_v2/library.json b/usermods/BME68X_v2/library.json index 2f1e1a310f..b315aa5d4b 100644 --- a/usermods/BME68X_v2/library.json +++ b/usermods/BME68X_v2/library.json @@ -1,5 +1,6 @@ { "name": "BME68X", + "build": { "libArchive": false }, "dependencies": { "boschsensortec/BSEC Software Library":"^1.8.1492" } diff --git a/usermods/Battery/library.json b/usermods/Battery/library.json index d6b8ad38a9..8e71c60a77 100644 --- a/usermods/Battery/library.json +++ b/usermods/Battery/library.json @@ -1,3 +1,4 @@ { - "name": "Battery" + "name": "Battery", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/Cronixie/library.json b/usermods/Cronixie/library.json index a1454a79a7..4a1b6988e2 100644 --- a/usermods/Cronixie/library.json +++ b/usermods/Cronixie/library.json @@ -1,3 +1,4 @@ { - "name": "Cronixie" + "name": "Cronixie", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/EXAMPLE/library.json b/usermods/EXAMPLE/library.json index dd8a7e5dd4..d0dc2f88e6 100644 --- a/usermods/EXAMPLE/library.json +++ b/usermods/EXAMPLE/library.json @@ -1,4 +1,5 @@ { "name": "EXAMPLE", + "build": { "libArchive": false }, "dependencies": {} } diff --git a/usermods/EleksTube_IPS/library.json.disabled b/usermods/EleksTube_IPS/library.json.disabled index eddd12b88e..d143638e47 100644 --- a/usermods/EleksTube_IPS/library.json.disabled +++ b/usermods/EleksTube_IPS/library.json.disabled @@ -1,5 +1,6 @@ { "name:": "EleksTube_IPS", + "build": { "libArchive": false }, "dependencies": { "TFT_eSPI" : "2.5.33" } diff --git a/usermods/INA226_v2/library.json b/usermods/INA226_v2/library.json index ab6c81fbde..34fcd36830 100644 --- a/usermods/INA226_v2/library.json +++ b/usermods/INA226_v2/library.json @@ -1,5 +1,6 @@ { "name": "INA226_v2", + "build": { "libArchive": false }, "dependencies": { "wollewald/INA226_WE":"~1.2.9" } diff --git a/usermods/Internal_Temperature_v2/library.json b/usermods/Internal_Temperature_v2/library.json index 571176f452..b1826ab458 100644 --- a/usermods/Internal_Temperature_v2/library.json +++ b/usermods/Internal_Temperature_v2/library.json @@ -1,3 +1,4 @@ { - "name": "Internal_Temperature_v2" + "name": "Internal_Temperature_v2", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/LD2410_v2/library.json b/usermods/LD2410_v2/library.json index 92ad54da72..757ec40477 100644 --- a/usermods/LD2410_v2/library.json +++ b/usermods/LD2410_v2/library.json @@ -1,5 +1,6 @@ { "name": "LD2410_v2", + "build": { "libArchive": false }, "dependencies": { "ncmreynolds/ld2410":"^0.1.3" } diff --git a/usermods/LDR_Dusk_Dawn_v2/library.json b/usermods/LDR_Dusk_Dawn_v2/library.json index be06c3a3a0..709967ea70 100644 --- a/usermods/LDR_Dusk_Dawn_v2/library.json +++ b/usermods/LDR_Dusk_Dawn_v2/library.json @@ -1,3 +1,4 @@ { - "name": "LDR_Dusk_Dawn_v2" + "name": "LDR_Dusk_Dawn_v2", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/MY9291/library.json b/usermods/MY9291/library.json index e4c63eaf50..9c3a33d43e 100644 --- a/usermods/MY9291/library.json +++ b/usermods/MY9291/library.json @@ -1,4 +1,5 @@ { "name": "MY9291", + "build": { "libArchive": false }, "platforms": ["espressif8266"] } \ No newline at end of file diff --git a/usermods/PIR_sensor_switch/library.json b/usermods/PIR_sensor_switch/library.json index d5ebb7689c..b3cbcbbff6 100644 --- a/usermods/PIR_sensor_switch/library.json +++ b/usermods/PIR_sensor_switch/library.json @@ -1,3 +1,4 @@ { - "name": "PIR_sensor_switch" + "name": "PIR_sensor_switch", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/PWM_fan/library.json b/usermods/PWM_fan/library.json index a8f7a94461..8ae3d7fd6e 100644 --- a/usermods/PWM_fan/library.json +++ b/usermods/PWM_fan/library.json @@ -1,6 +1,7 @@ { "name": "PWM_fan", "build": { + "libArchive": false, "extraScript": "setup_deps.py" } } \ No newline at end of file diff --git a/usermods/RTC/library.json b/usermods/RTC/library.json index 8c103e06d5..688dfc2d0c 100644 --- a/usermods/RTC/library.json +++ b/usermods/RTC/library.json @@ -1,3 +1,4 @@ { - "name": "RTC" + "name": "RTC", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/SN_Photoresistor/library.json b/usermods/SN_Photoresistor/library.json index 45519dfa63..c896644f71 100644 --- a/usermods/SN_Photoresistor/library.json +++ b/usermods/SN_Photoresistor/library.json @@ -1,3 +1,4 @@ { - "name": "SN_Photoresistor" + "name": "SN_Photoresistor", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/ST7789_display/library.json.disabled b/usermods/ST7789_display/library.json.disabled index abcd4635c3..725e20a65a 100644 --- a/usermods/ST7789_display/library.json.disabled +++ b/usermods/ST7789_display/library.json.disabled @@ -1,3 +1,4 @@ { - "name:": "ST7789_display" + "name:": "ST7789_display", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/Si7021_MQTT_HA/library.json b/usermods/Si7021_MQTT_HA/library.json index cec2edfb10..e3d7635e35 100644 --- a/usermods/Si7021_MQTT_HA/library.json +++ b/usermods/Si7021_MQTT_HA/library.json @@ -1,5 +1,6 @@ { "name": "Si7021_MQTT_HA", + "build": { "libArchive": false }, "dependencies": { "finitespace/BME280":"3.0.0", "adafruit/Adafruit Si7021 Library" : "1.5.3" diff --git a/usermods/TetrisAI_v2/library.json b/usermods/TetrisAI_v2/library.json index bfff1aa4d4..54aa22d35b 100644 --- a/usermods/TetrisAI_v2/library.json +++ b/usermods/TetrisAI_v2/library.json @@ -1,3 +1,4 @@ { - "name": "TetrisAI_v2" + "name": "TetrisAI_v2", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/boblight/library.json b/usermods/boblight/library.json index 12debccf55..b54fb35058 100644 --- a/usermods/boblight/library.json +++ b/usermods/boblight/library.json @@ -1,3 +1,4 @@ { - "name": "boblight" + "name": "boblight", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/buzzer/library.json b/usermods/buzzer/library.json index c6af3158b2..0dbb547e34 100644 --- a/usermods/buzzer/library.json +++ b/usermods/buzzer/library.json @@ -1,3 +1,4 @@ { - "name": "buzzer" + "name": "buzzer", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/deep_sleep/library.json b/usermods/deep_sleep/library.json index 8b39b2eedb..82e32c9947 100644 --- a/usermods/deep_sleep/library.json +++ b/usermods/deep_sleep/library.json @@ -1,3 +1,4 @@ { - "name": "deep_sleep" + "name": "deep_sleep", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/multi_relay/library.json b/usermods/multi_relay/library.json index f1caf7d42b..a5e5c6934b 100644 --- a/usermods/multi_relay/library.json +++ b/usermods/multi_relay/library.json @@ -1,3 +1,4 @@ { - "name": "multi_relay" + "name": "multi_relay", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/pwm_outputs/library.json b/usermods/pwm_outputs/library.json index bcdb8d5a64..a01068bd43 100644 --- a/usermods/pwm_outputs/library.json +++ b/usermods/pwm_outputs/library.json @@ -1,3 +1,4 @@ { - "name": "pwm_outputs" + "name": "pwm_outputs", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/sd_card/library.json b/usermods/sd_card/library.json index 44d3e3495e..33e8f98f27 100644 --- a/usermods/sd_card/library.json +++ b/usermods/sd_card/library.json @@ -1,3 +1,4 @@ { - "name": "sd_card" + "name": "sd_card", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/seven_segment_display/library.json b/usermods/seven_segment_display/library.json index 653c3d7ff2..f78aad87b9 100644 --- a/usermods/seven_segment_display/library.json +++ b/usermods/seven_segment_display/library.json @@ -1,3 +1,4 @@ { - "name": "seven_segment_display" + "name": "seven_segment_display", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/seven_segment_display_reloaded/library.json b/usermods/seven_segment_display_reloaded/library.json index 4e84e38ed4..1b7d0687f2 100644 --- a/usermods/seven_segment_display_reloaded/library.json +++ b/usermods/seven_segment_display_reloaded/library.json @@ -1,6 +1,7 @@ { "name": "seven_segment_display_reloaded", "build": { + "libArchive": false, "extraScript": "setup_deps.py" - } + } } \ No newline at end of file diff --git a/usermods/sht/library.json b/usermods/sht/library.json index 6849628ca0..0916e9a378 100644 --- a/usermods/sht/library.json +++ b/usermods/sht/library.json @@ -1,5 +1,6 @@ { "name": "sht", + "build": { "libArchive": false }, "dependencies": { "robtillaart/SHT85": "~0.3.3" } diff --git a/usermods/smartnest/library.json b/usermods/smartnest/library.json index 9b428f6b17..3e9ea63a9b 100644 --- a/usermods/smartnest/library.json +++ b/usermods/smartnest/library.json @@ -1,3 +1,4 @@ { - "name": "smartnest" + "name": "smartnest", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/stairway_wipe_basic/library.json b/usermods/stairway_wipe_basic/library.json index b75baef6bd..f7d353b596 100644 --- a/usermods/stairway_wipe_basic/library.json +++ b/usermods/stairway_wipe_basic/library.json @@ -1,3 +1,4 @@ { - "name": "stairway_wipe_basic" + "name": "stairway_wipe_basic", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_rotary_brightness_color/library.json b/usermods/usermod_rotary_brightness_color/library.json index ecf73c0f99..4f7a146a0b 100644 --- a/usermods/usermod_rotary_brightness_color/library.json +++ b/usermods/usermod_rotary_brightness_color/library.json @@ -1,3 +1,4 @@ { - "name": "usermod_rotary_brightness_color" + "name": "usermod_rotary_brightness_color", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_HttpPullLightControl/library.json b/usermods/usermod_v2_HttpPullLightControl/library.json index a9252fc0cf..870753b994 100644 --- a/usermods/usermod_v2_HttpPullLightControl/library.json +++ b/usermods/usermod_v2_HttpPullLightControl/library.json @@ -1,3 +1,4 @@ { - "name": "usermod_v2_HttpPullLightControl" + "name": "usermod_v2_HttpPullLightControl", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_RF433/library.json b/usermods/usermod_v2_RF433/library.json index d809d3a0da..d8de29b8a5 100644 --- a/usermods/usermod_v2_RF433/library.json +++ b/usermods/usermod_v2_RF433/library.json @@ -1,5 +1,6 @@ { "name": "usermod_v2_RF433", + "build": { "libArchive": false }, "dependencies": { "sui77/rc-switch":"2.6.4" } diff --git a/usermods/usermod_v2_animartrix/library.json b/usermods/usermod_v2_animartrix/library.json index 4552be3301..667572bad9 100644 --- a/usermods/usermod_v2_animartrix/library.json +++ b/usermods/usermod_v2_animartrix/library.json @@ -1,5 +1,6 @@ { "name": "animartrix", + "build": { "libArchive": false }, "dependencies": { "Animartrix": "https://github.com/netmindz/animartrix.git#b172586" } diff --git a/usermods/usermod_v2_auto_save/library.json b/usermods/usermod_v2_auto_save/library.json index d703487a75..127767eb07 100644 --- a/usermods/usermod_v2_auto_save/library.json +++ b/usermods/usermod_v2_auto_save/library.json @@ -1,3 +1,4 @@ { - "name": "auto_save" + "name": "auto_save", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_brightness_follow_sun/library.json b/usermods/usermod_v2_brightness_follow_sun/library.json index 6120d873e3..dec00e55b6 100644 --- a/usermods/usermod_v2_brightness_follow_sun/library.json +++ b/usermods/usermod_v2_brightness_follow_sun/library.json @@ -1,3 +1,4 @@ { - "name": "brightness_follow_sun" + "name": "brightness_follow_sun", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_four_line_display_ALT/library.json b/usermods/usermod_v2_four_line_display_ALT/library.json index 87a690f03f..b164482234 100644 --- a/usermods/usermod_v2_four_line_display_ALT/library.json +++ b/usermods/usermod_v2_four_line_display_ALT/library.json @@ -1,5 +1,6 @@ { "name": "four_line_display_ALT", + "build": { "libArchive": false }, "dependencies": { "U8g2": "~2.34.4", "Wire": "" diff --git a/usermods/usermod_v2_klipper_percentage/library.json b/usermods/usermod_v2_klipper_percentage/library.json index 7a2df6b23f..962dda14e7 100644 --- a/usermods/usermod_v2_klipper_percentage/library.json +++ b/usermods/usermod_v2_klipper_percentage/library.json @@ -1,3 +1,4 @@ { - "name": "usermod_v2_klipper_percentage" + "name": "usermod_v2_klipper_percentage", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_ping_pong_clock/library.json b/usermods/usermod_v2_ping_pong_clock/library.json index d6c079e589..4b272eca47 100644 --- a/usermods/usermod_v2_ping_pong_clock/library.json +++ b/usermods/usermod_v2_ping_pong_clock/library.json @@ -1,3 +1,4 @@ { - "name": "usermod_v2_ping_pong_clock" + "name": "usermod_v2_ping_pong_clock", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/usermod_v2_rotary_encoder_ui_ALT/library.json b/usermods/usermod_v2_rotary_encoder_ui_ALT/library.json index ddb6334b16..7c828d087c 100644 --- a/usermods/usermod_v2_rotary_encoder_ui_ALT/library.json +++ b/usermods/usermod_v2_rotary_encoder_ui_ALT/library.json @@ -1,6 +1,7 @@ { "name": "rotary_encoder_ui_ALT", "build": { + "libArchive": false, "extraScript": "setup_deps.py" } } \ No newline at end of file diff --git a/usermods/usermod_v2_word_clock/library.json b/usermods/usermod_v2_word_clock/library.json index b0dcebc6eb..0ea99d8102 100644 --- a/usermods/usermod_v2_word_clock/library.json +++ b/usermods/usermod_v2_word_clock/library.json @@ -1,3 +1,4 @@ { - "name": "usermod_v2_word_clock" + "name": "usermod_v2_word_clock", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/wizlights/library.json b/usermods/wizlights/library.json index 114424e5d0..0bfc097c78 100644 --- a/usermods/wizlights/library.json +++ b/usermods/wizlights/library.json @@ -1,3 +1,4 @@ { - "name": "wizlights" + "name": "wizlights", + "build": { "libArchive": false } } \ No newline at end of file diff --git a/usermods/word-clock-matrix/library.json b/usermods/word-clock-matrix/library.json index afeae5025f..7bc3919de0 100644 --- a/usermods/word-clock-matrix/library.json +++ b/usermods/word-clock-matrix/library.json @@ -1,3 +1,4 @@ { - "name": "word-clock-matrix" + "name": "word-clock-matrix", + "build": { "libArchive": false } } \ No newline at end of file