2011-09-02 218 views
1

我在顶级目录中有一个SConscript文件,而且我有许多包含不同键/值对的JSON文件的子目录。我在我的SConscript文件中有一个env.Command(),我想根据特定键的值调用它。在Scons中做这件事的最好方法是什么?SCONS if/then语句

我的想法是这样的:

env.Command(
    test = Value(params['json_key']) 
    if test == "True": 
     target = out.txt, 
     source = in.txt, 
     action = 'function $SOURCE $TARGET' 
    else: 
     pass 
    ) 

回答

2

这是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)