Skip to content

Commit e2f80cb

Browse files
committed
Inject a dependency on the usermod list
Write the current usermod list to a file, and add it as a dependency to the linked output file. This should hopefully overcome potential poisoning of SCons' build cache with incorrect matches. Meant to fix wled#4597
1 parent e76e9a3 commit e2f80cb

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

pio-scripts/add_usermod_dep.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Attempt to fix incorrect SCons cache lookups
2+
# The build system doesn't seem to always pick up cases where the dependency list itself has
3+
# changed, and can incorrectly return a cached build result with the wrong set of usermods
4+
# linked in.
5+
# We put the usermod list in a file which can be listed as dep for the final link,
6+
# ensuring that it will always link correctly based on the hashes.
7+
8+
Import('env')
9+
from pathlib import Path
10+
11+
# Write out the usermod list to a text file
12+
lib_path = Path(env.subst("$PROJECT_LIBDEPS_DIR")) / env.subst("$PIOENV")
13+
usermods = env.GetProjectOption("custom_usermods","")
14+
usermod_file = Path(lib_path) / "usermod_list.txt"
15+
16+
with usermod_file.open("a+", encoding="utf-8") as um_file:
17+
um_file.seek(0)
18+
old_ums = um_file.readline()
19+
if old_ums != usermods:
20+
um_file.truncate(0)
21+
um_file.seek(0)
22+
um_file.write(usermods)
23+
24+
# Add a dependency on this file
25+
env.Depends(env.subst("$PROGPATH"), str(usermod_file))

platformio.ini

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ extra_scripts =
115115
post:pio-scripts/strip-floats.py
116116
pre:pio-scripts/user_config_copy.py
117117
pre:pio-scripts/load_usermods.py
118+
post:pio-scripts/add_usermod_dep.py
118119
pre:pio-scripts/build_ui.py
119120
; post:pio-scripts/obj-dump.py ;; convenience script to create a disassembly dump of the firmware (hardcore debugging)
120121

0 commit comments

Comments
 (0)