You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Append/Prepend special CPPDEFINES handling problems #3876
Multiple past issues (see for example #2300) has caused env.Append and env.AppendUnique to grow special-case code for handling CPPDEFINES. One simple example of the special-casing is that normally Appending a string value to a string-valued consvar causes the strings to be concatenated, but for CPPDEFINES, they must remain two separate strings, so the variable is converted to a list and the new string added to the list.
This is a collective issue to document several problems.
the special-casing was only added for Append and AppendUnique, but not for the parallel Prepend and PrependUnique, meaning one set can have differing result types from the other.
there are no unit tests for the special CPPDEFINES handling. They are tested in e2e tests so this may not be a huge problem, but it seems an inconsistency, at least. And the e2e tests only test Append functions.
the special-casing in AppendUnique does not handle in the same way the case where both existing and added are list types. There's at least one case where this leads to different results, as in the example snippets below:
This can lead to compile issues. The following SConscript generates incorrect CPPDEFINES due to the AppendUnique "tuple-ification" issue mentioned above.
Guess I need to get back to this. Somehow there seems to be excess complexity, and we're currently carrying the four independent implementations of adding to a construction var, which is just poor engineering. I wonder if it would make sense, since they do type conversion anyway, to uses a deque so prepending doesn't have to play games "for performance reasons" since inserting at the front of a plain list is rather expensive.
Activity
mwichmann commentedon Mar 17, 2021
Assigning to myself to keep track of this one.
greenbender commentedon Sep 28, 2021
This can lead to compile issues. The following
SConscriptgenerates incorrectCPPDEFINESdue to theAppendUnique"tuple-ification" issue mentioned above.Results in:
mwichmann commentedon Sep 28, 2021
Guess I need to get back to this. Somehow there seems to be excess complexity, and we're currently carrying the four independent implementations of adding to a construction var, which is just poor engineering. I wonder if it would make sense, since they do type conversion anyway, to uses a deque so prepending doesn't have to play games "for performance reasons" since inserting at the front of a plain list is rather expensive.
mwichmann commentedon Nov 7, 2022
For the WIP branch I have, the example added here by @greenbender now results in this output:
which looks much better.
mwichmann commentedon Nov 7, 2022
And, for completeness, the example from the first checklist item example:
so... now equal, rather than different.
mwichmann commentedon Nov 14, 2022
The fourth checklist item from the original issue has been moved to separate issue #4262 as it was not specific to
CPPDEFINES.Split out CPPDEFINES handling in Append methods
Split out CPPDEFINES handling in Append methods
Split out CPPDEFINES handling in Append methods
Prefer `V.copy` over `V[:]` for creating shallow copies of sequences