-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSConscript
More file actions
141 lines (123 loc) · 5.03 KB
/
SConscript
File metadata and controls
141 lines (123 loc) · 5.03 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# Ziggurat -- Copyright 2011 GameClay LLC
# Portions Copyright 2010 - 2011, Qualcomm Innovation Center, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import os, sys
vars = Variables()
# Figure out the default OS based on Python's sys.platform
default_os = ''
host_os = ''
if sys.platform.startswith('darwin'):
default_os = 'darwin'
host_os = 'darwin'
elif sys.platform.startswith('linux'):
default_os = 'linux'
host_os = 'linux'
elif sys.platform.startswith('win32'):
default_os = 'win7' # TODO: Use sys.winver?
host_os = 'windows'
elif sys.platform.startswith('cygwin'):
default_os = 'winxp'
host_os = 'windows'
# Common build variables
vars.Add(EnumVariable('OS', 'Target OS', default_os, allowed_values=('linux', 'win7', 'winxp', 'android', 'darwin', 'ios')))
vars.Add(EnumVariable('CPU', 'Target CPU', 'x86', allowed_values=('x86', 'x86-64', 'IA64', 'arm', 'armv7', 'armv6')))
vars.Add(EnumVariable('VARIANT', 'Build variant', 'debug', allowed_values=('debug', 'release')))
vars.Add(EnumVariable('MSVC_VERSION', 'MSVC compiler version - Windows', '9.0', allowed_values=('9.0', '10.0')))
# Standard variant directories
build_dir = 'build/${OS}/${CPU}/${VARIANT}'
vars.AddVariables(('OBJDIR', '', build_dir + '/obj'),
('DISTDIR', '', '#' + build_dir + '/dist'),
('BUILDDIR', '', build_dir))
env = Environment(variables = vars)
path = env['ENV']['PATH']
# Recreate the environment with the correct path
if env['OS'] == 'win7' or env['OS'] == 'winxp':
if env['CPU'] == 'x86':
env = Environment(variables = vars, TARGET_ARCH='x86', MSVC_VERSION='${MSVC_VERSION}', ENV={'PATH': path})
print 'Building for 32 bit Windows'
elif env['CPU'] == 'IA64':
print 'Building for 64 bit Windows'
env = Environment(variables = vars, TARGET_ARCH='x86_64', MSVC_VERSION='${MSVC_VERSION}', ENV={'PATH': path})
else:
print 'Windows CPU must be x86 or IA64'
Exit()
elif env['OS'] == 'android':
env = Environment(variables = vars, tools = ['gnulink', 'gcc', 'g++', 'ar', 'as'], ENV={'PATH': path})
elif env['OS'] == 'darwin':
if (env['CPU'].startswith('arm') or env['CPU'] == 'IA64'):
print 'Darwin CPU msut be x86 or x86-64'
Exit()
elif env['OS'] == 'ios':
if (env['CPU'] == 'arm' or env['CPU'] == 'x86-64' or env['CPU'] == 'IA64'):
print 'iOS CPU msut be armv6 or armv7'
Exit()
else:
env = Environment(variables = vars, ENV={'PATH': path})
Help(vars.GenerateHelpText(env))
# Bring in platform defines if they exist
try:
Import('platform_defines')
if not ('' == platform_defines.subst('$ZIG_OS_ANDROID')):
env['ZIG_OS_ANDROID'] = platform_defines['ZIG_OS_ANDROID']
if not ('' == platform_defines.subst('$ZIG_OS_DARWIN')):
env['ZIG_OS_DARWIN'] = platform_defines['ZIG_OS_DARWIN']
if not ('' == platform_defines.subst('$ZIG_OS_IOS')):
env['ZIG_OS_IOS'] = platform_defines['ZIG_OS_IOS']
if not ('' == platform_defines.subst('$ZIG_OS_WINDOWS')):
env['ZIG_OS_WINDOWS'] = platform_defines['ZIG_OS_WINDOWS']
if not ('' == platform_defines.subst('$ZIG_CPU_ARM')):
env['ZIG_CPU_ARM'] = platform_defines['ZIG_CPU_ARM']
if not ('' == platform_defines.subst('$ZIG_CPU_X86')):
env['ZIG_CPU_X86'] = platform_defines['ZIG_CPU_X86']
if not ('' == platform_defines.subst('$ZIG_CPU_X64')):
env['ZIG_CPU_X64'] = platform_defines['ZIG_CPU_X64']
except:
print ''
# SetDefault for the desired OS/CPU defines
env.SetDefault(ZIG_OS_ANDROID = 'ZIG_OS_ANDROID')
env.SetDefault(ZIG_OS_DARWIN = 'ZIG_OS_DARWIN')
env.SetDefault(ZIG_OS_IOS = 'ZIG_OS_IOS')
env.SetDefault(ZIG_OS_WINDOWS = 'ZIG_OS_WINDOWS')
env.SetDefault(ZIG_CPU_ARM = 'ZIG_CPU_ARM')
env.SetDefault(ZIG_CPU_X86 = 'ZIG_CPU_X86')
env.SetDefault(ZIG_CPU_X64 = 'ZIG_CPU_X64')
# Validate build vars
if env['OS'] == 'linux':
env['OS_GROUP'] = 'posix'
env['OS_CONF'] = 'linux'
elif env['OS'] == 'win7' or env['OS'] == 'winxp':
env['OS_GROUP'] = 'windows'
env['OS_CONF'] = 'windows'
elif env['OS'] == 'android':
env['OS_GROUP'] = 'posix'
env['OS_CONF'] = 'android'
elif env['OS'] == 'darwin':
env['OS_GROUP'] = 'posix'
env['OS_CONF'] = 'darwin'
elif env['OS'] == 'ios':
env['OS_GROUP'] = 'posix'
env['OS_CONF'] = 'ios'
else:
print 'Unsupported OS/CPU combination'
Exit()
# Host OS is the build platform
env['HOST_OS'] = host_os
if env['VARIANT'] == 'release':
env.Append(CPPDEFINES = 'NDEBUG')
else:
env.Append(CPPDEFINES = ['DEBUG', '_DEBUG'])
# Read OS and CPU specific SConscript file
Export('env')
env.SConscript('conf/${OS_CONF}/${CPU}/SConscript')
Return('env')