[Scons-users] Building object files in multiple environments

Dan Čermák dan.cermak at cgc-instruments.com
Wed Nov 15 10:34:33 EST 2017


Thanks for the tip, I'll give that a try.

Bill Deegan <bill at baddogconsulting.com> writes:

> I'd suggest you us VariantDir per device.
> That's likely the simplest solution.
> You won't have to change much.
>
>
> On Wed, Nov 8, 2017 at 1:48 AM, Dan Čermák <dan.cermak at cgc-instruments.com>
> wrote:
>
>> Hi Folks,
>>
>> I am currently using SCons for a big mono-repo C++ Firmware, where I
>> have lots of common source files and then a directory where the actual
>> firmware for each device is (this is just a .cpp file with device
>> specific configurations and the appropriate high-level logic).
>>
>> For illustration purposes, the directory structure looks something like
>> this:
>> .
>> ├── devices
>> │   ├── Device_A
>> │   │   ├── main.cpp
>> │   │   ├── SConscript
>> │   │   ├── uart.cpp
>> │   │   └── uart.hpp
>> │   ├── Device_B
>> │   │   ├── main.cpp
>> │   │   └── SConscript
>> │   └── SConscript
>> ├── spi
>> │   └── config.cpp
>> ├── uart
>> │   └── uart.cpp
>> ├── util
>> │   └── endian.c
>> └── SConstruct
>>
>> The idea behind this is that everything outside of 'devices' is
>> considered as common files and build into object files. Every
>> subdirectory of devices should have a SConscript that creates a single
>> binary file (this is the firmware for the specific device) that is
>> linked with the common object files.
>>
>> I have achieved this by creating object files for every cpp file not in
>> devices/ and passing them to the SConscript in devices/. However, there
>> is a catch: I would like to build everything under devices with an
>> additional include path (the top level directory of the project) which
>> should not be propagated to the common object files. I therefore tried
>> creating a clone of the environment for each device in
>> devices/SConscript and then doing the following in
>> devices/Device_A/SConscript:
>>
>> Import('env_clone', 'obj')
>>
>> local_obj = env_clone.Object(Glob('*.cpp'))
>> prog = env_clone.Program('Device_A_bin', local_obj + obj)
>>
>> Return('prog')
>>
>> where env_clone is the cloned environment with the additional include
>> path and obj the list of object files that are common to all
>> devices (which have been created in the environment env from which
>> env_clone was cloned). This however causes SCons to complain, that there
>> are object files in multiple environments with the same build command.
>>
>>
>> My guess is, that my solution of cloning environments is not the correct
>> way. Does someone have an idea how to achieve this with SCons?
>>
>>
>> Thanks in advance,
>>
>> Dan
>> _______________________________________________
>> 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


More information about the Scons-users mailing list