blob: 0d5843603e9659cba19a01abf50c034a0c0ab8b1 [file] [log] [blame]
José Fonsecab04aa712008-06-06 14:48:57 +09001"""gallium
2
3Frontend-tool for Gallium3D architecture.
4
5"""
6
José Fonseca381e3482008-07-17 11:23:43 +09007#
José Fonsecab04aa712008-06-06 14:48:57 +09008# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
9# All Rights Reserved.
José Fonseca381e3482008-07-17 11:23:43 +090010#
José Fonsecab04aa712008-06-06 14:48:57 +090011# 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:
José Fonseca381e3482008-07-17 11:23:43 +090018#
José Fonsecab04aa712008-06-06 14:48:57 +090019# The above copyright notice and this permission notice (including the
20# next paragraph) shall be included in all copies or substantial portions
21# of the Software.
José Fonseca381e3482008-07-17 11:23:43 +090022#
José Fonsecab04aa712008-06-06 14:48:57 +090023# 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.
José Fonseca381e3482008-07-17 11:23:43 +090030#
José Fonsecab04aa712008-06-06 14:48:57 +090031
32
José Fonseca27d8d6f2008-07-03 12:42:23 +090033import os
José Fonsecab04aa712008-06-06 14:48:57 +090034import os.path
José Fonseca27d8d6f2008-07-03 12:42:23 +090035import re
José Fonsecab04aa712008-06-06 14:48:57 +090036
37import SCons.Action
38import SCons.Builder
José Fonseca27d8d6f2008-07-03 12:42:23 +090039import SCons.Scanner
José Fonsecab04aa712008-06-06 14:48:57 +090040
41
42def quietCommandLines(env):
José Fonseca381e3482008-07-17 11:23:43 +090043 # Quiet command lines
44 # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
José Fonseca0f50c4f2009-06-02 18:23:12 -070045 env['ASCOMSTR'] = "Assembling $SOURCE ..."
José Fonseca381e3482008-07-17 11:23:43 +090046 env['CCCOMSTR'] = "Compiling $SOURCE ..."
José Fonseca0f50c4f2009-06-02 18:23:12 -070047 env['SHCCCOMSTR'] = "Compiling $SOURCE ..."
José Fonseca381e3482008-07-17 11:23:43 +090048 env['CXXCOMSTR'] = "Compiling $SOURCE ..."
José Fonseca0f50c4f2009-06-02 18:23:12 -070049 env['SHCXXCOMSTR'] = "Compiling $SOURCE ..."
José Fonseca381e3482008-07-17 11:23:43 +090050 env['ARCOMSTR'] = "Archiving $TARGET ..."
José Fonseca0f50c4f2009-06-02 18:23:12 -070051 env['RANLIBCOMSTR'] = "Indexing $TARGET ..."
José Fonseca381e3482008-07-17 11:23:43 +090052 env['LINKCOMSTR'] = "Linking $TARGET ..."
José Fonseca0f50c4f2009-06-02 18:23:12 -070053 env['SHLINKCOMSTR'] = "Linking $TARGET ..."
54 env['LDMODULECOMSTR'] = "Linking $TARGET ..."
55 env['SWIGCOMSTR'] = "Generating $TARGET ..."
José Fonsecab04aa712008-06-06 14:48:57 +090056
57
58def createConvenienceLibBuilder(env):
59 """This is a utility function that creates the ConvenienceLibrary
60 Builder in an Environment if it is not there already.
61
62 If it is already there, we return the existing one.
José Fonseca381e3482008-07-17 11:23:43 +090063
José Fonsecab04aa712008-06-06 14:48:57 +090064 Based on the stock StaticLibrary and SharedLibrary builders.
65 """
66
67 try:
68 convenience_lib = env['BUILDERS']['ConvenienceLibrary']
69 except KeyError:
70 action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
71 if env.Detect('ranlib'):
72 ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
73 action_list.append(ranlib_action)
74
75 convenience_lib = SCons.Builder.Builder(action = action_list,
76 emitter = '$LIBEMITTER',
77 prefix = '$LIBPREFIX',
78 suffix = '$LIBSUFFIX',
79 src_suffix = '$SHOBJSUFFIX',
80 src_builder = 'SharedObject')
81 env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
José Fonsecab04aa712008-06-06 14:48:57 +090082
83 return convenience_lib
84
85
José Fonseca27d8d6f2008-07-03 12:42:23 +090086# TODO: handle import statements with multiple modules
87# TODO: handle from import statements
88import_re = re.compile(r'^import\s+(\S+)$', re.M)
89
90def python_scan(node, env, path):
José Fonseca381e3482008-07-17 11:23:43 +090091 # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
92 contents = node.get_contents()
93 source_dir = node.get_dir()
94 imports = import_re.findall(contents)
95 results = []
96 for imp in imports:
97 for dir in path:
98 file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
99 if os.path.exists(file):
100 results.append(env.File(file))
101 break
102 file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
103 if os.path.exists(file):
104 results.append(env.File(file))
105 break
106 return results
José Fonseca27d8d6f2008-07-03 12:42:23 +0900107
108python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
109
110
111def code_generate(env, script, target, source, command):
José Fonseca381e3482008-07-17 11:23:43 +0900112 """Method to simplify code generation via python scripts.
José Fonseca27d8d6f2008-07-03 12:42:23 +0900113
José Fonseca381e3482008-07-17 11:23:43 +0900114 http://www.scons.org/wiki/UsingCodeGenerators
115 http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
116 """
117
118 # We're generating code using Python scripts, so we have to be
119 # careful with our scons elements. This entry represents
120 # the generator file *in the source directory*.
121 script_src = env.File(script).srcnode()
122
123 # This command creates generated code *in the build directory*.
124 command = command.replace('$SCRIPT', script_src.path)
125 code = env.Command(target, source, command)
126
127 # Explicitly mark that the generated code depends on the generator,
128 # and on implicitly imported python modules
129 path = (script_src.get_dir(),)
130 deps = [script_src]
131 deps += script_src.get_implicit_deps(env, python_scanner, path)
132 env.Depends(code, deps)
133
134 # Running the Python script causes .pyc files to be generated in the
135 # source directory. When we clean up, they should go too. So add side
136 # effects for .pyc files
137 for dep in deps:
138 pyc = env.File(str(dep) + 'c')
139 env.SideEffect(pyc, code)
140
141 return code
José Fonseca27d8d6f2008-07-03 12:42:23 +0900142
143
144def createCodeGenerateMethod(env):
José Fonseca381e3482008-07-17 11:23:43 +0900145 env.Append(SCANNERS = python_scanner)
146 env.AddMethod(code_generate, 'CodeGenerate')
José Fonseca27d8d6f2008-07-03 12:42:23 +0900147
148
José Fonseca52c2dd12008-09-08 07:54:15 +0900149def symlink(target, source, env):
150 target = str(target[0])
151 source = str(source[0])
152 if os.path.islink(target) or os.path.exists(target):
153 os.remove(target)
154 os.symlink(os.path.basename(source), target)
155
156def install_shared_library(env, source, version = ()):
157 source = str(source[0])
158 version = tuple(map(str, version))
José Fonseca7cfc2942008-09-08 21:50:50 +0900159 target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
José Fonseca52c2dd12008-09-08 07:54:15 +0900160 target_name = '.'.join((str(source),) + version)
161 last = env.InstallAs(os.path.join(target_dir, target_name), source)
162 while len(version):
163 version = version[:-1]
164 target_name = '.'.join((str(source),) + version)
165 action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
José Fonseca52c2dd12008-09-08 07:54:15 +0900166 last = env.Command(os.path.join(target_dir, target_name), last, action)
167
168def createInstallMethods(env):
169 env.AddMethod(install_shared_library, 'InstallSharedLibrary')
170
171
José Fonseca1e8177e2009-02-10 18:11:56 +0000172def num_jobs():
173 try:
174 return int(os.environ['NUMBER_OF_PROCESSORS'])
175 except (ValueError, KeyError):
176 pass
177
178 try:
179 return os.sysconf('SC_NPROCESSORS_ONLN')
180 except (ValueError, OSError, AttributeError):
181 pass
182
183 try:
184 return int(os.popen2("sysctl -n hw.ncpu")[1].read())
185 except ValueError:
186 pass
187
188 return 1
189
190
José Fonsecab04aa712008-06-06 14:48:57 +0900191def generate(env):
José Fonseca381e3482008-07-17 11:23:43 +0900192 """Common environment generation code"""
José Fonsecab04aa712008-06-06 14:48:57 +0900193
José Fonseca0f50c4f2009-06-02 18:23:12 -0700194 if env.get('quiet', True):
195 quietCommandLines(env)
José Fonsecab04aa712008-06-06 14:48:57 +0900196
José Fonseca6cf59e12008-11-18 19:13:32 +0900197 # Toolchain
198 platform = env['platform']
199 if env['toolchain'] == 'default':
200 if platform == 'winddk':
Michal Krol4f3dcf32008-11-19 20:31:38 +0100201 env['toolchain'] = 'winddk'
José Fonseca6cf59e12008-11-18 19:13:32 +0900202 elif platform == 'wince':
Michal Krol4f3dcf32008-11-19 20:31:38 +0100203 env['toolchain'] = 'wcesdk'
José Fonseca6cf59e12008-11-18 19:13:32 +0900204 env.Tool(env['toolchain'])
205
José Fonseca26e27ba2009-03-25 19:24:16 +0000206 env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
207 env['msvc'] = env['CC'] == 'cl'
208
José Fonseca381e3482008-07-17 11:23:43 +0900209 # shortcuts
210 debug = env['debug']
211 machine = env['machine']
212 platform = env['platform']
213 x86 = env['machine'] == 'x86'
Michel Dänzer6b69e3c2008-10-23 10:28:48 +0200214 ppc = env['machine'] == 'ppc'
José Fonseca26e27ba2009-03-25 19:24:16 +0000215 gcc = env['gcc']
216 msvc = env['msvc']
José Fonsecab04aa712008-06-06 14:48:57 +0900217
José Fonseca381e3482008-07-17 11:23:43 +0900218 # Put build output in a separate dir, which depends on the current
219 # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
220 build_topdir = 'build'
221 build_subdir = env['platform']
José Fonseca381e3482008-07-17 11:23:43 +0900222 if env['llvm']:
223 build_subdir += "-llvm"
224 if env['machine'] != 'generic':
225 build_subdir += '-' + env['machine']
226 if env['debug']:
227 build_subdir += "-debug"
228 if env['profile']:
229 build_subdir += "-profile"
230 build_dir = os.path.join(build_topdir, build_subdir)
231 # Place the .sconsign file in the build dir too, to avoid issues with
232 # different scons versions building the same source file
233 env['build'] = build_dir
234 env.SConsignFile(os.path.join(build_dir, '.sconsign'))
José Fonseca18170bb2009-01-23 21:01:16 +0000235 env.CacheDir('build/cache')
José Fonsecab04aa712008-06-06 14:48:57 +0900236
José Fonseca1e8177e2009-02-10 18:11:56 +0000237 # Parallel build
238 if env.GetOption('num_jobs') <= 1:
239 env.SetOption('num_jobs', num_jobs())
240
José Fonseca381e3482008-07-17 11:23:43 +0900241 # C preprocessor options
242 cppdefines = []
243 if debug:
244 cppdefines += ['DEBUG']
245 else:
246 cppdefines += ['NDEBUG']
247 if env['profile']:
248 cppdefines += ['PROFILE']
249 if platform == 'windows':
250 cppdefines += [
251 'WIN32',
252 '_WINDOWS',
José Fonseca42be0102009-01-22 14:26:30 +0000253 #'_UNICODE',
254 #'UNICODE',
José Fonseca129c6ed2008-12-01 11:53:26 -0800255 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
256 ('WINVER', '0x0501'),
José Fonseca381e3482008-07-17 11:23:43 +0900257 # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
258 'WIN32_LEAN_AND_MEAN',
José Fonseca381e3482008-07-17 11:23:43 +0900259 ]
José Fonseca71793e0f2009-04-14 21:39:54 +0100260 if msvc and env['toolchain'] != 'winddk':
José Fonsecab3e03ed2009-03-25 19:32:54 +0000261 cppdefines += [
262 'VC_EXTRALEAN',
263 '_CRT_SECURE_NO_DEPRECATE',
264 ]
José Fonseca381e3482008-07-17 11:23:43 +0900265 if debug:
266 cppdefines += ['_DEBUG']
José Fonseca71793e0f2009-04-14 21:39:54 +0100267 if env['toolchain'] == 'winddk':
José Fonseca381e3482008-07-17 11:23:43 +0900268 # Mimic WINDDK's builtin flags. See also:
269 # - WINDDK's bin/makefile.new i386mk.inc for more info.
270 # - buildchk_wxp_x86.log files, generated by the WINDDK's build
271 # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
José Fonseca71793e0f2009-04-14 21:39:54 +0100272 if machine == 'x86':
273 cppdefines += ['_X86_', 'i386']
274 if machine == 'x86_64':
275 cppdefines += ['_AMD64_', 'AMD64']
276 if platform == 'winddk':
José Fonseca381e3482008-07-17 11:23:43 +0900277 cppdefines += [
José Fonseca381e3482008-07-17 11:23:43 +0900278 'STD_CALL',
279 ('CONDITION_HANDLING', '1'),
280 ('NT_INST', '0'),
281 ('WIN32', '100'),
282 ('_NT1X_', '100'),
283 ('WINNT', '1'),
284 ('_WIN32_WINNT', '0x0501'), # minimum required OS version
285 ('WINVER', '0x0501'),
286 ('_WIN32_IE', '0x0603'),
287 ('WIN32_LEAN_AND_MEAN', '1'),
288 ('DEVL', '1'),
289 ('__BUILDMACHINE__', 'WinDDK'),
290 ('FPO', '0'),
291 ]
292 if debug:
293 cppdefines += [('DBG', 1)]
294 if platform == 'wince':
295 cppdefines += [
296 '_CRT_SECURE_NO_DEPRECATE',
297 '_USE_32BIT_TIME_T',
298 'UNICODE',
299 '_UNICODE',
300 ('UNDER_CE', '600'),
301 ('_WIN32_WCE', '0x600'),
302 'WINCEOEM',
303 'WINCEINTERNAL',
304 'WIN32',
305 'STRICT',
306 'x86',
307 '_X86_',
308 'INTERNATIONAL',
309 ('INTLMSG_CODEPAGE', '1252'),
310 ]
311 if platform == 'windows':
312 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
313 if platform == 'winddk':
314 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
315 if platform == 'wince':
316 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
José Fonseca40b3bb02008-11-04 10:53:02 +0900317 cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
José Fonseca381e3482008-07-17 11:23:43 +0900318 env.Append(CPPDEFINES = cppdefines)
José Fonsecab04aa712008-06-06 14:48:57 +0900319
José Fonseca381e3482008-07-17 11:23:43 +0900320 # C compiler options
321 cflags = []
322 if gcc:
323 if debug:
324 cflags += ['-O0', '-g3']
Keith Whitwell222d7842009-05-07 08:00:42 +0100325 elif env['toolchain'] == 'crossmingw':
326 cflags += ['-O0', '-g3'] # mingw 4.2.1 optimizer is broken
José Fonseca381e3482008-07-17 11:23:43 +0900327 else:
328 cflags += ['-O3', '-g3']
329 if env['profile']:
330 cflags += ['-pg']
331 if env['machine'] == 'x86':
332 cflags += [
333 '-m32',
334 #'-march=pentium4',
335 '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
336 #'-mfpmath=sse',
337 ]
338 if env['machine'] == 'x86_64':
339 cflags += ['-m64']
José Fonseca102cb5c2009-03-13 16:21:30 +0000340 # See also:
341 # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
José Fonseca381e3482008-07-17 11:23:43 +0900342 cflags += [
José Fonseca102cb5c2009-03-13 16:21:30 +0000343 '-Werror=declaration-after-statement',
José Fonseca381e3482008-07-17 11:23:43 +0900344 '-Wall',
345 '-Wmissing-prototypes',
José Fonseca102cb5c2009-03-13 16:21:30 +0000346 '-Wmissing-field-initializers',
347 '-Wpointer-arith',
José Fonseca381e3482008-07-17 11:23:43 +0900348 '-Wno-long-long',
349 '-ffast-math',
José Fonseca47ca0232009-01-14 13:03:09 +0000350 '-std=gnu99',
José Fonseca381e3482008-07-17 11:23:43 +0900351 '-fmessage-length=0', # be nice to Eclipse
352 ]
353 if msvc:
354 # See also:
José Fonsecaa6c72582008-09-01 09:47:40 +0900355 # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
José Fonseca381e3482008-07-17 11:23:43 +0900356 # - cl /?
357 if debug:
358 cflags += [
359 '/Od', # disable optimizations
360 '/Oi', # enable intrinsic functions
361 '/Oy-', # disable frame pointer omission
José Fonseca73ccabc2009-02-12 11:57:45 +0000362 '/GL-', # disable whole program optimization
José Fonseca381e3482008-07-17 11:23:43 +0900363 ]
364 else:
José Fonsecafc7f9242009-06-02 18:41:12 -0700365 if env['machine'] == 'x86_64':
366 cflags += [
367 # Same as /O2, but without global optimizations or auto-inlining
368 # http://msdn.microsoft.com/en-us/library/8f8h5cxt.aspx
369 '/Ob1', # enable inline expansion, disable auto-inlining
370 '/Oi', # enable intrinsic functions
371 '/Ot', # favors fast code
372 '/Oy', # omit frame pointer
373 '/Gs', # enable stack probes
374 '/GF', # eliminate duplicate strings
375 '/Gy', # enable function-level linking
376 ]
377 else:
378 cflags += [
379 '/O2', # optimize for speed
380 ]
José Fonseca381e3482008-07-17 11:23:43 +0900381 cflags += [
José Fonsecafc7f9242009-06-02 18:41:12 -0700382 #'/fp:fast', # fast floating point
José Fonseca381e3482008-07-17 11:23:43 +0900383 ]
384 if env['profile']:
385 cflags += [
386 '/Gh', # enable _penter hook function
387 '/GH', # enable _pexit hook function
388 ]
389 cflags += [
390 '/W3', # warning level
391 #'/Wp64', # enable 64 bit porting warnings
392 ]
José Fonsecaa6c72582008-09-01 09:47:40 +0900393 if env['machine'] == 'x86':
394 cflags += [
395 #'/QIfist', # Suppress _ftol
396 #'/arch:SSE2', # use the SSE2 instructions
397 ]
José Fonseca381e3482008-07-17 11:23:43 +0900398 if platform == 'windows':
399 cflags += [
400 # TODO
401 ]
402 if platform == 'winddk':
403 cflags += [
404 '/Zl', # omit default library name in .OBJ
405 '/Zp8', # 8bytes struct member alignment
406 '/Gy', # separate functions for linker
407 '/Gm-', # disable minimal rebuild
408 '/WX', # treat warnings as errors
409 '/Gz', # __stdcall Calling convention
410 '/GX-', # disable C++ EH
411 '/GR-', # disable C++ RTTI
412 '/GF', # enable read-only string pooling
413 '/G6', # optimize for PPro, P-II, P-III
414 '/Ze', # enable extensions
415 '/Gi-', # disable incremental compilation
416 '/QIfdiv-', # disable Pentium FDIV fix
417 '/hotpatch', # prepares an image for hotpatching.
418 #'/Z7', #enable old-style debug info
419 ]
420 if platform == 'wince':
421 # See also C:\WINCE600\public\common\oak\misc\makefile.def
422 cflags += [
423 '/Zl', # omit default library name in .OBJ
424 '/GF', # enable read-only string pooling
425 '/GR-', # disable C++ RTTI
426 '/GS', # enable security checks
427 # Allow disabling language conformance to maintain backward compat
428 #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
429 #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
430 #'/wd4867',
431 #'/wd4430',
432 #'/MT',
433 #'/U_MT',
434 ]
435 # Automatic pdb generation
436 # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
437 env.EnsureSConsVersion(0, 98, 0)
438 env['PDB'] = '${TARGET.base}.pdb'
439 env.Append(CFLAGS = cflags)
440 env.Append(CXXFLAGS = cflags)
José Fonsecab04aa712008-06-06 14:48:57 +0900441
José Fonseca1781d7f2009-01-06 16:16:38 +0000442 if env['platform'] == 'windows' and msvc:
443 # Choose the appropriate MSVC CRT
444 # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
445 if env['debug']:
446 env.Append(CCFLAGS = ['/MTd'])
447 env.Append(SHCCFLAGS = ['/LDd'])
448 else:
449 env.Append(CCFLAGS = ['/MT'])
450 env.Append(SHCCFLAGS = ['/LD'])
451
José Fonseca381e3482008-07-17 11:23:43 +0900452 # Assembler options
453 if gcc:
454 if env['machine'] == 'x86':
455 env.Append(ASFLAGS = ['-m32'])
456 if env['machine'] == 'x86_64':
457 env.Append(ASFLAGS = ['-m64'])
José Fonseca27d8d6f2008-07-03 12:42:23 +0900458
José Fonseca381e3482008-07-17 11:23:43 +0900459 # Linker options
460 linkflags = []
461 if gcc:
462 if env['machine'] == 'x86':
463 linkflags += ['-m32']
464 if env['machine'] == 'x86_64':
465 linkflags += ['-m64']
José Fonseca6fe421c2009-02-12 12:59:58 +0000466 if platform == 'windows' and msvc:
José Fonseca381e3482008-07-17 11:23:43 +0900467 # See also:
468 # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
469 linkflags += [
José Fonseca73ccabc2009-02-12 11:57:45 +0000470 '/fixed:no',
471 '/incremental:no',
472 ]
473 if platform == 'winddk':
474 linkflags += [
José Fonseca381e3482008-07-17 11:23:43 +0900475 '/merge:_PAGE=PAGE',
476 '/merge:_TEXT=.text',
477 '/section:INIT,d',
478 '/opt:ref',
479 '/opt:icf',
480 '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
481 '/incremental:no',
482 '/fullbuild',
483 '/release',
484 '/nodefaultlib',
485 '/wx',
486 '/debug',
487 '/debugtype:cv',
488 '/version:5.1',
489 '/osversion:5.1',
490 '/functionpadmin:5',
491 '/safeseh',
492 '/pdbcompress',
493 '/stack:0x40000,0x1000',
494 '/driver',
495 '/align:0x80',
496 '/subsystem:native,5.01',
497 '/base:0x10000',
498
499 '/entry:DrvEnableDriver',
500 ]
José Fonseca46728032009-02-18 15:05:23 +0000501 if env['debug'] or env['profile']:
José Fonseca381e3482008-07-17 11:23:43 +0900502 linkflags += [
503 '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
504 ]
505 if platform == 'wince':
506 linkflags += [
507 '/nodefaultlib',
508 #'/incremental:no',
509 #'/fullbuild',
510 '/entry:_DllMainCRTStartup',
511 ]
512 env.Append(LINKFLAGS = linkflags)
513
José Fonsecac76787a2008-07-17 11:25:20 +0900514 # Default libs
515 env.Append(LIBS = [])
516
José Fonseca381e3482008-07-17 11:23:43 +0900517 # Custom builders and methods
518 createConvenienceLibBuilder(env)
519 createCodeGenerateMethod(env)
José Fonseca52c2dd12008-09-08 07:54:15 +0900520 createInstallMethods(env)
José Fonseca381e3482008-07-17 11:23:43 +0900521
522 # for debugging
523 #print env.Dump()
José Fonsecab04aa712008-06-06 14:48:57 +0900524
525
526def exists(env):
José Fonseca381e3482008-07-17 11:23:43 +0900527 return 1