-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert usermods to static libraries #4480
Draft
willmmiles
wants to merge
48
commits into
Aircoookie:main
Choose a base branch
from
willmmiles:usermod-libs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 30 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
b8685f2
Convert usermods to static libraries
willmmiles 4d5e0ca
load_usermods: Expand name search
willmmiles 71b0e8e
Convert AnimARTrix usermod to library
willmmiles 90b1815
Convert usermods from header to library
netmindz a5575bc
Fix naming of usermod files to match library name
netmindz 6e76a72
Convert usermods from header to library
netmindz 67022be
Build all usermods
netmindz cbed841
Include basic usermods in CI
netmindz c16d83f
Build custom_usermods = audioreactive auto_save animartrix
netmindz d64cedd
Build custom_usermods = audioreactive auto_save animartrix
netmindz 2381e32
Define dependencies for ADS1115 usermod
netmindz 79bac91
use bigger partitions for usermods env
netmindz d3eec72
Defining more usermod dependencies
netmindz 3521732
fix env:userods
netmindz 52b784e
fix env:usermods
netmindz 52bee88
fix word_clock_matrix naming
netmindz 075fd4d
Defining more usermod dependencies
netmindz 4c19341
Merge branch 'usermod-libs-migration' of github.com:netmindz/WLED int…
netmindz 8527d23
audioreactive: Move flags to library
willmmiles cc9e9b1
Fix usermod library builds
willmmiles f2626b0
Remove now-obsolete AR_build_flags
willmmiles 24accf9
Remove now redundant build section from library.json
netmindz b380d5e
reinstate libArchive:false
netmindz 2c9c413
Merge branch 'usermod-libs' into usermod-libs-migration
netmindz 1dbd706
Revert LOROL_LITTLEFS hack
netmindz e471487
typo in usermods/sensors_to_mqtt/library.json
netmindz 869e275
typo in usermods/sensors_to_mqtt/library.json
netmindz 0b8721c
Fix usermod libArchive setting
willmmiles 270d75a
Update usermod deps earlier
willmmiles 8fd9052
Integrate usermods environment
willmmiles 30559cd
Fix dependency for EleksTube_IPS usermod
willmmiles 32607ee
Revert incorrect testing platformio.ini
willmmiles ef2eb07
Merge branch 'main' into usermod-libs
2adf745
Update env:usermods to use V4
5da380e
Update dependencies for sensors_to_mqtt
59a79a3
Add deps for usermods/BME280_v2
0afd2fe
Destructor must be public
5d05d79
Add usermod dependencies
8487dd7
Disable build of usermods that are broken at the moment
15edfcd
Fix usermod platformio integration
willmmiles 193926c
usermods: Remove #pragma once from cpps
willmmiles 2b07be1
usermod mpu6050: Fix incorrect int type
willmmiles 44a1a1e
usermods: Fix MQTT checks
willmmiles 48372bc
platformio: Fix audioreactive usermod for ESP8266
willmmiles 0233dae
usermods/sensors_to_mqtt: Fix char type
willmmiles 30a697e
usermods/PWM_fan: Disable pending cross-mod check
willmmiles 1d558e8
platformio.ini: Add extra flags for usermod test
willmmiles 0d44e7e
Usermods: Remove libArchive
willmmiles File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
Import('env') | ||
from pathlib import Path # For OS-agnostic path manipulation | ||
|
||
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()] | ||
|
||
if env['PIOENV'] == "usermods": | ||
# Add all usermods | ||
env.GetProjectConfig().set(f"env:usermods", 'custom_usermods', " ".join([f.name for f in all_usermods])) | ||
|
||
def find_usermod(mod: str): | ||
"""Locate this library in the usermods folder. | ||
We do this to avoid needing to rename a bunch of folders; | ||
this could be removed later | ||
""" | ||
# Check name match | ||
mp = usermod_dir / mod | ||
if mp.exists(): | ||
return mp | ||
mp = usermod_dir / f"usermod_v2_{mod}" | ||
if mp.exists(): | ||
return mp | ||
raise RuntimeError(f"Couldn't locate module {mod} in usermods directory!") | ||
|
||
usermods = env.GetProjectOption("custom_usermods","") | ||
if usermods: | ||
proj = env.GetProjectConfig() | ||
deps = env.GetProjectOption('lib_deps') | ||
src_dir = proj.get("platformio", "src_dir") | ||
src_dir = src_dir.replace('\\','/') | ||
mod_paths = {mod: find_usermod(mod) for mod in usermods.split(" ")} | ||
usermods = [f"{mod} = symlink://{path}" for mod, path in mod_paths.items()] | ||
proj.set("env:" + env['PIOENV'], 'lib_deps', deps + usermods) | ||
|
||
|
||
# Monkey-patch ConfigureProjectLibBuilder to mark up the dependencies | ||
# Save the old value | ||
cpl = env.ConfigureProjectLibBuilder | ||
# Our new wrapper | ||
def cpl_wrapper(env): | ||
# Update usermod properties | ||
lib_builders = env.GetLibBuilders() | ||
um_deps = [dep for dep in lib_builders if usermod_dir in Path(dep.src_dir).parents] | ||
other_deps = [dep for dep in lib_builders if usermod_dir not in Path(dep.src_dir).parents] | ||
for um in um_deps: | ||
# Add include paths for all non-usermod dependencies | ||
for dep in other_deps: | ||
for dir in dep.get_include_dirs(): | ||
um.env.PrependUnique(CPPPATH=dir) | ||
# Add the wled folder to the include path | ||
um.env.PrependUnique(CPPPATH=env["PROJECT_SRC_DIR"]) | ||
# Make sure we link directly, not through an archive | ||
# Archives drop the .dtor table section we need | ||
build = um._manifest.get("build", {}) | ||
build["libArchive"] = False | ||
um._manifest["build"] = build | ||
return cpl.clone(env)() | ||
|
||
|
||
# Replace the old one with ours | ||
env.AddMethod(cpl_wrapper, "ConfigureProjectLibBuilder") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name:": "AHT10_v2", | ||
"build": { "libArchive": false }, | ||
"dependencies": { | ||
"enjoyneering/AHT10":"~1.1.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name:": "Analog_Clock", | ||
"build": { "libArchive": false } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name:": "Animated_Staircase", | ||
"build": { "libArchive": false } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name:": "BH1750_v2", | ||
"build": { "libArchive": false }, | ||
"dependencies": { | ||
"claws/BH1750":"^1.2.0" | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The downside to this change is that you have no control of what you are building
For testing I was setting my local platform_override.ini to only list the mods I was trying to build.
I guess I can still do that, but just need to name my env somehting like
usermods_local
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not thrilled at magic environment names, but I think it's important to be able to locally replicate what the CI system does without having to run shell commands to update local state after every
git pull
. I'm open to alternative suggestions!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly less need for an "all in one" build if we just let the CI handle a matrix build for usermods, then just define the one we are working on locally in our own platform_override ?
willmmiles#3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I stand by my opinion from above -- I think it's important that what the CI system does should be easily and directly reproducible by developers. I don't think it's appropriate to have to hand hack custom files in your personal workspace to replicate what the CI does; that's just asking to get it wrong.
From a practical perspective, I'd also like it to be simple to validate my local changes before pushing to the CI. If we depend on matrix builds, that becomes almost impossible. Id be stuck waiting on the CI system any time I want to have some confidence I haven't inadvertently broken the build of some random usermod.
Finally, I don't know much about GitHub CI; I'm concerned that adding dozens of extra builds per run would be costly.