2012-02-08 7 views
6

Se ho un eseguibile che genera un output di più file alla volta -SCons builder personalizzato - costruire con più file e di output un file

generate_output -o a.out -f input1.txt input2.txt input3.txt 

c'è un modo per scrivere un tale costruttore personalizzato per questo ? Quello che ho in questo momento è -

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

Poi si genera solo i file in una sequenza, che non è quello che volevo veramente -

generate_output -o input1.out -f input1.txt 
generate_output -o input2.out -f input2.txt 
# etc... 

risposta

10

Provare a utilizzare $SOURCES, vedere Variable Substitution:

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

funziona per me in questo semplice esempio:

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

Questo funzionerà finché generate_output non richiede -f per precedere ciascun file di input.