2008-02-27 17:36:28 +09:00
|
|
|
#######################################################################
|
|
|
|
# Common SCons code
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os.path
|
2010-05-20 10:25:17 -06:00
|
|
|
import re
|
2010-04-10 02:41:39 +01:00
|
|
|
import subprocess
|
2008-02-27 17:36:28 +09:00
|
|
|
import sys
|
|
|
|
import platform as _platform
|
|
|
|
|
2010-11-01 13:30:22 +00:00
|
|
|
import SCons.Script.SConscript
|
|
|
|
|
2008-02-27 17:36:28 +09:00
|
|
|
|
|
|
|
#######################################################################
|
|
|
|
# Defaults
|
|
|
|
|
2011-02-11 16:44:13 +00:00
|
|
|
host_platform = _platform.system().lower()
|
2011-02-24 19:49:37 -08:00
|
|
|
if host_platform.startswith('cygwin'):
|
|
|
|
host_platform = 'cygwin'
|
2008-02-27 17:36:28 +09:00
|
|
|
|
2010-11-01 13:30:22 +00:00
|
|
|
# Search sys.argv[] for a "platform=foo" argument since we don't have
|
|
|
|
# an 'env' variable at this point.
|
|
|
|
if 'platform' in SCons.Script.ARGUMENTS:
|
2011-01-13 20:52:01 +00:00
|
|
|
target_platform = SCons.Script.ARGUMENTS['platform']
|
2010-11-01 13:30:22 +00:00
|
|
|
else:
|
2011-01-13 20:52:01 +00:00
|
|
|
target_platform = host_platform
|
2010-11-01 13:30:22 +00:00
|
|
|
|
2008-02-27 17:36:28 +09:00
|
|
|
_machine_map = {
|
|
|
|
'x86': 'x86',
|
|
|
|
'i386': 'x86',
|
|
|
|
'i486': 'x86',
|
|
|
|
'i586': 'x86',
|
|
|
|
'i686': 'x86',
|
2012-01-17 15:46:01 +00:00
|
|
|
'BePC': 'x86',
|
|
|
|
'Intel': 'x86',
|
2008-10-23 10:28:48 +02:00
|
|
|
'ppc' : 'ppc',
|
2012-01-17 15:46:01 +00:00
|
|
|
'BeBox': 'ppc',
|
|
|
|
'BeMac': 'ppc',
|
2011-02-15 17:31:31 +00:00
|
|
|
'AMD64': 'x86_64',
|
2008-02-27 17:36:28 +09:00
|
|
|
'x86_64': 'x86_64',
|
2012-01-17 15:46:01 +00:00
|
|
|
'sparc': 'sparc',
|
|
|
|
'sun4u': 'sparc',
|
2008-02-27 17:36:28 +09:00
|
|
|
}
|
2010-05-20 10:26:19 -06:00
|
|
|
|
|
|
|
|
2011-01-13 20:52:01 +00:00
|
|
|
# find host_machine value
|
2008-02-27 17:36:28 +09:00
|
|
|
if 'PROCESSOR_ARCHITECTURE' in os.environ:
|
2011-01-13 20:52:01 +00:00
|
|
|
host_machine = os.environ['PROCESSOR_ARCHITECTURE']
|
2008-02-27 17:36:28 +09:00
|
|
|
else:
|
2011-01-13 20:52:01 +00:00
|
|
|
host_machine = _platform.machine()
|
|
|
|
host_machine = _machine_map.get(host_machine, 'generic')
|
|
|
|
|
|
|
|
default_machine = host_machine
|
2010-11-01 13:30:22 +00:00
|
|
|
default_toolchain = 'default'
|
|
|
|
|
2011-02-11 16:44:13 +00:00
|
|
|
if target_platform == 'windows' and host_platform != 'windows':
|
2010-11-01 13:30:22 +00:00
|
|
|
default_machine = 'x86'
|
|
|
|
default_toolchain = 'crossmingw'
|
2008-02-27 17:36:28 +09:00
|
|
|
|
2010-05-20 10:26:19 -06:00
|
|
|
|
|
|
|
# find default_llvm value
|
2010-04-13 19:40:48 +09:00
|
|
|
if 'LLVM' in os.environ:
|
2010-04-10 02:41:39 +01:00
|
|
|
default_llvm = 'yes'
|
|
|
|
else:
|
|
|
|
default_llvm = 'no'
|
2010-04-13 19:40:48 +09:00
|
|
|
try:
|
2011-01-13 20:52:01 +00:00
|
|
|
if target_platform != 'windows' and \
|
2010-11-01 13:30:22 +00:00
|
|
|
subprocess.call(['llvm-config', '--version'], stdout=subprocess.PIPE) == 0:
|
2010-04-13 19:40:48 +09:00
|
|
|
default_llvm = 'yes'
|
|
|
|
except:
|
|
|
|
pass
|
2010-04-10 02:41:39 +01:00
|
|
|
|
2010-05-20 10:26:19 -06:00
|
|
|
|
2008-02-27 17:36:28 +09:00
|
|
|
#######################################################################
|
|
|
|
# Common options
|
|
|
|
|
2008-03-03 18:52:37 +01:00
|
|
|
def AddOptions(opts):
|
2008-05-01 00:58:04 +09:00
|
|
|
try:
|
|
|
|
from SCons.Variables.BoolVariable import BoolVariable as BoolOption
|
|
|
|
except ImportError:
|
2009-05-01 16:12:17 +01:00
|
|
|
from SCons.Options.BoolOption import BoolOption
|
|
|
|
try:
|
2008-05-01 00:58:04 +09:00
|
|
|
from SCons.Variables.EnumVariable import EnumVariable as EnumOption
|
2009-05-01 16:12:17 +01:00
|
|
|
except ImportError:
|
|
|
|
from SCons.Options.EnumOption import EnumOption
|
2010-09-29 14:08:53 +01:00
|
|
|
opts.Add(EnumOption('build', 'build type', 'debug',
|
|
|
|
allowed_values=('debug', 'checked', 'profile', 'release')))
|
2011-06-17 18:42:39 +01:00
|
|
|
opts.Add(BoolOption('verbose', 'verbose output', 'no'))
|
2008-02-27 17:36:28 +09:00
|
|
|
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
|
2008-10-23 10:28:48 +02:00
|
|
|
allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
|
2011-01-13 20:52:01 +00:00
|
|
|
opts.Add(EnumOption('platform', 'target platform', host_platform,
|
2012-05-23 17:26:20 -07:00
|
|
|
allowed_values=('cygwin', 'darwin', 'freebsd', 'haiku', 'linux', 'sunos', 'windows')))
|
2011-06-17 14:48:28 +01:00
|
|
|
opts.Add(BoolOption('embedded', 'embedded build', 'no'))
|
2010-11-01 13:30:22 +00:00
|
|
|
opts.Add('toolchain', 'compiler toolchain', default_toolchain)
|
2011-01-14 17:50:29 +08:00
|
|
|
opts.Add(BoolOption('gles', 'EXPERIMENTAL: enable OpenGL ES support', 'no'))
|
2010-04-10 02:41:39 +01:00
|
|
|
opts.Add(BoolOption('llvm', 'use LLVM', default_llvm))
|
2011-08-10 08:07:29 +00:00
|
|
|
opts.Add(BoolOption('openmp', 'EXPERIMENTAL: compile with openmp (swrast)', 'no'))
|
2010-09-29 14:08:53 +01:00
|
|
|
opts.Add(BoolOption('debug', 'DEPRECATED: debug build', 'yes'))
|
|
|
|
opts.Add(BoolOption('profile', 'DEPRECATED: profile build', 'no'))
|
2011-06-17 20:12:18 +01:00
|
|
|
opts.Add(BoolOption('quiet', 'DEPRECATED: profile build', 'yes'))
|
2012-08-12 00:02:32 -07:00
|
|
|
opts.Add(BoolOption('texture_float', 'enable floating-point textures and renderbuffers', 'no'))
|
2011-06-17 20:07:12 +01:00
|
|
|
if host_platform == 'windows':
|
|
|
|
opts.Add(EnumOption('MSVS_VERSION', 'MS Visual C++ version', None, allowed_values=('7.1', '8.0', '9.0')))
|