usermods/*/setup_deps.py: Check lib_deps for deps

Check the safest possible location for final information on what
components are actually being linked in.  This demonstrates a safe
approach that works even for out-of-tree modules.
This commit is contained in:
Will Miles
2025-05-24 22:18:22 -04:00
parent 0a7d3a9d9b
commit 75c95d88e2
3 changed files with 12 additions and 10 deletions

View File

@@ -1,11 +1,12 @@
from platformio.package.meta import PackageSpec
Import('env')
usermods = env.GetProjectOption("custom_usermods","").split()
libs = [PackageSpec(lib).name for lib in env.GetProjectOption("lib_deps",[])]
# Check for dependencies
if "Temperature" in usermods:
if "Temperature" in libs:
env.Append(CPPDEFINES=[("USERMOD_DALLASTEMPERATURE")])
elif "sht" in usermods:
elif "sht" in libs:
env.Append(CPPDEFINES=[("USERMOD_SHT")])
elif "PWM_fan" in usermods: # The script can be run if this module was previously selected
elif "PWM_fan" in libs: # The script can be run if this module was previously selected
raise RuntimeError("PWM_fan usermod requires Temperature or sht to be enabled")