[Scons-users] scons not respecting variant_dir with object files
Gary Granger
granger at ucar.edu
Sun Jun 5 17:58:12 EDT 2016
I don't use variant_dir much myself, so I'm learning as I go. From the
man page I discovered that this setup seems to produce the effect you want:
#### SConstruct
VariantDir('build/out', 'dir1', duplicate=0)
SConscript('build/out/proj/SConscript')
####
#### dir1/proj/SConscript
StaticLibrary('../mylib', '../mysrc.cpp')
####
$ scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
g++ -o build/out/mysrc.o -c dir1/mysrc.cpp
ar rc build/out/libmylib.a build/out/mysrc.o
ranlib build/out/libmylib.a
scons: done building targets.
It seems like the challenge with absolute paths will be that each
variant_dir still needs to be associated with a src_dir. Whether your
source files are named by relative or absolute path, they must be
contained in a directory which has been identified as the src_dir for a
variant_dir, such as with VariantDir().
If you don't really want to create a mirror of your source tree
underneath the variant_dir, you just want to put output there
explicitly, then maybe there's an easy way to tweak the builders to put
the objects into a directory other than the source directory. The below
works, but I'm sure it would be important to parameterize the build dir
somehow, and it's not as flexible as variant dirs.
#### SConstruct
SConscript('dir1/proj/SConscript')
#### dir1/proj/SConscript
StaticLibrary('#build/mylib', StaticObject('#build/mysrc.o',
'../mysrc.cpp'))
Good luck,
gary
On 06/05/2016 02:44 PM, Bob Loblaw wrote:
>
> If I specify a relative path, that would fix it in this example. I
> believe I would need to change my SConstruct file to say:
>
>
> ####
>
> SConscript('dir1/proj/SConscript',
> src_dir='dir1', variant_dir='build/out', duplicate=0)
>
> ####
>
>
> Which adds the src_dir.
>
>
> What I provided in the original example was a simplified version of
> how I'm using scons. I will actually need to use full absolute paths
> to the source files.
>
>
> Is there a way this works with absolute paths?
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20160605/d1d75a93/attachment-0001.html>
More information about the Scons-users
mailing list