1 #############################################################################
3 # Copyright 2008-2009 VMware, Inc.
6 # Permission is hereby granted, free of charge, to any person obtaining a copy
7 # of this software and associated documentation files (the "Software"), to deal
8 # in the Software without restriction, including without limitation the rights
9 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 # copies of the Software, and to permit persons to whom the Software is
11 # furnished to do so, subject to the following conditions:
13 # The above copyright notice and this permission notice shall be included in
14 # all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 #############################################################################
38 default_platform = _platform_map.get(sys.platform, 'unix')
49 if 'PROCESSOR_ARCHITECTURE' in os.environ:
50 default_machine = os.environ['PROCESSOR_ARCHITECTURE']
52 default_machine = platform.machine()
53 default_machine = _machine_map.get(default_machine, 'generic')
56 vars.Add(BoolVariable('debug', 'debug build', 'no'))
57 vars.Add(EnumVariable('platform', 'target platform', default_platform,
58 allowed_values=('linux', 'freebsd', 'unix', 'other', 'windows')))
59 vars.Add(EnumVariable('machine', 'use machine-specific assembly code', default_machine,
60 allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
61 vars.Add(EnumVariable('toolchain', 'compiler toolchain', 'default',
62 allowed_values=('default', 'crossmingw', 'winsdk')))
63 vars.Add(EnumVariable('MSVS_VERSION', 'Microsoft Visual Studio version', None, allowed_values=('7.1', '8.0', '9.0')))
68 Help(vars.GenerateHelpText(env))
72 env.Tool(env['toolchain'])
74 env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
75 env['msvc'] = env['CC'] == 'cl'
77 # C preprocessor options
80 cppdefines += ['NDEBUG']
81 if env['platform'] == 'windows':
87 '_CRT_SECURE_NO_DEPRECATE',
88 '_CRT_NON_CONFORMING_SWPRINTFS',
89 'WIN32_LEAN_AND_MEAN',
91 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
94 cppdefines += ['_DEBUG']
95 env.Append(CPPDEFINES = cppdefines)
100 ccflags = [] # C & C++
103 ccflags += ['-O0', '-g3']
105 ccflags += ['-O3', '-g0']
106 if env['machine'] == 'x86':
108 if env['machine'] == 'x86_64':
111 # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
113 '-Werror=declaration-after-statement',
115 '-Wmissing-field-initializers',
117 '-fmessage-length=0', # be nice to Eclipse
120 '-Wmissing-prototypes',
125 '/Od', # disable optimizations
126 '/Oi', # enable intrinsic functions
127 '/Oy-', # disable frame pointer omission
128 '/GL-', # disable whole program optimization
132 '/Ox', # maximum optimizations
133 '/Oi', # enable intrinsic functions
134 '/Ot', # favor code speed
137 '/EHsc', # set exception handling model
138 '/W4', # warning level
139 #'/Wp64', # enable 64 bit porting warnings
141 # Automatic pdb generation
142 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
143 env.EnsureSConsVersion(0, 98, 0)
144 env['PDB'] = '${TARGET.base}.pdb'
145 env.Append(CCFLAGS = ccflags)
146 env.Append(CFLAGS = cflags)
147 env.Append(CXXFLAGS = cxxflags)
149 if env['platform'] == 'windows' and env['msvc']:
150 # Choose the appropriate MSVC CRT
151 # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
153 env.Append(CCFLAGS = ['/MTd'])
154 env.Append(SHCCFLAGS = ['/LDd'])
156 env.Append(CCFLAGS = ['/MT'])
157 env.Append(SHCCFLAGS = ['/LD'])
161 if env['machine'] == 'x86':
162 env.Append(ASFLAGS = ['-m32'])
163 if env['machine'] == 'x86_64':
164 env.Append(ASFLAGS = ['-m64'])
169 if env['machine'] == 'x86':
170 linkflags += ['-m32']
171 if env['machine'] == 'x86_64':
172 linkflags += ['-m64']
173 if env['platform'] == 'windows' and env['msvc']:
175 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
180 env.Append(LINKFLAGS = linkflags)
188 SConscript('zlib/SConscript')
192 conf = Configure(env)
193 has_d3d7 = conf.CheckCXXHeader('ddraw.h')
194 has_d3d8 = conf.CheckCXXHeader('d3d8.h')
195 has_d3d9 = conf.CheckCXXHeader('d3d9.h')
196 if env['toolchain'] != 'crossmingw':
197 has_d3d10 = conf.CheckCXXHeader('d3d10.h')
198 has_d3d10_1 = conf.CheckCXXHeader('d3d10_1.h')
200 # The above checks do not give reliable results for MinGW
205 if has_d3d7 and False:
207 target = 'ddraw.cpp',
208 source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
209 action = 'python $SOURCE > $TARGET',
212 ddraw = env.SharedLibrary(
227 source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
228 action = 'python $SOURCE > $TARGET',
231 d3d8 = env.SharedLibrary(
246 source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'd3dshader.py', 'windows.py', 'base.py'],
247 action = 'python $SOURCE > $TARGET',
250 d3d9 = env.SharedLibrary(
264 target = 'd3d10.cpp',
265 source = ['d3d10misc.py', 'windows.py', 'base.py'],
266 action = 'python $SOURCE > $TARGET',
269 d3d10 = env.SharedLibrary(
283 target = 'd3d10_1.cpp',
284 source = ['d3d10_1.py', 'windows.py', 'base.py'],
285 action = 'python $SOURCE > $TARGET',
288 d3d10_1 = env.SharedLibrary(
301 target = 'opengl32.cpp',
302 source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
303 action = 'python $SOURCE > $TARGET',
306 opengl32 = env.SharedLibrary(
316 env.Default(opengl32)
318 env.Tool('packaging')
322 VERSION = time.strftime('%Y%m%d'),
326 SUMMARY = 'Tool to trace Direct3D & OpenGL API calls from applications.',
327 SOURCE_URL = 'http://code.google.com/p/jrfonseca/source/browse?repo=apitrace',
338 env.Alias('dist', zip)