Skip to content

Inject a dependency on the usermod list #4622

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions pio-scripts/add_usermod_dep.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Attempt to fix incorrect SCons cache lookups
# The build system doesn't seem to always pick up cases where the dependency list itself has
# changed, and can incorrectly return a cached build result with the wrong set of usermods
# linked in.
# We put the usermod list in a file which can be listed as dep for the final link,
# ensuring that it will always link correctly based on the hashes.

Import('env')
from pathlib import Path

# Write out the usermod list to a text file
lib_path = Path(env.subst("$PROJECT_LIBDEPS_DIR")) / env.subst("$PIOENV")
usermods = env.GetProjectOption("custom_usermods","")
usermod_file = Path(lib_path) / "usermod_list.txt"

with usermod_file.open("a+", encoding="utf-8") as um_file:
um_file.seek(0)
old_ums = um_file.readline()
if old_ums != usermods:
um_file.truncate(0)
um_file.seek(0)
um_file.write(usermods)

# Add a dependency on this file
env.Depends(env.subst("$PROGPATH"), str(usermod_file))
1 change: 1 addition & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ extra_scripts =
post:pio-scripts/strip-floats.py
pre:pio-scripts/user_config_copy.py
pre:pio-scripts/load_usermods.py
post:pio-scripts/add_usermod_dep.py
pre:pio-scripts/build_ui.py
; post:pio-scripts/obj-dump.py ;; convenience script to create a disassembly dump of the firmware (hardcore debugging)

Expand Down