[Scons-users] Cross-OS Cross-Building

Damien damien at khubla.com
Wed Aug 10 23:21:41 EDT 2016


I don't know if this helps, but this is a cut-down version of what we do 
for cross-platform and 64 or 32-bit builds.  We don't use much of the 
default setup for platforms, the .config calls set everything specifically.

This is configure.py :

#This sets up the build environment for the platform
import platform
import os
import subprocess

def config(env, args):
    print ''
    print 'Configuring the build environment...'
    print ''
    env.Decider('MD5-timestamp')

    if env['PLATFORM'] == 'posix':
       if (platform.machine() == 'x86_64'):
          print "Got a 64-bit processor, I can do a 64-bit build in 
theory..."
          if args.get('32bit', 0):
              print '32-bit Linux build'
              env['MEMORYMODEL'] = '32bit'
              import linux6432
              linux6432.config(env, args)
          elif args.get('64bit', 0):
              env['MEMORYMODEL'] = '64bit'
              import linux64
              linux64.config(env, args)
          else:
              print 'Memory model not specified, so I\'m building 64-bit...'
              env['MEMORYMODEL'] = '64bit'
              import linux64
              linux64.config(env, args)
       else:
           print '64-bit Linux Build.'
           env['MEMORYMODEL'] = '32bit'
           import linux32
           linux32.config(env, args)
    elif env['PLATFORM'] == 'win32':
       txt = subprocess.Popen('ver', shell=True, stdout=subprocess.PIPE)
       txt2 = txt.communicate()[0]
       txt2 = txt2.lstrip("('\r\nMicrosoft Windows [Version")
       txt2 = txt2.rstrip("]\r\n)")
       txt3 = txt2[0];
       num = int(txt3)
       env['WINVERSION'] = num
       if (os.environ['PROCESSOR_ARCHITECTURE'] == 'AMD64' or
          (os.environ.has_key('PROCESSOR_ARCHITEW6432') and 
os.environ['PROCESSOR_ARCHITEW6432'] == 'AMD64')):
          print "Got a 64-bit processor, I can do a 64-bit build in 
theory..."
          if args.get('64bit', 0):
             print '64-bit Windows build.'
             import win64
             win64.config(env, args)
          else:
             print 'Memory model not specified, so I\'m building 64-bit.'
             import win64
             win64.config(env, args)
    elif env['PLATFORM'] == 'darwin':
       print 'OS X Darwin is a 64-bit build.'
       env['MEMORYMODEL'] = '64bit'
       import darwin64
       darwin64.config(env, args)
    else:
        print 'ERROR! unrecognized platform.  Twonk.'

    print''
    print '...Build configuration done.  Let\'s start.'
    print ''


This is imported into the SConstruct and used to set everything up:

import configure
baseenv = Environment(ENV = os.environ)
configure.config(baseenv, ARGUMENTS)
Export('baseenv')


Cheers,

Damien



On 8/10/2016 8:57 PM, Bill Deegan wrote:
> Fred,
>
> Does using this (from manpage)
>
> |Platform(string)|
>
>     The |Platform| form returns a callable object that can be used to
>     initialize a construction environment using the platform keyword
>     of the |Environment| function.
>
>     Example:
>
>     env = Environment(platform = Platform('win32'))
>
>     The |env.Platform| form applies the callable object for the
>     specified platform |string| to the environment through which the
>     method was called.
>
>     env.Platform('posix')
>
>     Note that the |win32| platform adds the |SystemDrive| and
>     |SystemRoot| variables from the user's external environment to the
>     construction environment's |$ENV|
>     <http://scons.org/doc/production/HTML/scons-man.html#cv-ENV>
>     dictionary. This is so that any executed commands that use sockets
>     to connect with other systems (such as fetching source files from
>     external CVS repository specifications like
>     |:pserver:anonymous at cvs.sourceforge.net:/cvsroot/scons|) will work
>     on Windows systems.
>
> Not work?
>
> -Bill
>
>
> On Wed, Aug 10, 2016 at 5:35 PM, Fred Wright <fw at fwright.net 
> <mailto:fw at fwright.net>> wrote:
>
>
>     On Tue, 9 Aug 2016, Jason Kenny wrote:
>
>     > I been doing cross platform builds for years. If you choose use
>     Parts with
>     > Scons you will find it very easy to setup.
>
>     Adding another dependency to GPSD is a non-starter, especially if it's
>     purely for cross-building.  Having to accomodate a range of SCons
>     versions
>     is trouble enough.
>
>     > 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.
>
>     Well the SCons documentation *claims* it handles cross-building
>     well, it's
>     just that the claim is overstated. :-)
>
>     > 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.
>
>     The particular issue that prompted the investigation is that when
>     cross-bulding for Linux on OSX, it wants to use a .dylib extension
>     rather
>     than .so on shared libraries.  The extension is being supplied by
>     SCons,
>     not the toolchain.  It's probably not the only such issue.
>
>     > 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.
>
>     It already has the means to set up certain construction variables in a
>     manner appropriate to the platform.  The problem is just that it
>     doesn't
>     make that mechanism available for a specifiable platform, for no
>     terribly
>     good reason.  Duplicating that logic separately would be rather silly.
>
>     If the platform setup sets some global variables in addition to
>     construction varaibles, then one might need to call it again for
>     the host
>     platform after setting up the target environment.  That way the
>     host and
>     target environments can have the approriately different settings,
>     while
>     the global settings will be correct for the host.
>
>     Fred Wright
>     _______________________________________________
>     Scons-users mailing list
>     Scons-users at scons.org <mailto:Scons-users at scons.org>
>     https://pairlist4.pair.net/mailman/listinfo/scons-users
>     <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/20160810/fbeb5c20/attachment-0001.html>


More information about the Scons-users mailing list