我在顶级目录中有一个单独的SConscript文件,并且我有许多子目录,其中包含包含不同键/值对的JSON文件。我的SConscript文件中有一个env.Command(),我希望基于特定键的值来调用它。在Scons中实现这一点的最佳方法是什么?
我是这样想的:
env.Command(
test = Value(params['json_key'])
if test == "True":
target = out.txt,
source = in.txt,
action = 'function $SOURCE $TARGET'
else:
pass
)发布于 2011-09-03 05:35:06
这是Python,你不能把if/else放在其他类似的东西里面。但是,您可以使用字典将参数传递给env.Command。
if Value(params['json_key']) == "True":
kw = {
'target': 'out.txt',
'source': 'in.txt',
'action': 'function $SOURCE $TARGET',
}
else:
kw = {}
env.Command(**kw)https://stackoverflow.com/questions/7289418
复制相似问题