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 ('_WIN32_WCE', '500'),
169 'WCE_PLATFORM_STANDARDSDK_500',
179 if platform
== 'windows':
180 cppdefines
+= ['PIPE_SUBSYSTEM_WINDOWS_USER']
181 if platform
== 'winddk':
182 cppdefines
+= ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
183 if platform
== 'wince':
184 cppdefines
+= ['PIPE_SUBSYSTEM_WINDOWS_CE']
185 env
.Append(CPPDEFINES
= cppdefines
)
187 # C preprocessor includes
188 if platform
== 'winddk':
189 env
.Append(CPPPATH
= [
200 cflags
+= ['-O0', '-g3']
202 cflags
+= ['-O3', '-g3']
205 if env
['machine'] == 'x86':
207 if env
['machine'] == 'x86_64':
211 '-Wmissing-prototypes',
215 '-fmessage-length=0', # be nice to Eclipse
219 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
223 '/Od', # disable optimizations
224 '/Oi', # enable intrinsic functions
225 '/Oy-', # disable frame pointer omission
229 '/Ox', # maximum optimizations
230 '/Oi', # enable intrinsic functions
231 '/Os', # favor code space
235 '/Gh', # enable _penter hook function
236 '/GH', # enable _pexit hook function
239 '/W3', # warning level
240 #'/Wp64', # enable 64 bit porting warnings
242 if platform
== 'windows':
246 if platform
== 'winddk':
248 '/Zl', # omit default library name in .OBJ
249 '/Zp8', # 8bytes struct member alignment
250 '/Gy', # separate functions for linker
251 '/Gm-', # disable minimal rebuild
252 '/WX', # treat warnings as errors
253 '/Gz', # __stdcall Calling convention
254 '/GX-', # disable C++ EH
255 '/GR-', # disable C++ RTTI
256 '/GF', # enable read-only string pooling
257 '/G6', # optimize for PPro, P-II, P-III
258 '/Ze', # enable extensions
259 '/Gi-', # disable incremental compilation
260 '/QIfdiv-', # disable Pentium FDIV fix
261 '/hotpatch', # prepares an image for hotpatching.
262 #'/Z7', #enable old-style debug info
264 if platform
== 'wince':
267 '/GF', # enable read-only string pooling
269 # Automatic pdb generation
270 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
271 env
.EnsureSConsVersion(0, 98, 0)
272 env
['PDB'] = '${TARGET.base}.pdb'
273 env
.Append(CFLAGS
= cflags
)
274 env
.Append(CXXFLAGS
= cflags
)
279 if env
['machine'] == 'x86':
280 linkflags
+= ['-m32']
281 if env
['machine'] == 'x86_64':
282 linkflags
+= ['-m64']
283 if platform
== 'winddk':
285 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
288 '/merge:_TEXT=.text',
292 '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
305 '/stack:0x40000,0x1000',
308 '/subsystem:native,5.01',
311 '/entry:DrvEnableDriver',
313 env
.Append(LINKFLAGS
= linkflags
)
315 # Convenience Library Builder
316 createConvenienceLibBuilder(env
)