SCons自定义生成器-生成多个文件并输出一个文件 [英] SCons custom builder - build with multiple files and output one file
本文介绍了SCons自定义生成器-生成多个文件并输出一个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有一个可执行文件,一次可以从多个文件生成输出,-
If I have an executable that generates an output from multiple files at a time -
generate_output -o a.out -f input1.txt input2.txt input3.txt
有没有办法为这个?
我现在所拥有的是-
Is there a way to write such a custom builder for this? What I have at the moment is -
builder = Builder(
action='generate_output -o $TARGET -f $SOURCE',
suffix='.out', src_suffix='.txt')
然后它仅按顺序生成文件,这不是我真正想要的-
Then it only generates files in a sequence, which is not what I really wanted -
generate_output -o input1.out -f input1.txt
generate_output -o input2.out -f input2.txt
# etc...
推荐答案
尝试使用 $ SOURCES
,请参见变量替换:
builder = Builder(
action='generate_output -o $TARGET -f $SOURCES',
suffix='.out', src_suffix='.txt')
在这个简单示例中对我有用:
It works for me in this simple example:
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
到每个输入文件之前,此方法就起作用。
This will work as long as generate_output
doesn't require -f
to precede each input file.
这篇关于SCons自定义生成器-生成多个文件并输出一个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文