Following code prints as expected:
\nmy_option: \n default: some_string\n actual: test\n\nmy_option2: \n default: $my_option/${2+3}\n actual: test/5\n
But inside docs I saw following https://scons.org/doc/production/HTML/scons-user.html#b-Substfile that Substfile
can be nondeterministic in some cases. So are there similar limitations for this feature and is it published? I couldn't find it in the docs so... But looks like very intended beahavior so maybe it is published?
Sorry, never commented on this... I think the Substfile
wording in the User Guide you point to is a remnant of when Python dicts were not order-preserving.
In the case of Variables, ones that come from a file are processed by doing an exec
on the script as if it were Python code, so that behavior should be well-known; nothing particular is done up front for values that come from the command line. Then, once a declared variable has a value, if it has a converter it is substituted before the converter is called; if it has a validator it may be substituted, depending on the type of the value - both also controlled by a flag which can be set to not do substitution (that's because of a specific request to cover a case where a value needed to hold something starting with a $
which was intended for the external tool, not as an SCons variable reference).
So there seem to be plenty of ways for substitution not to happen on the value/default of a variable...
","upvoteCount":1,"url":"https://github.com/SCons/scons/discussions/4651#discussioncomment-11486778"}}}-
Hello I've just thought about expansion and want to know if following code is reliable and deterministic. import SCons
from SCons.Variables import *
env = Environment()
options = Variables(["custom.py"], ARGUMENTS)
options.Add("my_option", "", "some_string")
options.Add("my_option2", "", "$my_option/${2+3}")
options.Update(env)
print(options.GenerateHelpText(env)) Following code prints as expected:
But inside docs I saw following https://scons.org/doc/production/HTML/scons-user.html#b-Substfile that |
Beta Was this translation helpful? Give feedback.
-
Sorry, never commented on this... I think the In the case of Variables, ones that come from a file are processed by doing an So there seem to be plenty of ways for substitution not to happen on the value/default of a variable... |
Beta Was this translation helpful? Give feedback.
Sorry, never commented on this... I think the
Substfile
wording in the User Guide you point to is a remnant of when Python dicts were not order-preserving.In the case of Variables, ones that come from a file are processed by doing an
exec
on the script as if it were Python code, so that behavior should be well-known; nothing particular is done up front for values that come from the command line. Then, once a declared variable has a value, if it has a converter it is substituted before the converter is called; if it has a validator it may be substituted, depending on the type of the value - both also controlled by a flag which can be set to not do substitution (that's because of a specifi…