[Scons-users] placing object files to one common directory

Endre Bak ebak32 at gmail.com
Tue Apr 28 05:31:44 EDT 2015


Hi,

" There isn't a good reason to copy objects around IMHO." Placing .o files
into the source directory is an ugly thing. And I don't want to copy
objects around, I want the compiler to place the .o files directly into the
object directory.

The VariantDir() function doesn't seem to be working at all:

GTEST_DIR = '../GTestGMock/gtest-1.7.0'

for objDir, srcDir in [('gtest', GTEST_DIR + '/src'), ('mock', 'mock'),
('', 'src')]:
    print 'objs/{} <- {}'.format(objDir, srcDir)
    VariantDir('objs/' + objDir, srcDir, duplicate=0)

env = Environment()
env.Append(CXXFLAGS = '-g -Wall -Wextra -pthread -isystem
{}/include'.format(GTEST_DIR))

env.StaticLibrary('output/gtest', [GTEST_DIR + '/src/gtest-all.cc'],
CPPPATH=[GTEST_DIR, GTEST_DIR + '/include'])

Output:

$ scons
scons: Reading SConscript files ...
objs/gtest <- ../GTestGMock/gtest-1.7.0/src
objs/mock <- mock
objs/ <- src
scons: done reading SConscript files.
scons: Building targets ...
g++ -o /home/endre/Prg/Repos/GTestGMock/gtest-1.7.0/src/gtest-all.o -c -g
-Wall -Wextra -pthread -isystem ../GTestGMock/gtest-1.7.0/include
-I/home/endre/Prg/Repos/GTestGMock/gtest-1.7.0
-I/home/endre/Prg/Repos/GTestGMock/gtest-1.7.0/include
/home/endre/Prg/Repos/GTestGMock/gtest-1.7.0/src/gtest-all.cc
ar rc output/libgtest.a
/home/endre/Prg/Repos/GTestGMock/gtest-1.7.0/src/gtest-all.o
ranlib output/libgtest.a
scons: done building targets.

It is requested that the objects compiled from
*../GTestGMock/gtest-1.7.0/src* should be placed into *objs/gtest* but it
is placed into the source directory instead.

Regards,
Endre

On Tue, Apr 28, 2015 at 1:01 AM, William Blevins <wblevins001 at gmail.com>
wrote:

> Endre,
>
> Are you trying to build a GTest executable suite?  I recommend simply
> building the fixtures as libraries and linking them into your couples line
> of GTest executable.  There isn't a good reason to copy objects around IMHO.
>
> V/R,
> William
>
> On Mon, Apr 27, 2015 at 3:55 PM, Bill Deegan <bill at baddogconsulting.com>
> wrote:
>
>> Endre,
>>
>> Not via VariantDir for sure.
>> You could make a pseudo builder (see user guide) which you call which
>> prepends the target with your "object dir"
>>
>> -Bill
>>
>> On Mon, Apr 27, 2015 at 2:48 PM, Endre Bak <ebak32 at gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I would like to place all object files from multiple source directories
>>> into one common object directory. Is that possible?
>>> I tried it with the following code:
>>>
>>> for src in [GTEST_DIR, 'src', 'mock']:
>>>     VariantDir('objs', src, duplicate=0)
>>>
>>> But it is rejected:
>>> scons: *** 'objs' already has a source directory:
>>> '/home/endre/Prg/Repos/GTestGMock/gtest-1.7.0'.
>>>
>>> Thanks,
>>> Endre
>>>
>>> _______________________________________________
>>> Scons-users mailing list
>>> Scons-users at scons.org
>>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>>
>>>
>>
>> _______________________________________________
>> Scons-users mailing list
>> Scons-users at scons.org
>> https://pairlist4.pair.net/mailman/listinfo/scons-users
>>
>>
>
> _______________________________________________
> Scons-users mailing list
> Scons-users at scons.org
> https://pairlist4.pair.net/mailman/listinfo/scons-users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20150428/392d14e3/attachment.html>


More information about the Scons-users mailing list