From f9bfcce65d3abcb304f47919b1892e7e1bee55aa Mon Sep 17 00:00:00 2001 From: Will Miles Date: Wed, 18 Jun 2025 12:08:57 -0400 Subject: [PATCH 1/2] Fix disabled usermod presence validation PlatformIO doesn't clean out the libdir when usermods are disabled, so they still appear in the LibBuilders() set. Ensure that we validate only usermods that were actually deps for the build. --- pio-scripts/load_usermods.py | 24 ++++++++++++++---------- pio-scripts/validate_modules.py | 5 +++-- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pio-scripts/load_usermods.py b/pio-scripts/load_usermods.py index 146cb1f87..38a08401e 100644 --- a/pio-scripts/load_usermods.py +++ b/pio-scripts/load_usermods.py @@ -77,17 +77,18 @@ def wrapped_ConfigureProjectLibBuilder(xenv): for dep in result.depbuilders: cached_add_includes(dep, processed_deps, extra_include_dirs) + wled_deps = [dep for dep in result.depbuilders if is_wled_module(dep)] + 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) + for dep in wled_deps: + # 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] @@ -97,6 +98,9 @@ def wrapped_ConfigureProjectLibBuilder(xenv): err=True) Exit(1) + # Save the depbuilders list for later validation + xenv.Replace(WLED_MODULES=wled_deps) + return result # Apply the wrapper diff --git a/pio-scripts/validate_modules.py b/pio-scripts/validate_modules.py index f8c9a599d..03348bbde 100644 --- a/pio-scripts/validate_modules.py +++ b/pio-scripts/validate_modules.py @@ -53,9 +53,10 @@ def validate_map_file(source, target, env): secho(f"ERROR: Map file not found: {map_file_path}", fg="red", err=True) Exit(1) - # Identify the WLED module source directories - module_lib_builders = [builder for builder in env.GetLibBuilders() if is_wled_module(env, builder)] + # Identify the WLED module builders, set by load_usermods.py + module_lib_builders = env['WLED_MODULES'] + # Filter/warn if an incompatible usermod was requested if env.GetProjectOption("custom_usermods","") == "*": # All usermods build; filter non-platform-OK modules module_lib_builders = [builder for builder in module_lib_builders if env.IsCompatibleLibBuilder(builder)] From 368351bbdd68a73dcb470f5668359208d7bdb6fc Mon Sep 17 00:00:00 2001 From: Will Miles Date: Wed, 18 Jun 2025 12:10:00 -0400 Subject: [PATCH 2/2] Remove nonfunctional usermod validation Non-platform-safe usermods are filtered out before validation runs; so this check is no longer functional. --- pio-scripts/validate_modules.py | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/pio-scripts/validate_modules.py b/pio-scripts/validate_modules.py index 03348bbde..d63b609ac 100644 --- a/pio-scripts/validate_modules.py +++ b/pio-scripts/validate_modules.py @@ -56,19 +56,6 @@ def validate_map_file(source, target, env): # Identify the WLED module builders, set by load_usermods.py module_lib_builders = env['WLED_MODULES'] - # Filter/warn if an incompatible usermod was requested - if env.GetProjectOption("custom_usermods","") == "*": - # All usermods build; filter non-platform-OK modules - module_lib_builders = [builder for builder in module_lib_builders if env.IsCompatibleLibBuilder(builder)] - else: - incompatible_builders = [builder for builder in module_lib_builders if not env.IsCompatibleLibBuilder(builder)] - if incompatible_builders: - secho( - f"ERROR: Modules {[b.name for b in incompatible_builders]} are not compatible with this platform!", - fg="red", - err=True) - Exit(1) - # Extract the values we care about modules = {Path(builder.build_dir).name: builder.name for builder in module_lib_builders} secho(f"INFO: {len(modules)} libraries linked as WLED optional/user modules")