[Scons-users] env.MergeFlags does not accept dict CPPDEFINES

Dirk Baechle tshortik at gmx.de
Thu Jul 13 08:32:51 EDT 2017


Hi Olivier, 

thanks a lot for reporting this. However, this looks like a known problem to me. Please check the issues 2961, 2402, 2962 and 2599...as well as the referenced mail thread. Is this a superset of your problems? 

Best regards, 

Dirk


Am 13. Juli 2017 11:23:54 MESZ schrieb Olivier Renaud <orenaud at coventor.com>:
>Hi,
>
>I would like to present to you an issue I have, and maybe submit it to 
>the bugtracker if appropriate.
>
>I am trying to use the MergeFlags method of Environment. The docstring 
>of this method says:
>
>         Merge the dict in args into the construction variables of this
>         env, or the passed-in dict.  If args is not a dict, it is
>         converted into a dict using ParseFlags.  If unique is not set,
>         the flags are appended rather than merged.
>
>It does not give details about what kind of flags are supported,
>though. 
>As a user, I would expect CPPDEFINES to be supported as a flag that can
>
>be merged into the env.
>
>The user manual for CPPDEFINES 
>(http://scons.org/doc/production/HTML/scons-user/apa.html#cv-CPPDEFINES)
>
>says that it can be:
>- a string (for a single define)
>- a list of strings
>- a list of tuples (each containing 2 strings)
>- a list of lists (each containing 2 strings)
>- a dictionary
>
>The problem is that the implementation of MergeFlags seems to support 
>the merging of lists of strings only, and can behave poorly or raise an
>
>exception when using other variants.
>
>Some examples:
>___________________
>
>     # Example 1: list of tuples + list of tuples => OK
>     env_cppdefines = [('MY_DEF', 'hello')]
>     flags_cppdefines = [('OTHER_DEF', 'goodbye')]
>
>     env = Environment(CPPDEFINES = env_cppdefines)
>     env.MergeFlags({'CPPDEFINES': flags_cppdefines})
>
>     print env.Dump('CPPDEFINES')
>     print env.subst('$_CPPDEFFLAGS')
>=>
>     [('MY_DEF', 'hello'), ('OTHER_DEF', 'goodbye')]
>     /DMY_DEF=hello /DOTHER_DEF=goodbye
>___________________
>
>     # Example 2: list + list => OK
>     env_cppdefines = ['MY_DEF']
>     flags_cppdefines = ['OTHER_DEF']
>=>
>     ['MY_DEF', 'OTHER_DEF']
>     /DMY_DEF /DOTHER_DEF
>___________________
>
>     # Example 3: dict + dict => Exception
>     env_cppdefines = {'MY_DEF': 'hello'}
>     flags_cppdefines = {'OTHER_DEF': 'goodbye'}
>=>
>     AttributeError: 'dict' object has no attribute 'insert':
>       File "C:\Users\me\tmp\bug_scons\SConstruct", line 5:
>         env.MergeFlags({'CPPDEFINES': flags_cppdefines})
>       File 
>"c:\python27\lib\site-packages\scons-2.5.1\SCons\Environment.py", line
>841:
>         value.insert(0, orig)
>___________________
>
>     # Example 4: list + identical list => OK
>     env_cppdefines = ['MY_DEF']
>     flags_cppdefines = ['MY_DEF']
>=>
>     ['MY_DEF']
>     /DMY_DEF
>___________________
>
>     # Example 5: dict + identical list => duplication
>     env_cppdefines = {'MY_DEF': None}
>     flags_cppdefines = ['MY_DEF']
>=>
>     [{ 'MY_DEF': None}, 'MY_DEF']
>     /DMY_DEF /DMY_DEF
>
>Is it correct for me to expect MergeFlags to work with CPPDEFINES, and 
>in particular to work with the dictionary versions of it?
>
>Best regards,
>Olivier Renaud
>_______________________________________________
>Scons-users mailing list
>Scons-users at scons.org
>https://pairlist4.pair.net/mailman/listinfo/scons-users

-- 
Sent from my Android with K-9 Mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170713/cea67575/attachment.html>


More information about the Scons-users mailing list