[Scons-users] HowTo: toggle between toolchains during scons build

Kenny, Jason L jason.l.kenny at intel.com
Mon Sep 2 14:22:18 EDT 2013


Hi,

I would add that the easiest way to do this is to call a sconscript twice, one with an environment with for arm and one for native. It is also a good idea to pass two different variant directories as well, to allow each case to build in a different directory.

The last issue you may come across is that on POSIX based system it is common to have all the tools under a common directory with different names. This means you may need to change the value for some of the "tools" variable in the environment to allow the build to work. For example you may need to set CC to "arm-gcc" instead of "gcc".

You may also need to add different flags for the target platform you are building for. Scons however does not support an official notion of host vs target platform, yet. The PLATFORM is really the host building system.

This is generally easy to set up. This is basically what my add on Parts does under the covers.

Enjoy
Jason


From: scons-users-bounces at scons.org [mailto:scons-users-bounces at scons.org] On Behalf Of Dirk Bächle
Sent: Sunday, September 01, 2013 3:43 AM
To: scons-users at scons.org
Subject: Re: [Scons-users] HowTo: toggle between toolchains during scons build

Hi Phil,

On 01.09.2013 02:35, PhilAPol wrote:
Hi All,

The current scons build for mongodb assumes that it will be built on the target machine. This is not possible since there is not enough memory on the target. Consequently, I would like to cross-build mongodb under Ubuntu targeting the ARM processor.

I will need to toggle between using the native tool-chain (under Ubuntu) and the ARM tool-chain in the middle of the build. I have set up my Ubuntu environment under /usr/bin to symbolically link to either the ARM tool-chain or the Ubuntu tool-chain by invoking the use-arm-tools.sh or use-native-tools.sh scripts. Before building I invoke use-arm-tools.sh to start in ARM mode. I have tried a several different approaches (see below) without success. I am looking for a solution.

if you want to get files of your build created in a different way than others, your best approach is to put them in different environments. That's what they're actually there for ;) ...

Trying to set and restore things like the "$CC" variable for the same construction environment won't help, because the commands and variables aren't evaluated and fully expanded until the build phase begins, so the last variable assignment wins.

Instead, you should Clone() your actual environment and modify it as you like:
############################################################################
# We need to change the tool environment from ARM to native Ubuntu mode here.
# Thus jskwgen.c would be built for the Ubuntu environment then executed to
# produce the jskautokw.h and jsautocfg.h files for subsequent use in the
# overall ARM build.
############################################################################
envNative = env.Clone()
envNative['CC'] = ...


envNative.Program('jskwgen', 'jskwgen.c')
envNativ.Program('jscpucfg', 'jscpucfg.c')
envNative.Command('jsautokw.h', ['${PROGREFIX}jskwgen${PROGSUFFIX}'],
'$SOURCE >$TARGET')
envNative.Command('jsautocfg.h', ['${PROGREFIX}jscpucfg${PROGSUFFIX}'],
'$SOURCE >$TARGET')

Like this, the original environment and its clone are protected from each other, and you don't have to restore any stuff for "env" in the end.

Hope this helps you further.

Best regards,

Dirk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://four.pairlist.net/pipermail/scons-users/attachments/20130902/c593e926/attachment.html


More information about the Scons-users mailing list