[Scons-users] Scons and external file generator
Непомнящий Евгений Игоревич
johnny at topazelectro.ru
Mon Nov 17 05:20:40 EST 2014
Hello!
I have external generator gen.exe, which receive input file and generate some
.h and .cpp files from it (names and quantity depends on input file)
Suppose, I have gen.in, and generator create gen/a.h and gen/a.cpp.
Also I have b.cpp, which include gen/a.h
How to write sconstruct file to call gen.exe, enumerate cpp files in
directory gen and build program from gen/a.cpp and b.cpp?
I write such file, but it call gen.exe during "Reading SConscript
files" phase. Maybe exist some more correct decision?
#-----------------
def callGen(env, target, source)
gen = env.Command(target, source, 'gen.exe $TARGET $SOURCE')
env.BuildNow(gen) # my own helper method to build arg right now
res = []
for file in os.listdir(target.abspath): # enumerate cpp files in gen folder
if file.endswith(".cpp"):
res.append(env.Object(target.File(file).path))
return res
gen = callGen(env, Dir('gen'), 'gen.in')
env.Program('prog', gen + ['b.cpp'])
#-----------------
Thank you
More information about the Scons-users
mailing list