[Scons-users] CPPDEFINES Unexpected Behavior
Strand, Kyle J
kyle.strand at beckman.com
Wed Apr 10 14:51:10 EDT 2013
Some additional information:
The line "print env.Dictionary('CPPDEFINES')" exposes the way the defines are stored internally. I have only ever seen them stored as a list of tuples. It appears that such a list always behaves exactly according to the description on the manpage:
"If any element is a list or tuple, then the first item is the name being defined and the second item is its value."
But this only makes sense if the value is a string; currently, the value "None" is interpreted as the literal string "None"!
In situations where value-less definitions are stored correctly in the CPPDEFINES variable, they are stored as single-element tuples. This makes sense, but it's inconsistent with the behavior described for the CPPDEFINES variable when it's stored as a dictionary.
So, as I see it, there are two possible fixes:
1) When evaluating the CPPDEFINES variable, SCons should interpret ([def],None) the same way it interprets ([def],).
2) Functions such as AppendUnique() that alter the CPPDEFINES variable and accept a dictionary as an argument should interpret [def]:None key-value pairs in such a way as to store them "correctly," that is, as the tuple ([def],) in the CPPDEFINES list.
________________________________
Kyle Strand, Software Intern
Beckman Coulter, Inc., Life Sciences Division
4862 Innovation Drive, Fort Collins, Colorado, 80525
(970) 204-7036
________________________________
From: scons-users-bounces at scons.org [scons-users-bounces at scons.org] on behalf of Strand, Kyle J [kyle.strand at beckman.com]
Sent: Wednesday, April 10, 2013 12:10 PM
To: scons-users at scons.org
Subject: [Scons-users] CPPDEFINES Unexpected Behavior
I've discovered some really surprising and probably incorrect behavior with the environment's CPPDEFINES variable. According to the manpage,
"If $CPPDEFINES is a dictionary, the values of the $CPPDEFPREFIXand$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."
This leads me to expect that if I use env.AppendUnique() with a dictionary argument, if any of the values in that dictionary are None, then the corresponding keys will be defined without an explicit value. However, this is not what happens. The following code:
env = Environment()
newdefs = {'def1':None}
env.AppendUnique(CPPDEFINES=newdefs)
causes 'def1' to be defined as the literal string 'None.'
Is this the desired behavior? If so, why? If not, I'll submit a bug report.
________________________________
Kyle Strand, Software Intern
Beckman Coulter, Inc., Life Sciences Division
4862 Innovation Drive, Fort Collins, Colorado, 80525
(970) 204-7036
Please be advised that this email may contain confidential information. If you are not the intended recipient, please notify us by email by replying to the sender and delete this message. The sender disclaims that the content of this email constitutes an offer to enter into, or the acceptance of, any agreement; provided that the foregoing does not invalidate the binding effect of any digital or other electronic reproduction of a manual signature that is included in any attachment.
Please be advised that this email may contain confidential
information. If you are not the intended recipient, please notify us
by email by replying to the sender and delete this message. The
sender disclaims that the content of this email constitutes an offer
to enter into, or the acceptance of, any agreement; provided that the
foregoing does not invalidate the binding effect of any digital or
other electronic reproduction of a manual signature that is included
in any attachment.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://four.pairlist.net/pipermail/scons-users/attachments/20130410/7fbe017a/attachment.htm>
More information about the Scons-users
mailing list