1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
import sys
import os
EnsureSConsVersion(0,98,1)
#######################################################
# reusable functions and data structures
#######################################################
# Platform to Target Map (specifies which default target to build on a platform)
PLATFORM_TO_TARGET_MAP = {
'linux-i386' : 'x86-unknown-linux',
'linux2' : 'x86-unknown-linux',
'win32' : 'x86-microsoft-win32',
'cygwin' : 'x86-unknown-cygwin',
'darwin' : 'universal-apple-macosx'
}
CROSS_PLATFORMS = ['ppu-sony-ps3', 'arm-unknown-linux', 'arm-gp2x-linux', 'arm-android-linux']
SPECIAL_PLATFORMS = ['universal-apple-macosx-xcode']
def DefaultTarget():
if PLATFORM_TO_TARGET_MAP.has_key(sys.platform):
return PLATFORM_TO_TARGET_MAP[sys.platform]
else:
return None
#######################################################
# Main Build
#######################################################
options = Variables()
options.AddVariables(
EnumVariable('target', 'build target', DefaultTarget(), allowed_values=PLATFORM_TO_TARGET_MAP.values()+CROSS_PLATFORMS+SPECIAL_PLATFORMS),
BoolVariable('stop_on_warning', 'Stop the build on warnings', False),
ListVariable('build_config', 'build configurations', 'Debug', names=['Debug', 'Release'])
)
env = Environment(variables=options)
Help(options.GenerateHelpText(env))
if 'CXX' in os.environ:
env['CXX'] = os.environ['CXX']
if 'CC' in os.environ:
env['CC'] = os.environ['CC']
if not hasattr(env, 'Clone'): env.Clone = env.Copy ## old scons compatibility
base_env = env
### special build for x86-microsoft-win32
if env['target'] == 'x86-microsoft-win32':
import subprocess
for build_config in env['build_config']:
env = base_env.Clone()
env['build_config'] = build_config
print '********** Configuring Build Target =', env['target'], '/', build_config, '********'
retVal = subprocess.call(["python", "Build.py", "-r", "-s", "Platinum.sln", "-b", build_config], cwd=env.GetBuildPath('#/Build/Targets/x86-microsoft-win32-vs2005/'))
if (retVal != 0):
sys.exit(retVal)
### special build for universal-apple-macosx-xcode
elif env['target'] == 'universal-apple-macosx-xcode':
import subprocess
for build_config in env['build_config']:
env = base_env.Clone()
env['build_config'] = build_config
print '********** Configuring Build Target =', env['target'], '/', build_config, '********'
retVal = subprocess.call(["python", "../../Tools/Scripts/XCodeMake.py", "-p", "Platinum.xcodeproj", "-t", "All", "-s", "macosx", "-b", build_config], cwd=env.GetBuildPath('#/Build/Targets/universal-apple-macosx/'))
if (retVal != 0):
sys.exit(retVal)
else:
### call the actual build script for each build config
for build_config in env['build_config']:
env = base_env.Clone()
env['build_config'] = build_config
print '********** Configuring Build Target =', env['target'], '/', build_config, '********'
SConscript('Build.scons', variant_dir='Targets/'+env['target']+'/'+build_config, exports='env', duplicate=0)
|