Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create mixed (value set) CPPDEFINES in SCons

Tags:

python

scons

I'd like to set the compiler defines to -DBLUB as well as -DFOO=1.

Currently I only have:

env.Append("CPPDEFINES", ["BLUB", "VALUE2"])

I now would like to include a third define via "FOO" : 1 and thus use CPPDEFINES as a dictionary so I can later on test quite easy

env["CPPDEFINES"].get("FOO") == 1

or so. Everything I attempted leads to syntax errors or strange errors. Could one explain the strange ways to do this in python to me?

like image 570
abergmeier Avatar asked Oct 09 '22 23:10

abergmeier


1 Answers

If you need to specify a value for any single define, CPPDEFINES must be a dictionary.

From the scons User Manual:

If $CPPDEFINES is a dictionary, the values of the $CPPDEFPREFIX and $CPPDEFSUFFIX construction variables will be appended to the beginning and end of each item from the dictionary. The key of each dictionary item is a name being defined to the dictionary item's corresponding value; if the value is None, then the name is defined without an explicit value.

For your example, I suggest:

env.Append(CPPDEFINES = { 'BLUB': None, 'VALUE2': None, 'Foo': 1 })

or

env.Append(CPPDEFINES = { 'BLUB': None, 'VALUE2': None })
...and sometime later...
env.Append(CPPDEFINES = { 'Foo': 1 })
like image 161
Dave Bacher Avatar answered Oct 13 '22 12:10

Dave Bacher