3 Frontend-tool for Gallium3D architecture.
8 # Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
11 # Permission is hereby granted, free of charge, to any person obtaining a
12 # copy of this software and associated documentation files (the
13 # "Software"), to deal in the Software without restriction, including
14 # without limitation the rights to use, copy, modify, merge, publish,
15 # distribute, sub license, and/or sell copies of the Software, and to
16 # permit persons to whom the Software is furnished to do so, subject to
17 # the following conditions:
19 # The above copyright notice and this permission notice (including the
20 # next paragraph) shall be included in all copies or substantial portions
23 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24 # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
26 # IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
27 # ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
28 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
29 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 def quietCommandLines(env):
41 # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
42 env['CCCOMSTR'] = "Compiling $SOURCE ..."
43 env['CXXCOMSTR'] = "Compiling $SOURCE ..."
44 env['ARCOMSTR'] = "Archiving $TARGET ..."
45 env['RANLIBCOMSTR'] = ""
46 env['LINKCOMSTR'] = "Linking $TARGET ..."
49 def createConvenienceLibBuilder(env):
50 """This is a utility function that creates the ConvenienceLibrary
51 Builder in an Environment if it is not there already.
53 If it is already there, we return the existing one.
55 Based on the stock StaticLibrary and SharedLibrary builders.
59 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
61 action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
62 if env.Detect('ranlib'):
63 ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
64 action_list.append(ranlib_action)
66 convenience_lib = SCons.Builder.Builder(action = action_list,
67 emitter = '$LIBEMITTER',
68 prefix = '$LIBPREFIX',
69 suffix = '$LIBSUFFIX',
70 src_suffix = '$SHOBJSUFFIX',
71 src_builder = 'SharedObject')
72 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
73 env['BUILDERS']['Library'] = convenience_lib
75 return convenience_lib
79 """Common environment generation code"""
81 # FIXME: this is already too late
82 #if env.get('quiet', False):
83 # quietCommandLines(env)
87 machine = env['machine']
88 platform = env['platform']
89 x86 = env['machine'] == 'x86'
90 gcc = env['platform'] in ('linux', 'freebsd', 'darwin')
91 msvc = env['platform'] in ('windows', 'winddk', 'wince')
94 if platform == 'winddk':
96 elif platform == 'wince':
101 # Put build output in a separate dir, which depends on the current
102 # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
103 build_topdir = 'build'
104 build_subdir = env['platform']
106 build_subdir += "-dri"
108 build_subdir += "-llvm"
109 if env['machine'] != 'generic':
110 build_subdir += '-' + env['machine']
112 build_subdir += "-debug"
114 build_subdir += "-profile"
115 build_dir = os.path.join(build_topdir, build_subdir)
116 # Place the .sconsign file in the build dir too, to avoid issues with
117 # different scons versions building the same source file
118 env['build'] = build_dir
119 env.SConsignFile(os.path.join(build_dir, '.sconsign'))
121 # C preprocessor options
124 cppdefines += ['DEBUG']
126 cppdefines += ['NDEBUG']
128 cppdefines += ['PROFILE']
129 if platform == 'windows':
135 # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
136 'WIN32_LEAN_AND_MEAN',
138 '_CRT_SECURE_NO_DEPRECATE',
141 cppdefines += ['_DEBUG']
142 if platform == 'winddk':
143 # Mimic WINDDK's builtin flags. See also:
144 # - WINDDK's bin/makefile.new i386mk.inc for more info.
145 # - buildchk_wxp_x86.log files, generated by the WINDDK's build
146 # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
151 ('CONDITION_HANDLING', '1'),
156 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
157 ('WINVER', '0x0501'),
158 ('_WIN32_IE', '0x0603'),
159 ('WIN32_LEAN_AND_MEAN', '1'),
161 ('__BUILDMACHINE__', 'WinDDK'),
165 cppdefines += [('DBG', 1)]
166 if platform == 'wince':
168 '_CRT_SECURE_NO_DEPRECATE',
173 ('_WIN32_WCE', '0x600'),
181 ('INTLMSG_CODEPAGE', '1252'),
183 if platform == 'windows':
184 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
185 if platform == 'winddk':
186 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
187 if platform == 'wince':
188 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
189 env.Append(CPPDEFINES = cppdefines)
191 # C preprocessor includes
192 if platform == 'winddk':
193 env.Append(CPPPATH = [
204 cflags += ['-O0', '-g3']
206 cflags += ['-O3', '-g3']
209 if env['machine'] == 'x86':
211 if env['machine'] == 'x86_64':
215 '-Wmissing-prototypes',
219 '-fmessage-length=0', # be nice to Eclipse
223 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
227 '/Od', # disable optimizations
228 '/Oi', # enable intrinsic functions
229 '/Oy-', # disable frame pointer omission
233 '/Ox', # maximum optimizations
234 '/Oi', # enable intrinsic functions
235 '/Os', # favor code space
239 '/Gh', # enable _penter hook function
240 '/GH', # enable _pexit hook function
243 '/W3', # warning level
244 #'/Wp64', # enable 64 bit porting warnings
246 if platform == 'windows':
250 if platform == 'winddk':
252 '/Zl', # omit default library name in .OBJ
253 '/Zp8', # 8bytes struct member alignment
254 '/Gy', # separate functions for linker
255 '/Gm-', # disable minimal rebuild
256 '/WX', # treat warnings as errors
257 '/Gz', # __stdcall Calling convention
258 '/GX-', # disable C++ EH
259 '/GR-', # disable C++ RTTI
260 '/GF', # enable read-only string pooling
261 '/G6', # optimize for PPro, P-II, P-III
262 '/Ze', # enable extensions
263 '/Gi-', # disable incremental compilation
264 '/QIfdiv-', # disable Pentium FDIV fix
265 '/hotpatch', # prepares an image for hotpatching.
266 #'/Z7', #enable old-style debug info
268 if platform == 'wince':
269 # See also C:\WINCE600\public\common\oak\misc\makefile.def
271 '/GF', # enable read-only string pooling
272 '/GR-', # disable C++ RTTI
273 '/GS', # enable security checks
274 # Allow disabling language conformance to maintain backward compat
275 #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
276 #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
282 # Automatic pdb generation
283 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
284 env.EnsureSConsVersion(0, 98, 0)
285 env['PDB'] = '${TARGET.base}.pdb'
286 env.Append(CFLAGS = cflags)
287 env.Append(CXXFLAGS = cflags)
291 if env['machine'] == 'x86':
292 env.Append(ASFLAGS = ['-m32'])
293 if env['machine'] == 'x86_64':
294 env.Append(ASFLAGS = ['-m64'])
299 if env['machine'] == 'x86':
300 linkflags += ['-m32']
301 if env['machine'] == 'x86_64':
302 linkflags += ['-m64']
303 if platform == 'winddk':
305 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
308 '/merge:_TEXT=.text',
312 '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
325 '/stack:0x40000,0x1000',
328 '/subsystem:native,5.01',
331 '/entry:DrvEnableDriver',
335 '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
337 env.Append(LINKFLAGS = linkflags)
339 # Convenience Library Builder
340 createConvenienceLibBuilder(env)