-
-
Notifications
You must be signed in to change notification settings - Fork 21.8k
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
SCons: Preserve Environment
values when updating Variables
#91792
SCons: Preserve Environment
values when updating Variables
#91792
Conversation
8212fc1
to
ad8ae4a
Compare
Seems to ignore some options, it makes it ignore the sanitizer args somehow |
This comment was marked as outdated.
This comment was marked as outdated.
Tried a few different approaches but couldn't make it not ignore command line options, it seems unfortunately that this option doesn't allow updating from command line for some arguments, unsure how this could be fixed |
It sounds like it's meant to update the command line arguments by default, but either that's excluded when passing |
Tested and this seems to work: env_copy = env.Clone()
opts.Update(env_copy)
opts.Update(env, env_copy) Not sure how to detect the broken stuff without the handling of Edit: Doesn't seem to correctly catch if Edit 2: env_copy = env.Clone()
opts.Update(env_copy)
env_copy["platform"] = env["platform"]
opts.Update(env, env_copy) Seems to solve that part, but feels like we're circling around to hackiness again, but unsure exactly what's missing |
How about something like this? Seems to work in a few tests, though I need to check with the follow-up PRs based on this one. diff --git a/SConstruct b/SConstruct
index 5f1c50876e..8ce504ae2b 100644
--- a/SConstruct
+++ b/SConstruct
@@ -362,7 +362,7 @@ if env["platform"] in platform_opts:
opts.Add(opt)
# Update the environment to take platform-specific options into account.
-opts.Update(env, env)
+opts.Update(env, {**ARGUMENTS, **env})
# Detect modules.
modules_detected = OrderedDict()
@@ -422,7 +422,7 @@ for name, path in modules_detected.items():
env.modules_detected = modules_detected
# Update the environment again after all the module options are added.
-opts.Update(env, env)
+opts.Update(env, {**ARGUMENTS, **env})
Help(opts.GenerateHelpText(env))
# add default include paths |
That does seem to work, it handles Edit: It seems to work and it now handles #91791 correctly |
Finally reading the docs for `SCons.Variables.Update` let me find this optional parameter, which solves the hacks and pain we've dealt with for years: > args (optional) – a dictionary of keys and values to update in env. > If omitted, uses the variables from the commandline. By passing the environment itself, we preserve the values we've overridden in `SConstruct` or `detect.py`.
ad8ae4a
to
d4d0e34
Compare
That does the trick! |
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.
Works correctly in my testing
Finally reading the docs for
SCons.Variables.Update
let me find this optional parameter, which solves the hacks and pain we've dealt with for years:By passing the environment itself, we preserve the values we've overridden in
SConstruct
ordetect.py
.Might fix a number of reported issues.
CC @Repiteo