scons icon indicating copy to clipboard operation
scons copied to clipboard

Fix coercion of Strings/Lists/Dict in Append

Open bdbaddog opened this issue 7 years ago • 2 comments

This issue was originally created at: 2014-07-13 05:32:13. This issue was reported by: dirkbaechle. dirkbaechle said at 2014-07-13 05:32:13

As reported on the mailing list:

http://scons.tigris.org/ds/viewMessage.do?dsForumId=1272&viewType=browseAll&dsMessageId=2876001

the env.Append() method can yield surprising results, when mixing data types like Strings and Lists for the arguments.

This issue should add support for the most basic use cases:

  1. Adding string values:
env.Append(CCFLAGS = '-O1')
env.Append(CCFLAGS = '-whatever')

expected is CCFLAGS = ['-O1','-whatever']

  1. Overriding the pre-set type of CCFLAGS:
env = Environment(CCFLAGS='breakit')
env.Append(CCFLAGS = ['-g3'])
env.Append(CCFLAGS = 'test')
env = Environment(CCFLAGS=['breakit'])
env.Append(CCFLAGS = ['-g3'])
env.Append(CCFLAGS = 'test')

, and also includes proper documentation about how coercions are handled in general (coerce upward from String to List|Dict, no mix of List+Dict supported).

dirkbaechle said at 2014-07-13 05:32:44

added dependency

dirkbaechle said at 2014-07-13 07:33:46

*** Issue #2599 has been marked as a duplicate of this issue. ***

dirkbaechle said at 2014-07-13 07:35:24

added dependency

dirkbaechle said this issue depends on #2900 at 2014-07-13 05:32:44.

dirkbaechle said this issue depends on #2926 at 2014-07-13 07:35:24.

dirkbaechle said this issue blocks #2961 at 2014-07-13 05:33:10.

dirkbaechle said this issue is duplicated by #2599 at 2014-07-13 07:33:46.

bdbaddog avatar Jan 02 '18 15:01 bdbaddog

The unit test for Append (and Prepend) enshrine the expected behavior so it seems it would be hard to change. I think there are a couple of surprises - in particular some of the construction variables are initialized to a type (CLVar) which isn't exposed in the documentation (I think there's other material on that topic), so for the first example, if you do this:

env.Append(SOMEFLAGS="-O1")
env.Append(SOMEFLAGS="-whatever")

you get a string: -O1-whatever, but for the example itself you get a SCons.Util.CLVar with value -O1 -whatever - note that in the former case you needed to add spaces yourself, but in the latter case it's handled for you, because CCFLAGS is pre-initialized.

I have some manpage wording proposals to improve the description a bit, but don't want to get super-detailed listing all the combinations.

mwichmann avatar Jan 03 '21 17:01 mwichmann

Assigning to myself not to promise to implement, but so I can keep track of it.

mwichmann avatar Mar 17 '21 18:03 mwichmann