mirror of
https://github.com/wled/WLED.git
synced 2025-07-23 18:56:41 +00:00
Fix up usermod libArchive settings
The ConfigureProjectLibBuilder process will flush and reload the library settings from the on-disk manifests if any new library is installed at that stage. This has the side effect of reverting the libArchive setting applied to usermods which was performed prior to that call. Apply the setting afterwards, instead. Fixes #4597
This commit is contained in:
parent
d10714d1c1
commit
7998650e60
@ -2,16 +2,19 @@ Import('env')
|
||||
import os.path
|
||||
from collections import deque
|
||||
from pathlib import Path # For OS-agnostic path manipulation
|
||||
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 +31,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 +92,6 @@ old_ConfigureProjectLibBuilder = env.ConfigureProjectLibBuilder
|
||||
|
||||
# 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 +105,18 @@ 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)
|
||||
for dep in result.depbuilders:
|
||||
if is_wled_module(dep):
|
||||
# Add the wled folder to the include path
|
||||
dep.env.PrependUnique(CPPPATH=wled_dir)
|
||||
# Add WLED's own dependencies
|
||||
for dir in extra_include_dirs:
|
||||
dep.env.PrependUnique(CPPPATH=dir)
|
||||
# Enforce that libArchive is not set; we must link them directly to the executable
|
||||
if dep.lib_archive:
|
||||
build = dep._manifest.get("build", {})
|
||||
build["libArchive"] = False
|
||||
dep._manifest["build"] = build
|
||||
|
||||
return result
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user