I would like SCons to generate some source files for me in my src/ directory, and then build them as any other source file in my build directory build/variantX.
This is my SCons file:
import SCons
def my_builder(env, target, source):
# do stuff
pass
env = Environment()
env.VariantDir('build/variant1/', 'src', duplicate=0)
env.Command('src/foobar.cc', 'src/foobar.input', action=my_builder)
env.Program('bin/test', [
'build/variant1/foobar.cc',
'build/variant1/test.cc',
])
This errors with the following message:
Source
src/foobar.ccnot found, needed by targetbuild/variant1/foobar.o
which I don't think is correct, considering that I am indeed providing a command to build src/foobar.cc.
Now, I tried a few workarounds:
if I replace
build/variant1/foobar.ccin Program withsrc/foobar.cc, it does work, but obviouslyfoobar.ogets created insrc/rather thanbuild/variant1if I replace
src/foobar.ccin Command withbuild/variant1/foobar.cc, it does work, but I would like the code to be generated insrc/; (also because things like relative paths in include directories won't work unlessduplicate=1)if
duplicate=1, I get a similar error message, but this time mentioning the variant directory:Source
build/variant1/foobar.ccnot found, needed by targetbuild/variant1/foobar.o
Is there a way around this? Is it a limitation/bug in SCons, or is there a fundamental misunderstanding on my side?