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

Dirk Bächle tshortik at gmx.de
Sun Sep 1 04:43:24 EDT 2013


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/20130901/35f1cef5/attachment.html


More information about the Scons-users mailing list