scons icon indicating copy to clipboard operation
scons copied to clipboard

Clone() does not honor 'variables' argument

Open pauschar opened this issue 6 years ago • 4 comments

Describe the bug As per discussion with bdbaddog on Discord around 2020-03-12, the following SConstruct does not work as expected:

vars = Variables()
vars.Add(BoolVariable('MYTEST', 'bla',default=False))

env = Environment(variables=vars)
print(env.get('MYTEST'))
env.Replace(MYTEST=True)
print(env.get('MYTEST'))

# passing variables to Clone() does not seem to have an effect
# and there is no indication of failure to update.
env1 = env.Clone(variables=vars)

# after Clone(), the expected value of MYTEST is 'False' because 'vars' has
# been passed into the clone. But we have to enforce that env1 is using the
# values from vars, not from env.
# commenting out the Update call proves this ...
vars.Update(env1)
print(env1.get('MYTEST'))``

Required information

  • Link to SCons Users thread discussing your issue: None, discussed on Discord
  • Version of SCons: 3.1.2
  • Version of Python: 3.6.8
  • Which python distribution if applicable (python.org, cygwin, anaconda, macports, brew,etc): WSL Ubuntu 18.04
  • How you installed SCons: pip
  • What Platform are you on? (Linux/Windows and which version): WSL Ubuntu 18.04
  • How to reproduce your issue? Run the above SConstruct, the expected 3rd line printout is 'True' with vars.Update(env1) disabled - env1 should hold 'MYTEST' as False because that's the default from line 2 of the script.
  • How you invoke scons (The command line you're using "scons --flags some_arguments") scons

pauschar avatar Mar 24 '20 10:03 pauschar

Thanks for filing a complete Issue! Can't make any promises when we'll get to this, but we have sufficient info to properly understand the issue now.

bdbaddog avatar Mar 24 '20 16:03 bdbaddog

Quick look - there's no code for it. Environment recognizes variables separate from the generic kwargs, and folds them in; Clone does not.

mwichmann avatar Apr 07 '20 23:04 mwichmann

Re-reading my initial report and Mats' quick look makes me think that this could be handled in 2 steps:

  • make Clone() report some error/warning that it was unable to parse/evaluate provided named arguments. This behaviour was most disturbing to me when trying to pass variables into a clone - it took me quite a while to figure that variables is ignored silently.
  • make Clone() behave much as Environment() - to me this would be SCons'ic.

pauschar avatar Apr 16 '20 06:04 pauschar

@pauschar - Unfortunately the first option you list is really not viable. As you can specify any variable to be added or overwritten(from the env being cloned) to the cloned env.

bdbaddog avatar Apr 16 '20 14:04 bdbaddog