SCons custom builder - build with multiple files and output a single file

If I have an executable that generates output from several 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 constructor 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 the files in sequence, which I did not want -

 generate_output -o input1.out -f input1.txt generate_output -o input2.out -f input2.txt # etc... 
+6
source share
1 answer

Try using $SOURCES , see Changing Variables :

 builder = Builder( action='generate_output -o $TARGET -f $SOURCES', suffix='.out', src_suffix='.txt') 

This 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']) 

This will work until generate_output requires -f precede each input file.

+10
source

Source: https://habr.com/ru/post/907994/


All Articles