SCons中的if/then语句
我在一个顶层目录下有一个 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
)
1 个回答
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)