[Scons-users] Cross-OS Cross-Building

Jason Kenny dragon512 at live.com
Tue Aug 9 19:31:37 EDT 2016


I been doing cross platform builds for years. If you choose use Parts with
Scons you will find it very easy to setup.

Overall SCons only has a notion of the Host build platform, not the Target.
This means that if you use raw scons you will need to create an environment
by hand with the correct tools and flags set it in.

I am not sure why you feel you need to redefine anything in SCons. Given you
are build cross 32-bit/64-bit or to a different OS such as Android, etc...
The given tools have to work on the host you are building on.

SCons does not provide a Target set of variables, it current assume you will
provide this and you will map them to any tool that support cross builds
correctly.

Parts might be useful here. A simple cross build of a hello world program
would look like:

SConstruct----

from parts import *
Part('hello.parts')

----------------------
hello.part------
Import('*')
ret=env.Program("hello","hello.c")
env.InstallTarget(ret)

----------------------

to build native:
Scons all

to build cross 32-bit ( assume native 64-bit):
Scons all --target=x86

to build cross 64-bit android:
Scons all --target=android-x86_64


If you want to do a more complex one pass build for different platforms,
just change the SConstruct as such:
-------------
from parts import *
Part('hello.parts', TARGET_PLATFORM="x86")
Part('hello.parts', TARGET_PLATFORM="x86_64")
Part('hello.parts', TARGET_PLATFORM="android-x86"
Part('hello.parts', TARGET_PLATFORM="android-x86_64")

--------------------

I hope this helps. 
Jason


-----Original Message-----
From: Scons-users [mailto:scons-users-bounces at scons.org] On Behalf Of Fred
Wright
Sent: Tuesday, August 9, 2016 5:33 PM
To: SCons users mailing list <scons-users at scons.org>
Subject: Re: [Scons-users] Cross-OS Cross-Building


On Tue, 9 Aug 2016, William Blevins wrote:

> Fred,
>
> Can you not redefine os.name in site_scons?
>
> http://stackoverflow.com/questions/3692159/how-do-i-redefine-functions
> -in-python

That's not the appropriate place, since one doesn't want to make *all*
builds look like a different platform.  The platform needs to be set up as
part of the target specification when cross-building.

Fred Wright

> On Tue, Aug 9, 2016 at 8:50 PM, Fred Wright <fw at fwright.net> wrote:
>
> >
> > I've been looking into some issues with cross-building, and have 
> > come across a problem:
> >
> > Setting up the proper target environment has to include setting up 
> > the proper platform-related settings.  The code that does that is 
> > contained in platform-related SCons functions that don't directly 
> > correspond to the normal user-visible platform names.  The code to 
> > provide that mapping seems to exist solely in the platform_default() 
> > function, which takes no arguments and gets the values directly from the
host Python.
> >
> > AFAICT, the only way to make this work for a specified target OS is 
> > to do one of two things:
> >
> > 1) Duplicate the logic in platform_default(), thereby relying on 
> > knowledge of SCons internals.
> >
> > 2) Monkey-patch os.name and sys.platform around a call to 
> > platform_default(), so that it can be fed the proper values.
> >
> > Both of these are rather ugly.  Am I missing something?  Is it 
> > really true that nobody considered the possibility of cross-building 
> > for a different OS?
> >
> > Fred Wright
> > _______________________________________________
> > 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