python – 在SCons中创建混合(值集)CPPDEFINES

前端之家收集整理的这篇文章主要介绍了python – 在SCons中创建混合(值集)CPPDEFINES前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我想将编译器定义设置为-DBLUB以及-DFOO = 1.

目前我只有:

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

我现在想通过“FOO”包含第三个定义:1然后使用CPPDEFINES作为字典,以便稍后我可以很容易地测试

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

或者.我尝试的一切都会导致语法错误或奇怪的错误.
能解释一下奇怪的方法在python中对我这么做吗?

最佳答案
如果需要为任何单个定义指定值,则CPPDEFINES必须是字典.

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.

对于你的例子,我建议:

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

要么

env.Append(CPPDEFINES = { 'BLUB': None,'VALUE2': None })
...and sometime later...
env.Append(CPPDEFINES = { 'Foo': 1 })
@H_502_51@ 原文链接:https://www.f2er.com/python/439190.html

猜你在找的Python相关文章