如果我有一个可执行文件一次从多个文件生成输出 -
generate_output -o a.out -f input1.txt input2.txt input3.txt
有没有办法为此编写这样的自定义构建器?
我目前所拥有的是——
builder = Builder(
action='generate_output -o $TARGET -f $SOURCE',
suffix='.out', src_suffix='.txt')
然后它只按顺序生成文件,这不是我真正想要的 -
generate_output -o input1.out -f input1.txt
generate_output -o input2.out -f input2.txt
# etc...
最佳答案
尝试使用 $SOURCES
,见 Variable Substitution :
builder = Builder(
action='generate_output -o $TARGET -f $SOURCES',
suffix='.out', src_suffix='.txt')
在这个简单的例子中它对我有用:
env = Environment()
builder = Builder(action='cat $SOURCES > $TARGET',
suffix='.out', src_suffix='.txt')
env = Environment(BUILDERS = {'MyBld' : builder})
env.MyBld('all', ['a.txt', 'b.txt', 'c.txt'])
只要
generate_output
就可以使用不需要 -f
在每个输入文件之前。
关于builder - SCons 自定义构建器 - 使用多个文件构建并输出一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9203367/