summaryrefslogtreecommitdiffstats
path: root/scons
diff options
context:
space:
mode:
Diffstat (limited to 'scons')
-rw-r--r--scons/crossmingw.py185
-rw-r--r--scons/gallium.py473
-rw-r--r--scons/generic.py551
-rw-r--r--scons/mslib_sa.py49
-rw-r--r--scons/mslink_sa.py211
-rw-r--r--scons/msvc_sa.py173
-rw-r--r--scons/python.py70
-rw-r--r--scons/wcesdk.py176
-rw-r--r--scons/winddk.py130
9 files changed, 2018 insertions, 0 deletions
diff --git a/scons/crossmingw.py b/scons/crossmingw.py
new file mode 100644
index 00000000000..bf81f16fd64
--- /dev/null
+++ b/scons/crossmingw.py
@@ -0,0 +1,185 @@
+"""SCons.Tool.gcc
+
+Tool-specific initialization for MinGW (http://www.mingw.org/)
+
+There normally shouldn't be any need to import this module directly.
+It will usually be imported through the generic SCons.Tool.Tool()
+selection method.
+
+See also http://www.scons.org/wiki/CrossCompilingMingw
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os
+import os.path
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Tool
+import SCons.Util
+
+# This is what we search for to find mingw:
+prefixes = SCons.Util.Split("""
+ mingw32-
+ mingw32msvc-
+ i386-mingw32-
+ i486-mingw32-
+ i586-mingw32-
+ i686-mingw32-
+ i386-mingw32msvc-
+ i486-mingw32msvc-
+ i586-mingw32msvc-
+ i686-mingw32msvc-
+""")
+
+def find(env):
+ for prefix in prefixes:
+ # First search in the SCons path and then the OS path:
+ if env.WhereIs(prefix + 'gcc') or SCons.Util.WhereIs(prefix + 'gcc'):
+ return prefix
+
+ return ''
+
+def shlib_generator(target, source, env, for_signature):
+ cmd = SCons.Util.CLVar(['$SHLINK', '$SHLINKFLAGS'])
+
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ if dll: cmd.extend(['-o', dll])
+
+ cmd.extend(['$SOURCES', '$_LIBDIRFLAGS', '$_LIBFLAGS'])
+
+ implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
+ if implib: cmd.append('-Wl,--out-implib,'+implib.get_string(for_signature))
+
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if def_target: cmd.append('-Wl,--output-def,'+def_target.get_string(for_signature))
+
+ return [cmd]
+
+def shlib_emitter(target, source, env):
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ no_import_lib = env.get('no_import_lib', 0)
+
+ if not dll:
+ raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+
+ if not no_import_lib and \
+ not env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX'):
+
+ # Append an import library to the list of targets.
+ target.append(env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'LIBPREFIX', 'LIBSUFFIX'))
+
+ # Append a def file target if there isn't already a def file target
+ # or a def file source. There is no option to disable def file
+ # target emitting, because I can't figure out why someone would ever
+ # want to turn it off.
+ def_source = env.FindIxes(source, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ def_target = env.FindIxes(target, 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX')
+ if not def_source and not def_target:
+ target.append(env.ReplaceIxes(dll,
+ 'SHLIBPREFIX', 'SHLIBSUFFIX',
+ 'WIN32DEFPREFIX', 'WIN32DEFSUFFIX'))
+
+ return (target, source)
+
+
+shlib_action = SCons.Action.Action(shlib_generator, generator=1)
+
+res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
+
+res_builder = SCons.Builder.Builder(action=res_action, suffix='.o',
+ source_scanner=SCons.Tool.SourceFileScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
+
+def generate(env):
+ mingw_prefix = find(env)
+
+ if mingw_prefix:
+ dir = os.path.dirname(env.WhereIs(mingw_prefix + 'gcc') or SCons.Util.WhereIs(mingw_prefix + 'gcc'))
+
+ # The mingw bin directory must be added to the path:
+ path = env['ENV'].get('PATH', [])
+ if not path:
+ path = []
+ if SCons.Util.is_String(path):
+ path = string.split(path, os.pathsep)
+
+ env['ENV']['PATH'] = string.join([dir] + path, os.pathsep)
+
+ # Most of mingw is the same as gcc and friends...
+ gnu_tools = ['gcc', 'g++', 'gnulink', 'ar', 'gas']
+ for tool in gnu_tools:
+ SCons.Tool.Tool(tool)(env)
+
+ #... but a few things differ:
+ env['CC'] = mingw_prefix + 'gcc'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['CXX'] = mingw_prefix + 'g++'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS -shared')
+ env['SHLINKCOM'] = shlib_action
+ env.Append(SHLIBEMITTER = [shlib_emitter])
+ env['LINK'] = mingw_prefix + 'g++'
+ env['AR'] = mingw_prefix + 'ar'
+ env['RANLIB'] = mingw_prefix + 'ranlib'
+ env['LINK'] = mingw_prefix + 'g++'
+ env['AS'] = mingw_prefix + 'as'
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
+ env['SHOBJSUFFIX'] = '.o'
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+ env['RC'] = mingw_prefix + 'windres'
+ env['RCFLAGS'] = SCons.Util.CLVar('')
+ env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS ${INCPREFIX}${SOURCE.dir} $RCFLAGS -i $SOURCE -o $TARGET'
+ env['BUILDERS']['RES'] = res_builder
+
+ # Some setting from the platform also have to be overridden:
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+ env['PROGPREFIX'] = ''
+ env['PROGSUFFIX'] = '.exe'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = ''
+ env['SHLIBSUFFIX'] = '.dll'
+ env['LIBPREFIXES'] = [ 'lib', '' ]
+ env['LIBSUFFIXES'] = [ '.a', '.lib' ]
+
+ # MinGW port of gdb does not handle well dwarf debug info which is the
+ # default in recent gcc versions
+ env.AppendUnique(CFLAGS = ['-gstabs'])
+
+ env.AppendUnique(LIBS = ['iberty'])
+ env.AppendUnique(SHLINKFLAGS = ['-Wl,--enable-stdcall-fixup'])
+ #env.AppendUnique(SHLINKFLAGS = ['-Wl,--kill-at'])
+
+def exists(env):
+ return find(env)
diff --git a/scons/gallium.py b/scons/gallium.py
new file mode 100644
index 00000000000..065c53c54b2
--- /dev/null
+++ b/scons/gallium.py
@@ -0,0 +1,473 @@
+"""gallium
+
+Frontend-tool for Gallium3D architecture.
+
+"""
+
+#
+# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+import os
+import os.path
+import re
+
+import SCons.Action
+import SCons.Builder
+import SCons.Scanner
+
+
+def quietCommandLines(env):
+ # Quiet command lines
+ # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
+ env['CCCOMSTR'] = "Compiling $SOURCE ..."
+ env['CXXCOMSTR'] = "Compiling $SOURCE ..."
+ env['ARCOMSTR'] = "Archiving $TARGET ..."
+ env['RANLIBCOMSTR'] = ""
+ env['LINKCOMSTR'] = "Linking $TARGET ..."
+
+
+def createConvenienceLibBuilder(env):
+ """This is a utility function that creates the ConvenienceLibrary
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+
+ Based on the stock StaticLibrary and SharedLibrary builders.
+ """
+
+ try:
+ convenience_lib = env['BUILDERS']['ConvenienceLibrary']
+ except KeyError:
+ action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
+ if env.Detect('ranlib'):
+ ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
+ action_list.append(ranlib_action)
+
+ convenience_lib = SCons.Builder.Builder(action = action_list,
+ emitter = '$LIBEMITTER',
+ prefix = '$LIBPREFIX',
+ suffix = '$LIBSUFFIX',
+ src_suffix = '$SHOBJSUFFIX',
+ src_builder = 'SharedObject')
+ env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
+
+ return convenience_lib
+
+
+# TODO: handle import statements with multiple modules
+# TODO: handle from import statements
+import_re = re.compile(r'^import\s+(\S+)$', re.M)
+
+def python_scan(node, env, path):
+ # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
+ contents = node.get_contents()
+ source_dir = node.get_dir()
+ imports = import_re.findall(contents)
+ results = []
+ for imp in imports:
+ for dir in path:
+ file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
+ if os.path.exists(file):
+ results.append(env.File(file))
+ break
+ file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
+ if os.path.exists(file):
+ results.append(env.File(file))
+ break
+ return results
+
+python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
+
+
+def code_generate(env, script, target, source, command):
+ """Method to simplify code generation via python scripts.
+
+ http://www.scons.org/wiki/UsingCodeGenerators
+ http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
+ """
+
+ # We're generating code using Python scripts, so we have to be
+ # careful with our scons elements. This entry represents
+ # the generator file *in the source directory*.
+ script_src = env.File(script).srcnode()
+
+ # This command creates generated code *in the build directory*.
+ command = command.replace('$SCRIPT', script_src.path)
+ code = env.Command(target, source, command)
+
+ # Explicitly mark that the generated code depends on the generator,
+ # and on implicitly imported python modules
+ path = (script_src.get_dir(),)
+ deps = [script_src]
+ deps += script_src.get_implicit_deps(env, python_scanner, path)
+ env.Depends(code, deps)
+
+ # Running the Python script causes .pyc files to be generated in the
+ # source directory. When we clean up, they should go too. So add side
+ # effects for .pyc files
+ for dep in deps:
+ pyc = env.File(str(dep) + 'c')
+ env.SideEffect(pyc, code)
+
+ return code
+
+
+def createCodeGenerateMethod(env):
+ env.Append(SCANNERS = python_scanner)
+ env.AddMethod(code_generate, 'CodeGenerate')
+
+
+def symlink(target, source, env):
+ target = str(target[0])
+ source = str(source[0])
+ if os.path.islink(target) or os.path.exists(target):
+ os.remove(target)
+ os.symlink(os.path.basename(source), target)
+
+def install_shared_library(env, source, version = ()):
+ source = str(source[0])
+ version = tuple(map(str, version))
+ target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
+ target_name = '.'.join((str(source),) + version)
+ last = env.InstallAs(os.path.join(target_dir, target_name), source)
+ while len(version):
+ version = version[:-1]
+ target_name = '.'.join((str(source),) + version)
+ action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+ last = env.Command(os.path.join(target_dir, target_name), last, action)
+
+def createInstallMethods(env):
+ env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
+def generate(env):
+ """Common environment generation code"""
+
+ # FIXME: this is already too late
+ #if env.get('quiet', False):
+ # quietCommandLines(env)
+
+ # Toolchain
+ platform = env['platform']
+ if env['toolchain'] == 'default':
+ if platform == 'winddk':
+ env['toolchain'] = 'winddk'
+ elif platform == 'wince':
+ env['toolchain'] = 'wcesdk'
+ env.Tool(env['toolchain'])
+
+ # shortcuts
+ debug = env['debug']
+ machine = env['machine']
+ platform = env['platform']
+ x86 = env['machine'] == 'x86'
+ ppc = env['machine'] == 'ppc'
+ gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw'
+ msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw'
+
+ # Put build output in a separate dir, which depends on the current
+ # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
+ build_topdir = 'build'
+ build_subdir = env['platform']
+ if env['llvm']:
+ build_subdir += "-llvm"
+ if env['machine'] != 'generic':
+ build_subdir += '-' + env['machine']
+ if env['debug']:
+ build_subdir += "-debug"
+ if env['profile']:
+ build_subdir += "-profile"
+ build_dir = os.path.join(build_topdir, build_subdir)
+ # Place the .sconsign file in the build dir too, to avoid issues with
+ # different scons versions building the same source file
+ env['build'] = build_dir
+ env.SConsignFile(os.path.join(build_dir, '.sconsign'))
+ env.CacheDir('build/cache')
+
+ # C preprocessor options
+ cppdefines = []
+ if debug:
+ cppdefines += ['DEBUG']
+ else:
+ cppdefines += ['NDEBUG']
+ if env['profile']:
+ cppdefines += ['PROFILE']
+ if platform == 'windows':
+ cppdefines += [
+ 'WIN32',
+ '_WINDOWS',
+ #'_UNICODE',
+ #'UNICODE',
+ ('_WIN32_WINNT', '0x0501'), # minimum required OS version
+ ('WINVER', '0x0501'),
+ # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
+ 'WIN32_LEAN_AND_MEAN',
+ 'VC_EXTRALEAN',
+ '_CRT_SECURE_NO_DEPRECATE',
+ ]
+ if debug:
+ cppdefines += ['_DEBUG']
+ if platform == 'winddk':
+ # Mimic WINDDK's builtin flags. See also:
+ # - WINDDK's bin/makefile.new i386mk.inc for more info.
+ # - buildchk_wxp_x86.log files, generated by the WINDDK's build
+ # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
+ cppdefines += [
+ ('_X86_', '1'),
+ ('i386', '1'),
+ 'STD_CALL',
+ ('CONDITION_HANDLING', '1'),
+ ('NT_INST', '0'),
+ ('WIN32', '100'),
+ ('_NT1X_', '100'),
+ ('WINNT', '1'),
+ ('_WIN32_WINNT', '0x0501'), # minimum required OS version
+ ('WINVER', '0x0501'),
+ ('_WIN32_IE', '0x0603'),
+ ('WIN32_LEAN_AND_MEAN', '1'),
+ ('DEVL', '1'),
+ ('__BUILDMACHINE__', 'WinDDK'),
+ ('FPO', '0'),
+ ]
+ if debug:
+ cppdefines += [('DBG', 1)]
+ if platform == 'wince':
+ cppdefines += [
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_USE_32BIT_TIME_T',
+ 'UNICODE',
+ '_UNICODE',
+ ('UNDER_CE', '600'),
+ ('_WIN32_WCE', '0x600'),
+ 'WINCEOEM',
+ 'WINCEINTERNAL',
+ 'WIN32',
+ 'STRICT',
+ 'x86',
+ '_X86_',
+ 'INTERNATIONAL',
+ ('INTLMSG_CODEPAGE', '1252'),
+ ]
+ if platform == 'windows':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_USER']
+ if platform == 'winddk':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_DISPLAY']
+ if platform == 'wince':
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE']
+ cppdefines += ['PIPE_SUBSYSTEM_WINDOWS_CE_OGL']
+ env.Append(CPPDEFINES = cppdefines)
+
+ # C preprocessor includes
+ if platform == 'winddk':
+ env.Append(CPPPATH = [
+ env['SDK_INC_PATH'],
+ env['DDK_INC_PATH'],
+ env['WDM_INC_PATH'],
+ env['CRT_INC_PATH'],
+ ])
+
+ # C compiler options
+ cflags = []
+ if gcc:
+ if debug:
+ cflags += ['-O0', '-g3']
+ else:
+ cflags += ['-O3', '-g3']
+ if env['profile']:
+ cflags += ['-pg']
+ if env['machine'] == 'x86':
+ cflags += [
+ '-m32',
+ #'-march=pentium4',
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ #'-mfpmath=sse',
+ ]
+ if env['machine'] == 'x86_64':
+ cflags += ['-m64']
+ cflags += [
+ '-Wall',
+ '-Wmissing-prototypes',
+ '-Wno-long-long',
+ '-ffast-math',
+ '-std=gnu99',
+ '-fmessage-length=0', # be nice to Eclipse
+ ]
+ if msvc:
+ # See also:
+ # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
+ # - cl /?
+ if debug:
+ cflags += [
+ '/Od', # disable optimizations
+ '/Oi', # enable intrinsic functions
+ '/Oy-', # disable frame pointer omission
+ ]
+ else:
+ cflags += [
+ '/Ox', # maximum optimizations
+ '/Oi', # enable intrinsic functions
+ '/Ot', # favor code speed
+ #'/fp:fast', # fast floating point
+ ]
+ if env['profile']:
+ cflags += [
+ '/Gh', # enable _penter hook function
+ '/GH', # enable _pexit hook function
+ ]
+ cflags += [
+ '/W3', # warning level
+ #'/Wp64', # enable 64 bit porting warnings
+ ]
+ if env['machine'] == 'x86':
+ cflags += [
+ #'/QIfist', # Suppress _ftol
+ #'/arch:SSE2', # use the SSE2 instructions
+ ]
+ if platform == 'windows':
+ cflags += [
+ # TODO
+ ]
+ if platform == 'winddk':
+ cflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/Zp8', # 8bytes struct member alignment
+ '/Gy', # separate functions for linker
+ '/Gm-', # disable minimal rebuild
+ '/WX', # treat warnings as errors
+ '/Gz', # __stdcall Calling convention
+ '/GX-', # disable C++ EH
+ '/GR-', # disable C++ RTTI
+ '/GF', # enable read-only string pooling
+ '/G6', # optimize for PPro, P-II, P-III
+ '/Ze', # enable extensions
+ '/Gi-', # disable incremental compilation
+ '/QIfdiv-', # disable Pentium FDIV fix
+ '/hotpatch', # prepares an image for hotpatching.
+ #'/Z7', #enable old-style debug info
+ ]
+ if platform == 'wince':
+ # See also C:\WINCE600\public\common\oak\misc\makefile.def
+ cflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/GF', # enable read-only string pooling
+ '/GR-', # disable C++ RTTI
+ '/GS', # enable security checks
+ # Allow disabling language conformance to maintain backward compat
+ #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
+ #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
+ #'/wd4867',
+ #'/wd4430',
+ #'/MT',
+ #'/U_MT',
+ ]
+ # Automatic pdb generation
+ # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
+ env.EnsureSConsVersion(0, 98, 0)
+ env['PDB'] = '${TARGET.base}.pdb'
+ env.Append(CFLAGS = cflags)
+ env.Append(CXXFLAGS = cflags)
+
+ if env['platform'] == 'windows' and msvc:
+ # Choose the appropriate MSVC CRT
+ # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
+ if env['debug']:
+ env.Append(CCFLAGS = ['/MTd'])
+ env.Append(SHCCFLAGS = ['/LDd'])
+ else:
+ env.Append(CCFLAGS = ['/MT'])
+ env.Append(SHCCFLAGS = ['/LD'])
+
+ # Assembler options
+ if gcc:
+ if env['machine'] == 'x86':
+ env.Append(ASFLAGS = ['-m32'])
+ if env['machine'] == 'x86_64':
+ env.Append(ASFLAGS = ['-m64'])
+
+ # Linker options
+ linkflags = []
+ if gcc:
+ if env['machine'] == 'x86':
+ linkflags += ['-m32']
+ if env['machine'] == 'x86_64':
+ linkflags += ['-m64']
+ if platform == 'winddk':
+ # See also:
+ # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+ linkflags += [
+ '/merge:_PAGE=PAGE',
+ '/merge:_TEXT=.text',
+ '/section:INIT,d',
+ '/opt:ref',
+ '/opt:icf',
+ '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
+ '/incremental:no',
+ '/fullbuild',
+ '/release',
+ '/nodefaultlib',
+ '/wx',
+ '/debug',
+ '/debugtype:cv',
+ '/version:5.1',
+ '/osversion:5.1',
+ '/functionpadmin:5',
+ '/safeseh',
+ '/pdbcompress',
+ '/stack:0x40000,0x1000',
+ '/driver',
+ '/align:0x80',
+ '/subsystem:native,5.01',
+ '/base:0x10000',
+
+ '/entry:DrvEnableDriver',
+ ]
+ if env['profile']:
+ linkflags += [
+ '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
+ ]
+ if platform == 'wince':
+ linkflags += [
+ '/nodefaultlib',
+ #'/incremental:no',
+ #'/fullbuild',
+ '/entry:_DllMainCRTStartup',
+ ]
+ env.Append(LINKFLAGS = linkflags)
+
+ # Default libs
+ env.Append(LIBS = [])
+
+ # Custom builders and methods
+ createConvenienceLibBuilder(env)
+ createCodeGenerateMethod(env)
+ createInstallMethods(env)
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/scons/generic.py b/scons/generic.py
new file mode 100644
index 00000000000..05f7356b762
--- /dev/null
+++ b/scons/generic.py
@@ -0,0 +1,551 @@
+"""generic
+
+Generic tool that provides a commmon ground for all platforms.
+
+"""
+
+#
+# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+import os
+import os.path
+import re
+import platform as _platform
+import sys
+
+import SCons.Action
+import SCons.Builder
+import SCons.Scanner
+
+
+def quietCommandLines(env):
+ # Quiet command lines
+ # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
+ env['CCCOMSTR'] = "Compiling $SOURCE ..."
+ env['CXXCOMSTR'] = "Compiling $SOURCE ..."
+ env['ARCOMSTR'] = "Archiving $TARGET ..."
+ env['RANLIBCOMSTR'] = ""
+ env['LINKCOMSTR'] = "Linking $TARGET ..."
+
+
+def createConvenienceLibBuilder(env):
+ """This is a utility function that creates the ConvenienceLibrary
+ Builder in an Environment if it is not there already.
+
+ If it is already there, we return the existing one.
+
+ Based on the stock StaticLibrary and SharedLibrary builders.
+ """
+
+ try:
+ convenience_lib = env['BUILDERS']['ConvenienceLibrary']
+ except KeyError:
+ action_list = [ SCons.Action.Action("$ARCOM", "$ARCOMSTR") ]
+ if env.Detect('ranlib'):
+ ranlib_action = SCons.Action.Action("$RANLIBCOM", "$RANLIBCOMSTR")
+ action_list.append(ranlib_action)
+
+ convenience_lib = SCons.Builder.Builder(action = action_list,
+ emitter = '$LIBEMITTER',
+ prefix = '$LIBPREFIX',
+ suffix = '$LIBSUFFIX',
+ src_suffix = '$SHOBJSUFFIX',
+ src_builder = 'SharedObject')
+ env['BUILDERS']['ConvenienceLibrary'] = convenience_lib
+
+ return convenience_lib
+
+
+# TODO: handle import statements with multiple modules
+# TODO: handle from import statements
+import_re = re.compile(r'^import\s+(\S+)$', re.M)
+
+def python_scan(node, env, path):
+ # http://www.scons.org/doc/0.98.5/HTML/scons-user/c2781.html#AEN2789
+ contents = node.get_contents()
+ source_dir = node.get_dir()
+ imports = import_re.findall(contents)
+ results = []
+ for imp in imports:
+ for dir in path:
+ file = os.path.join(str(dir), imp.replace('.', os.sep) + '.py')
+ if os.path.exists(file):
+ results.append(env.File(file))
+ break
+ file = os.path.join(str(dir), imp.replace('.', os.sep), '__init__.py')
+ if os.path.exists(file):
+ results.append(env.File(file))
+ break
+ return results
+
+python_scanner = SCons.Scanner.Scanner(function = python_scan, skeys = ['.py'])
+
+
+def code_generate(env, script, target, source, command):
+ """Method to simplify code generation via python scripts.
+
+ http://www.scons.org/wiki/UsingCodeGenerators
+ http://www.scons.org/doc/0.98.5/HTML/scons-user/c2768.html
+ """
+
+ # We're generating code using Python scripts, so we have to be
+ # careful with our scons elements. This entry represents
+ # the generator file *in the source directory*.
+ script_src = env.File(script).srcnode()
+
+ # This command creates generated code *in the build directory*.
+ command = command.replace('$SCRIPT', script_src.path)
+ code = env.Command(target, source, command)
+
+ # Explicitly mark that the generated code depends on the generator,
+ # and on implicitly imported python modules
+ path = (script_src.get_dir(),)
+ deps = [script_src]
+ deps += script_src.get_implicit_deps(env, python_scanner, path)
+ env.Depends(code, deps)
+
+ # Running the Python script causes .pyc files to be generated in the
+ # source directory. When we clean up, they should go too. So add side
+ # effects for .pyc files
+ for dep in deps:
+ pyc = env.File(str(dep) + 'c')
+ env.SideEffect(pyc, code)
+
+ return code
+
+
+def createCodeGenerateMethod(env):
+ env.Append(SCANNERS = python_scanner)
+ env.AddMethod(code_generate, 'CodeGenerate')
+
+
+def symlink(target, source, env):
+ target = str(target[0])
+ source = str(source[0])
+ if os.path.islink(target) or os.path.exists(target):
+ os.remove(target)
+ os.symlink(os.path.basename(source), target)
+
+def install_shared_library(env, source, version = ()):
+ source = str(source[0])
+ version = tuple(map(str, version))
+ target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build'], 'lib')
+ target_name = '.'.join((str(source),) + version)
+ last = env.InstallAs(os.path.join(target_dir, target_name), source)
+ while len(version):
+ version = version[:-1]
+ target_name = '.'.join((str(source),) + version)
+ action = SCons.Action.Action(symlink, "$TARGET -> $SOURCE")
+ last = env.Command(os.path.join(target_dir, target_name), last, action)
+
+def createInstallMethods(env):
+ env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
+_platform_map = {
+ 'linux2': 'linux',
+ 'win32': 'windows',
+}
+
+
+_machine_map = {
+ 'x86': 'x86',
+ 'i386': 'x86',
+ 'i486': 'x86',
+ 'i586': 'x86',
+ 'i686': 'x86',
+ 'ppc': 'ppc',
+ 'x86_64': 'x86_64',
+}
+
+
+_toolchain_map = {
+ 'winddk': 'winddk',
+ 'wince': 'wcesdk',
+}
+
+
+_bool_map = {
+ 'y': 1,
+ 'yes': 1,
+ 't': 1,
+ 'true': 1,
+ '1': 1,
+ 'on': 1,
+ 'all': 1,
+ 'n': 0,
+ 'no': 0,
+ 'f': 0,
+ 'false': 0,
+ '0': 0,
+ 'off': 0,
+ 'none': 0,
+}
+
+
+def generate(env):
+ """Common environment generation code"""
+
+ from SCons.Script import ARGUMENTS
+
+ # FIXME: this is already too late
+ #if env.get('quiet', False):
+ # quietCommandLines(env)
+
+
+ # Platform
+ try:
+ env['platform'] = ARGUMENTS['platform']
+ except KeyError:
+ env['platform'] = _platform_map.get(sys.platform, sys.platform)
+
+ # Machine
+ try:
+ env['machine'] = ARGUMENTS['machine']
+ except KeyError:
+ env['machine'] = _machine_map.get(os.environ.get('PROCESSOR_ARCHITECTURE', _platform.machine()), 'generic')
+
+ # Toolchain
+ try:
+ env['toolchain'] = ARGUMENTS['toolchain']
+ except KeyError:
+ if env['platform'] in ('windows', 'winddk', 'wince') and sys.platform != 'win32':
+ env['toolchain'] = 'crossmingw'
+ else:
+ env['toolchain'] = _toolchain_map.get(env['platform'], 'default')
+ if env['toolchain'] == 'crossmingw' and env['machine'] not in ('generic', 'x86'):
+ env['machine'] = 'x86'
+
+ try:
+ env['MSVS_VERSION'] = ARGUMENTS['MSVS_VERSION']
+ except KeyError:
+ pass
+
+ # Build type
+ env['debug'] = _bool_map[ARGUMENTS.get('debug', 'no')]
+ env['profile'] = _bool_map[ARGUMENTS.get('profile', 'no')]
+
+ # Put build output in a separate dir, which depends on the current
+ # configuration. See also http://www.scons.org/wiki/AdvancedBuildExample
+ try:
+ env['build'] = ARGUMENTS['build']
+ except KeyError:
+ build_topdir = 'build'
+ build_subdir = env['platform']
+ if env['machine'] != 'generic':
+ build_subdir += '-' + env['machine']
+ if env['debug']:
+ build_subdir += "-debug"
+ if env['profile']:
+ build_subdir += "-profile"
+ env['build'] = os.path.join(build_topdir, build_subdir)
+ # Place the .sconsign file in the build dir too, to avoid issues with
+ # different scons versions building the same source file
+ env.SConsignFile(os.path.join(env['build'], '.sconsign'))
+
+ # Summary
+ print
+ print ' platform=%s' % env['platform']
+ print ' machine=%s' % env['machine']
+ print ' toolchain=%s' % env['toolchain']
+ print ' debug=%s' % ['no', 'yes'][env['debug']]
+ print ' profile=%s' % ['no', 'yes'][env['profile']]
+ print ' build=%s' % env['build']
+ print
+
+ # Load tool chain
+ env.Tool(env['toolchain'])
+
+ # shortcuts
+ debug = env['debug']
+ machine = env['machine']
+ platform = env['platform']
+ x86 = env['machine'] == 'x86'
+ ppc = env['machine'] == 'ppc'
+ gcc = env['platform'] in ('linux', 'freebsd', 'darwin') or env['toolchain'] == 'crossmingw'
+ msvc = env['platform'] in ('windows', 'winddk', 'wince') and env['toolchain'] != 'crossmingw'
+
+ # C preprocessor options
+ cppdefines = []
+ if debug:
+ cppdefines += ['DEBUG']
+ else:
+ cppdefines += ['NDEBUG']
+ if env['profile']:
+ cppdefines += ['PROFILE']
+ if platform == 'windows':
+ cppdefines += [
+ 'WIN32',
+ '_WINDOWS',
+ #'_UNICODE',
+ #'UNICODE',
+ # http://msdn2.microsoft.com/en-us/library/6dwk3a1z.aspx,
+ #'WIN32_LEAN_AND_MEAN',
+ 'VC_EXTRALEAN',
+ '_CRT_SECURE_NO_DEPRECATE',
+ ]
+ if debug:
+ cppdefines += ['_DEBUG']
+ if platform == 'winddk':
+ # Mimic WINDDK's builtin flags. See also:
+ # - WINDDK's bin/makefile.new i386mk.inc for more info.
+ # - buildchk_wxp_x86.log files, generated by the WINDDK's build
+ # - http://alter.org.ua/docs/nt_kernel/vc8_proj/
+ cppdefines += [
+ ('_X86_', '1'),
+ ('i386', '1'),
+ 'STD_CALL',
+ ('CONDITION_HANDLING', '1'),
+ ('NT_INST', '0'),
+ ('WIN32', '100'),
+ ('_NT1X_', '100'),
+ ('WINNT', '1'),
+ ('_WIN32_WINNT', '0x0501'), # minimum required OS version
+ ('WINVER', '0x0501'),
+ ('_WIN32_IE', '0x0603'),
+ ('WIN32_LEAN_AND_MEAN', '1'),
+ ('DEVL', '1'),
+ ('__BUILDMACHINE__', 'WinDDK'),
+ ('FPO', '0'),
+ ]
+ if debug:
+ cppdefines += [('DBG', 1)]
+ if platform == 'wince':
+ cppdefines += [
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_USE_32BIT_TIME_T',
+ 'UNICODE',
+ '_UNICODE',
+ ('UNDER_CE', '600'),
+ ('_WIN32_WCE', '0x600'),
+ 'WINCEOEM',
+ 'WINCEINTERNAL',
+ 'WIN32',
+ 'STRICT',
+ 'x86',
+ '_X86_',
+ 'INTERNATIONAL',
+ ('INTLMSG_CODEPAGE', '1252'),
+ ]
+ env.Append(CPPDEFINES = cppdefines)
+
+ # C preprocessor includes
+ if platform == 'winddk':
+ env.Append(CPPPATH = [
+ env['SDK_INC_PATH'],
+ env['DDK_INC_PATH'],
+ env['WDM_INC_PATH'],
+ env['CRT_INC_PATH'],
+ ])
+
+ # C compiler options
+ cflags = [] # C
+ cxxflags = [] # C++
+ ccflags = [] # C & C++
+ if gcc:
+ if debug:
+ ccflags += ['-O0', '-g3']
+ else:
+ ccflags += ['-O3', '-g0']
+ if env['profile']:
+ ccflags += ['-pg']
+ if env['machine'] == 'x86':
+ ccflags += [
+ '-m32',
+ #'-march=pentium4',
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ #'-mfpmath=sse',
+ ]
+ if env['machine'] == 'x86_64':
+ ccflags += ['-m64']
+ ccflags += [
+ '-Wall',
+ '-Wmissing-prototypes',
+ '-Wno-long-long',
+ '-ffast-math',
+ '-pedantic',
+ '-fmessage-length=0', # be nice to Eclipse
+ ]
+ cflags += [
+ '-Wmissing-prototypes',
+ ]
+ if msvc:
+ # See also:
+ # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
+ # - cl /?
+ if debug:
+ ccflags += [
+ '/Od', # disable optimizations
+ '/Oi', # enable intrinsic functions
+ '/Oy-', # disable frame pointer omission
+ ]
+ else:
+ ccflags += [
+ '/Ox', # maximum optimizations
+ '/Oi', # enable intrinsic functions
+ '/Ot', # favor code speed
+ #'/fp:fast', # fast floating point
+ ]
+ if env['profile']:
+ ccflags += [
+ '/Gh', # enable _penter hook function
+ '/GH', # enable _pexit hook function
+ ]
+ ccflags += [
+ '/W3', # warning level
+ #'/Wp64', # enable 64 bit porting warnings
+ ]
+ if env['machine'] == 'x86':
+ ccflags += [
+ #'/QIfist', # Suppress _ftol
+ #'/arch:SSE2', # use the SSE2 instructions
+ ]
+ if platform == 'windows':
+ ccflags += [
+ # TODO
+ ]
+ if platform == 'winddk':
+ ccflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/Zp8', # 8bytes struct member alignment
+ '/Gy', # separate functions for linker
+ '/Gm-', # disable minimal rebuild
+ '/WX', # treat warnings as errors
+ '/Gz', # __stdcall Calling convention
+ '/GX-', # disable C++ EH
+ '/GR-', # disable C++ RTTI
+ '/GF', # enable read-only string pooling
+ '/G6', # optimize for PPro, P-II, P-III
+ '/Ze', # enable extensions
+ '/Gi-', # disable incremental compilation
+ '/QIfdiv-', # disable Pentium FDIV fix
+ '/hotpatch', # prepares an image for hotpatching.
+ #'/Z7', #enable old-style debug info
+ ]
+ if platform == 'wince':
+ # See also C:\WINCE600\public\common\oak\misc\makefile.def
+ ccflags += [
+ '/Zl', # omit default library name in .OBJ
+ '/GF', # enable read-only string pooling
+ '/GR-', # disable C++ RTTI
+ '/GS', # enable security checks
+ # Allow disabling language conformance to maintain backward compat
+ #'/Zc:wchar_t-', # don't force wchar_t as native type, instead of typedef
+ #'/Zc:forScope-', # don't enforce Standard C++ for scoping rules
+ #'/wd4867',
+ #'/wd4430',
+ #'/MT',
+ #'/U_MT',
+ ]
+ # Automatic pdb generation
+ # See http://scons.tigris.org/issues/show_bug.cgi?id=1656
+ env.EnsureSConsVersion(0, 98, 0)
+ env['PDB'] = '${TARGET.base}.pdb'
+ env.Append(CCFLAGS = ccflags)
+ env.Append(CFLAGS = cflags)
+ env.Append(CXXFLAGS = cxxflags)
+
+ if env['platform'] == 'windows' and msvc:
+ # Choose the appropriate MSVC CRT
+ # http://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
+ if env['debug']:
+ env.Append(CCFLAGS = ['/MTd'])
+ env.Append(SHCCFLAGS = ['/LDd'])
+ else:
+ env.Append(CCFLAGS = ['/MT'])
+ env.Append(SHCCFLAGS = ['/LD'])
+
+ # Assembler options
+ if gcc:
+ if env['machine'] == 'x86':
+ env.Append(ASFLAGS = ['-m32'])
+ if env['machine'] == 'x86_64':
+ env.Append(ASFLAGS = ['-m64'])
+
+ # Linker options
+ linkflags = []
+ if gcc:
+ if env['machine'] == 'x86':
+ linkflags += ['-m32']
+ if env['machine'] == 'x86_64':
+ linkflags += ['-m64']
+ if platform == 'winddk':
+ # See also:
+ # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+ linkflags += [
+ '/merge:_PAGE=PAGE',
+ '/merge:_TEXT=.text',
+ '/section:INIT,d',
+ '/opt:ref',
+ '/opt:icf',
+ '/ignore:4198,4010,4037,4039,4065,4070,4078,4087,4089,4221',
+ '/incremental:no',
+ '/fullbuild',
+ '/release',
+ '/nodefaultlib',
+ '/wx',
+ '/debug',
+ '/debugtype:cv',
+ '/version:5.1',
+ '/osversion:5.1',
+ '/functionpadmin:5',
+ '/safeseh',
+ '/pdbcompress',
+ '/stack:0x40000,0x1000',
+ '/driver',
+ '/align:0x80',
+ '/subsystem:native,5.01',
+ '/base:0x10000',
+
+ '/entry:DrvEnableDriver',
+ ]
+ if env['profile']:
+ linkflags += [
+ '/MAP', # http://msdn.microsoft.com/en-us/library/k7xkk3e2.aspx
+ ]
+ if platform == 'wince':
+ linkflags += [
+ '/nodefaultlib',
+ #'/incremental:no',
+ #'/fullbuild',
+ '/entry:_DllMainCRTStartup',
+ ]
+ env.Append(LINKFLAGS = linkflags)
+
+ # Default libs
+ env.Append(LIBS = [])
+
+ # Custom builders and methods
+ createConvenienceLibBuilder(env)
+ createCodeGenerateMethod(env)
+ createInstallMethods(env)
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/scons/mslib_sa.py b/scons/mslib_sa.py
new file mode 100644
index 00000000000..da51c574b62
--- /dev/null
+++ b/scons/mslib_sa.py
@@ -0,0 +1,49 @@
+"""mslib_sa
+
+Tool-specific initialization for lib (MicroSoft library archiver).
+
+Based on SCons.Tool.mslib, without the MSVC detection.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+
+def generate(env):
+ """Add Builders and construction variables for lib to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ env['AR'] = 'lib'
+ env['ARFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['ARCOM'] = "${TEMPFILE('$AR $ARFLAGS /OUT:$TARGET $SOURCES')}"
+ env['LIBPREFIX'] = ''
+ env['LIBSUFFIX'] = '.lib'
+
+def exists(env):
+ return env.Detect('lib')
+
+# vim:set ts=4 sw=4 et:
diff --git a/scons/mslink_sa.py b/scons/mslink_sa.py
new file mode 100644
index 00000000000..53331def1aa
--- /dev/null
+++ b/scons/mslink_sa.py
@@ -0,0 +1,211 @@
+"""mslink_sa
+
+Tool-specific initialization for the Microsoft linker.
+
+Based on SCons.Tool.mslink, without the MSVS detection.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os.path
+
+import SCons.Action
+import SCons.Defaults
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Tool.msvc
+import SCons.Util
+
+def pdbGenerator(env, target, source, for_signature):
+ try:
+ return ['/PDB:%s' % target[0].attributes.pdb, '/DEBUG']
+ except (AttributeError, IndexError):
+ return None
+
+def windowsShlinkTargets(target, source, env, for_signature):
+ listCmd = []
+ dll = env.FindIxes(target, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ if dll: listCmd.append("/out:%s"%dll.get_string(for_signature))
+
+ implib = env.FindIxes(target, 'LIBPREFIX', 'LIBSUFFIX')
+ if implib: listCmd.append("/implib:%s"%implib.get_string(for_signature))
+
+ return listCmd
+
+def windowsShlinkSources(target, source, env, for_signature):
+ listCmd = []
+
+ deffile = env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX")
+ for src in source:
+ if src == deffile:
+ # Treat this source as a .def file.
+ listCmd.append("/def:%s" % src.get_string(for_signature))
+ else:
+ # Just treat it as a generic source file.
+ listCmd.append(src)
+ return listCmd
+
+def windowsLibEmitter(target, source, env):
+ SCons.Tool.msvc.validate_vars(env)
+
+ extratargets = []
+ extrasources = []
+
+ dll = env.FindIxes(target, "SHLIBPREFIX", "SHLIBSUFFIX")
+ no_import_lib = env.get('no_import_lib', 0)
+
+ if not dll:
+ raise SCons.Errors.UserError, "A shared library should have exactly one target with the suffix: %s" % env.subst("$SHLIBSUFFIX")
+
+ insert_def = env.subst("$WINDOWS_INSERT_DEF")
+ if not insert_def in ['', '0', 0] and \
+ not env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"):
+
+ # append a def file to the list of sources
+ extrasources.append(
+ env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX"))
+
+ if env.has_key('PDB') and env['PDB']:
+ pdb = env.arg2nodes('$PDB', target=target, source=source)[0]
+ extratargets.append(pdb)
+ target[0].attributes.pdb = pdb
+
+ if not no_import_lib and \
+ not env.FindIxes(target, "LIBPREFIX", "LIBSUFFIX"):
+ # Append an import library to the list of targets.
+ extratargets.append(
+ env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "LIBPREFIX", "LIBSUFFIX"))
+ # and .exp file is created if there are exports from a DLL
+ extratargets.append(
+ env.ReplaceIxes(dll,
+ "SHLIBPREFIX", "SHLIBSUFFIX",
+ "WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX"))
+
+ return (target+extratargets, source+extrasources)
+
+def prog_emitter(target, source, env):
+ SCons.Tool.msvc.validate_vars(env)
+
+ extratargets = []
+
+ exe = env.FindIxes(target, "PROGPREFIX", "PROGSUFFIX")
+ if not exe:
+ raise SCons.Errors.UserError, "An executable should have exactly one target with the suffix: %s" % env.subst("$PROGSUFFIX")
+
+ if env.has_key('PDB') and env['PDB']:
+ pdb = env.arg2nodes('$PDB', target=target, source=source)[0]
+ extratargets.append(pdb)
+ target[0].attributes.pdb = pdb
+
+ return (target+extratargets,source)
+
+def RegServerFunc(target, source, env):
+ if env.has_key('register') and env['register']:
+ ret = regServerAction([target[0]], [source[0]], env)
+ if ret:
+ raise SCons.Errors.UserError, "Unable to register %s" % target[0]
+ else:
+ print "Registered %s sucessfully" % target[0]
+ return ret
+ return 0
+
+regServerAction = SCons.Action.Action("$REGSVRCOM", "$REGSVRCOMSTR")
+regServerCheck = SCons.Action.Action(RegServerFunc, None)
+shlibLinkAction = SCons.Action.Action('${TEMPFILE("$SHLINK $SHLINKFLAGS $_SHLINK_TARGETS $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $_SHLINK_SOURCES")}')
+compositeLinkAction = shlibLinkAction + regServerCheck
+
+def generate(env):
+ """Add Builders and construction variables for ar to an Environment."""
+ SCons.Tool.createSharedLibBuilder(env)
+ SCons.Tool.createProgBuilder(env)
+
+ env['SHLINK'] = '$LINK'
+ env['SHLINKFLAGS'] = SCons.Util.CLVar('$LINKFLAGS /dll')
+ env['_SHLINK_TARGETS'] = windowsShlinkTargets
+ env['_SHLINK_SOURCES'] = windowsShlinkSources
+ env['SHLINKCOM'] = compositeLinkAction
+ env.Append(SHLIBEMITTER = [windowsLibEmitter])
+ env['LINK'] = 'link'
+ env['LINKFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['_PDB'] = pdbGenerator
+ env['LINKCOM'] = '${TEMPFILE("$LINK $LINKFLAGS /OUT:$TARGET.windows $( $_LIBDIRFLAGS $) $_LIBFLAGS $_PDB $SOURCES.windows")}'
+ env.Append(PROGEMITTER = [prog_emitter])
+ env['LIBDIRPREFIX']='/LIBPATH:'
+ env['LIBDIRSUFFIX']=''
+ env['LIBLINKPREFIX']=''
+ env['LIBLINKSUFFIX']='$LIBSUFFIX'
+
+ env['WIN32DEFPREFIX'] = ''
+ env['WIN32DEFSUFFIX'] = '.def'
+ env['WIN32_INSERT_DEF'] = 0
+ env['WINDOWSDEFPREFIX'] = '${WIN32DEFPREFIX}'
+ env['WINDOWSDEFSUFFIX'] = '${WIN32DEFSUFFIX}'
+ env['WINDOWS_INSERT_DEF'] = '${WIN32_INSERT_DEF}'
+
+ env['WIN32EXPPREFIX'] = ''
+ env['WIN32EXPSUFFIX'] = '.exp'
+ env['WINDOWSEXPPREFIX'] = '${WIN32EXPPREFIX}'
+ env['WINDOWSEXPSUFFIX'] = '${WIN32EXPSUFFIX}'
+
+ env['WINDOWSSHLIBMANIFESTPREFIX'] = ''
+ env['WINDOWSSHLIBMANIFESTSUFFIX'] = '${SHLIBSUFFIX}.manifest'
+ env['WINDOWSPROGMANIFESTPREFIX'] = ''
+ env['WINDOWSPROGMANIFESTSUFFIX'] = '${PROGSUFFIX}.manifest'
+
+ env['REGSVRACTION'] = regServerCheck
+ env['REGSVR'] = os.path.join(SCons.Platform.win32.get_system_root(),'System32','regsvr32')
+ env['REGSVRFLAGS'] = '/s '
+ env['REGSVRCOM'] = '$REGSVR $REGSVRFLAGS ${TARGET.windows}'
+
+ # For most platforms, a loadable module is the same as a shared
+ # library. Platforms which are different can override these, but
+ # setting them the same means that LoadableModule works everywhere.
+ SCons.Tool.createLoadableModuleBuilder(env)
+ env['LDMODULE'] = '$SHLINK'
+ env['LDMODULEPREFIX'] = '$SHLIBPREFIX'
+ env['LDMODULESUFFIX'] = '$SHLIBSUFFIX'
+ env['LDMODULEFLAGS'] = '$SHLINKFLAGS'
+ # We can't use '$SHLINKCOM' here because that will stringify the
+ # action list on expansion, and will then try to execute expanded
+ # strings, with the upshot that it would try to execute RegServerFunc
+ # as a command.
+ env['LDMODULECOM'] = compositeLinkAction
+
+def exists(env):
+ platform = env.get('PLATFORM', '')
+ if platform in ('win32', 'cygwin'):
+ # Only explicitly search for a 'link' executable on Windows
+ # systems. Some other systems (e.g. Ubuntu Linux) have an
+ # executable named 'link' and we don't want that to make SCons
+ # think Visual Studio is installed.
+ return env.Detect('link')
+ return None
+
+# vim:set ts=4 sw=4 et:
diff --git a/scons/msvc_sa.py b/scons/msvc_sa.py
new file mode 100644
index 00000000000..136d3052656
--- /dev/null
+++ b/scons/msvc_sa.py
@@ -0,0 +1,173 @@
+"""msvc_sa
+
+Tool-specific initialization for Microsoft Visual C/C++.
+
+Based on SCons.Tool.msvc, without the MSVS detection.
+
+"""
+
+#
+# Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 The SCons Foundation
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os.path
+import re
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Util
+import SCons.Warnings
+
+CSuffixes = ['.c', '.C']
+CXXSuffixes = ['.cc', '.cpp', '.cxx', '.c++', '.C++']
+
+def validate_vars(env):
+ """Validate the PCH and PCHSTOP construction variables."""
+ if env.has_key('PCH') and env['PCH']:
+ if not env.has_key('PCHSTOP'):
+ raise SCons.Errors.UserError, "The PCHSTOP construction must be defined if PCH is defined."
+ if not SCons.Util.is_String(env['PCHSTOP']):
+ raise SCons.Errors.UserError, "The PCHSTOP construction variable must be a string: %r"%env['PCHSTOP']
+
+def pch_emitter(target, source, env):
+ """Adds the object file target."""
+
+ validate_vars(env)
+
+ pch = None
+ obj = None
+
+ for t in target:
+ if SCons.Util.splitext(str(t))[1] == '.pch':
+ pch = t
+ if SCons.Util.splitext(str(t))[1] == '.obj':
+ obj = t
+
+ if not obj:
+ obj = SCons.Util.splitext(str(pch))[0]+'.obj'
+
+ target = [pch, obj] # pch must be first, and obj second for the PCHCOM to work
+
+ return (target, source)
+
+def object_emitter(target, source, env, parent_emitter):
+ """Sets up the PCH dependencies for an object file."""
+
+ validate_vars(env)
+
+ parent_emitter(target, source, env)
+
+ if env.has_key('PCH') and env['PCH']:
+ env.Depends(target, env['PCH'])
+
+ return (target, source)
+
+def static_object_emitter(target, source, env):
+ return object_emitter(target, source, env,
+ SCons.Defaults.StaticObjectEmitter)
+
+def shared_object_emitter(target, source, env):
+ return object_emitter(target, source, env,
+ SCons.Defaults.SharedObjectEmitter)
+
+pch_action = SCons.Action.Action('$PCHCOM', '$PCHCOMSTR')
+pch_builder = SCons.Builder.Builder(action=pch_action, suffix='.pch',
+ emitter=pch_emitter,
+ source_scanner=SCons.Tool.SourceFileScanner)
+res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
+res_builder = SCons.Builder.Builder(action=res_action,
+ src_suffix='.rc',
+ suffix='.res',
+ src_builder=[],
+ source_scanner=SCons.Tool.SourceFileScanner)
+SCons.Tool.SourceFileScanner.add_scanner('.rc', SCons.Defaults.CScan)
+
+def generate(env):
+ """Add Builders and construction variables for MSVC++ to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ for suffix in CSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCAction)
+ static_obj.add_emitter(suffix, static_object_emitter)
+ shared_obj.add_emitter(suffix, shared_object_emitter)
+
+ for suffix in CXXSuffixes:
+ static_obj.add_action(suffix, SCons.Defaults.CXXAction)
+ shared_obj.add_action(suffix, SCons.Defaults.ShCXXAction)
+ static_obj.add_emitter(suffix, static_object_emitter)
+ shared_obj.add_emitter(suffix, shared_object_emitter)
+
+ env['CCPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Z7") or ""}'])
+ env['CCPCHFLAGS'] = SCons.Util.CLVar(['${(PCH and "/Yu%s /Fp%s"%(PCHSTOP or "",File(PCH))) or ""}'])
+ env['CCCOMFLAGS'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo$TARGET $CCPCHFLAGS $CCPDBFLAGS'
+ env['CC'] = 'cl'
+ env['CCFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['CFLAGS'] = SCons.Util.CLVar('')
+ env['CCCOM'] = '$CC $CFLAGS $CCFLAGS $CCCOMFLAGS'
+ env['SHCC'] = '$CC'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS')
+ env['SHCCCOM'] = '$SHCC $SHCFLAGS $SHCCFLAGS $CCCOMFLAGS'
+ env['CXX'] = '$CC'
+ env['CXXFLAGS'] = SCons.Util.CLVar('$CCFLAGS $( /TP $)')
+ env['CXXCOM'] = '$CXX $CXXFLAGS $CCCOMFLAGS'
+ env['SHCXX'] = '$CXX'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHCXXCOM'] = '$SHCXX $SHCXXFLAGS $CCCOMFLAGS'
+ env['CPPDEFPREFIX'] = '/D'
+ env['CPPDEFSUFFIX'] = ''
+ env['INCPREFIX'] = '/I'
+ env['INCSUFFIX'] = ''
+# env.Append(OBJEMITTER = [static_object_emitter])
+# env.Append(SHOBJEMITTER = [shared_object_emitter])
+ env['STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME'] = 1
+
+ env['RC'] = 'rc'
+ env['RCFLAGS'] = SCons.Util.CLVar('')
+ env['RCCOM'] = '$RC $_CPPDEFFLAGS $_CPPINCFLAGS $RCFLAGS /fo$TARGET $SOURCES'
+ env['BUILDERS']['RES'] = res_builder
+ env['OBJPREFIX'] = ''
+ env['OBJSUFFIX'] = '.obj'
+ env['SHOBJPREFIX'] = '$OBJPREFIX'
+ env['SHOBJSUFFIX'] = '$OBJSUFFIX'
+
+ env['CFILESUFFIX'] = '.c'
+ env['CXXFILESUFFIX'] = '.cc'
+
+ env['PCHPDBFLAGS'] = SCons.Util.CLVar(['${(PDB and "/Yd") or ""}'])
+ env['PCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /Fo${TARGETS[1]} /Yc$PCHSTOP /Fp${TARGETS[0]} $CCPDBFLAGS $PCHPDBFLAGS'
+ env['BUILDERS']['PCH'] = pch_builder
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+ if not env['ENV'].has_key('SystemRoot'): # required for dlls in the winsxs folders
+ env['ENV']['SystemRoot'] = SCons.Platform.win32.get_system_root()
+
+def exists(env):
+ return env.Detect('cl')
+
+# vim:set ts=4 sw=4 et:
diff --git a/scons/python.py b/scons/python.py
new file mode 100644
index 00000000000..539184dd39c
--- /dev/null
+++ b/scons/python.py
@@ -0,0 +1,70 @@
+"""gallium
+
+Frontend-tool for Gallium3D architecture.
+
+"""
+
+#
+# Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+# All Rights Reserved.
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sub license, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice (including the
+# next paragraph) shall be included in all copies or substantial portions
+# of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+# IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+
+import sys
+import distutils.sysconfig
+import os.path
+
+
+def generate(env):
+ # See http://www.scons.org/wiki/PythonExtensions
+
+ if sys.platform in ['windows']:
+ python_root = sys.prefix
+ python_version = '%u%u' % sys.version_info[:2]
+ python_include = os.path.join(python_root, 'include')
+ python_libs = os.path.join(python_root, 'libs')
+ python_lib = os.path.join(python_libs, 'python' + python_version + '.lib')
+
+ env.Append(CPPPATH = [python_include])
+ env.Append(LIBPATH = [python_libs])
+ env.Append(LIBS = ['python' + python_version + '.lib'])
+ env.Replace(SHLIBPREFIX = '')
+ env.Replace(SHLIBSUFFIX = '.pyd')
+
+ # XXX; python25_d.lib is not included in Python for windows, and
+ # we'll get missing symbols unless we undefine _DEBUG
+ cppdefines = env['CPPDEFINES']
+ cppdefines = [define for define in cppdefines if define != '_DEBUG']
+ env.Replace(CPPDEFINES = cppdefines)
+ else:
+ #env.ParseConfig('python-config --cflags --ldflags --libs')
+ env.AppendUnique(CPPPATH = [distutils.sysconfig.get_python_inc()])
+ env.Replace(SHLIBPREFIX = '')
+ env.Replace(SHLIBSUFFIX = distutils.sysconfig.get_config_vars()['SO'])
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/scons/wcesdk.py b/scons/wcesdk.py
new file mode 100644
index 00000000000..bf73c2d73f0
--- /dev/null
+++ b/scons/wcesdk.py
@@ -0,0 +1,176 @@
+"""wcesdk
+
+Tool-specific initialization for Microsoft Window CE SDKs.
+
+"""
+
+#
+# Copyright (c) 2001-2007 The SCons Foundation
+# Copyright (c) 2008 Tungsten Graphics, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os.path
+import re
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Util
+import SCons.Warnings
+
+import msvc_sa
+import mslib_sa
+import mslink_sa
+
+def get_wce500_paths(env):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
+ of those three environment variables that should be set
+ in order to execute the MSVC tools properly."""
+
+ exe_paths = []
+ lib_paths = []
+ include_paths = []
+
+ # mymic the batch files located in Microsoft eMbedded C++ 4.0\EVC\WCExxx\BIN
+ os_version = os.environ.get('OSVERSION', 'WCE500')
+ platform = os.environ.get('PLATFORM', 'STANDARDSDK_500')
+ wce_root = os.environ.get('WCEROOT', 'C:\\Program Files\\Microsoft eMbedded C++ 4.0')
+ sdk_root = os.environ.get('SDKROOT', 'C:\\Windows CE Tools')
+
+ target_cpu = 'x86'
+ cfg = 'none'
+
+ exe_paths.append( os.path.join(wce_root, 'COMMON', 'EVC', 'bin') )
+ exe_paths.append( os.path.join(wce_root, 'EVC', os_version, 'bin') )
+ include_paths.append( os.path.join(sdk_root, os_version, platform, 'include', target_cpu) )
+ include_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'include') )
+ include_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'include') )
+ lib_paths.append( os.path.join(sdk_root, os_version, platform, 'lib', target_cpu) )
+ lib_paths.append( os.path.join(sdk_root, os_version, platform, 'MFC', 'lib', target_cpu) )
+ lib_paths.append( os.path.join(sdk_root, os_version, platform, 'ATL', 'lib', target_cpu) )
+
+ include_path = string.join( include_paths, os.pathsep )
+ lib_path = string.join(lib_paths, os.pathsep )
+ exe_path = string.join(exe_paths, os.pathsep )
+ return (include_path, lib_path, exe_path)
+
+def get_wce600_root(env):
+ try:
+ return os.environ['_WINCEROOT']
+ except KeyError:
+ pass
+
+ if SCons.Util.can_read_reg:
+ key = r'SOFTWARE\Microsoft\Platform Builder\6.00\Directories\OS Install Dir'
+ try:
+ path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
+ except SCons.Util.RegError:
+ pass
+ else:
+ return path
+
+ default_path = os.path.join(r'C:\WINCE600', version)
+ if os.path.exists(default_path):
+ return default_path
+
+ return None
+
+def get_wce600_paths(env):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
+ of those three environment variables that should be set
+ in order to execute the MSVC tools properly."""
+
+ exe_paths = []
+ lib_paths = []
+ include_paths = []
+
+ # See also C:\WINCE600\public\common\oak\misc\wince.bat
+
+ wince_root = get_wce600_root(env)
+ if wince_root is None:
+ raise SCons.Errors.InternalError, "Windows CE 6.0 SDK not found"
+
+ os_version = os.environ.get('_WINCEOSVER', '600')
+ platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
+ sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
+
+ platform_root = os.environ.get('_PLATFORMROOT', os.path.join(wince_root, 'platform'))
+ sdk_root = os.environ.get('_SDKROOT' ,os.path.join(wince_root, 'sdk'))
+
+ host_cpu = os.environ.get('_HOSTCPUTYPE', 'i386')
+ target_cpu = os.environ.get('_TGTCPU', 'x86')
+
+ if env['debug']:
+ build = 'debug'
+ else:
+ build = 'retail'
+
+ try:
+ project_root = os.environ['_PROJECTROOT']
+ except KeyError:
+ # No project root defined -- use the common stuff instead
+ project_root = os.path.join(wince_root, 'public', 'common')
+
+ exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu) )
+ exe_paths.append( os.path.join(sdk_root, 'bin', host_cpu, target_cpu) )
+ exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'bin', host_cpu) )
+ exe_paths.append( os.path.join(wince_root, 'common', 'oak', 'misc') )
+
+ include_paths.append( os.path.join(project_root, 'sdk', 'inc') )
+ include_paths.append( os.path.join(project_root, 'oak', 'inc') )
+ include_paths.append( os.path.join(project_root, 'ddk', 'inc') )
+ include_paths.append( os.path.join(sdk_root, 'CE', 'inc') )
+
+ lib_paths.append( os.path.join(project_root, 'sdk', 'lib', target_cpu, build) )
+ lib_paths.append( os.path.join(project_root, 'oak', 'lib', target_cpu, build) )
+ lib_paths.append( os.path.join(project_root, 'ddk', 'lib', target_cpu, build) )
+
+ include_path = string.join( include_paths, os.pathsep )
+ lib_path = string.join(lib_paths, os.pathsep )
+ exe_path = string.join(exe_paths, os.pathsep )
+ return (include_path, lib_path, exe_path)
+
+def generate(env):
+
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ try:
+ include_path, lib_path, exe_path = get_wce600_paths(env)
+
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+def exists(env):
+ return get_wce600_root(env) is not None
+
+# vim:set ts=4 sw=4 et:
diff --git a/scons/winddk.py b/scons/winddk.py
new file mode 100644
index 00000000000..6a99b83a835
--- /dev/null
+++ b/scons/winddk.py
@@ -0,0 +1,130 @@
+"""winddk
+
+Tool-specific initialization for Microsoft Windows DDK.
+
+"""
+
+#
+# Copyright (c) 2001-2007 The SCons Foundation
+# Copyright (c) 2008 Tungsten Graphics, Inc.
+#
+# Permission is hereby granted, free of charge, to any person obtaining
+# a copy of this software and associated documentation files (the
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+
+import os.path
+import re
+import string
+
+import SCons.Action
+import SCons.Builder
+import SCons.Errors
+import SCons.Platform.win32
+import SCons.Tool
+import SCons.Util
+import SCons.Warnings
+
+import msvc_sa
+import mslib_sa
+import mslink_sa
+
+def get_winddk_root(env):
+ try:
+ return os.environ['BASEDIR']
+ except KeyError:
+ pass
+
+ version = "3790.1830"
+
+ if SCons.Util.can_read_reg:
+ key = r'SOFTWARE\Microsoft\WINDDK\%s\LFNDirectory' % version
+ try:
+ path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
+ except SCons.Util.RegError:
+ pass
+ else:
+ return path
+
+ default_path = os.path.join(r'C:\WINDDK', version)
+ if os.path.exists(default_path):
+ return default_path
+
+ return None
+
+def get_winddk_paths(env):
+ """Return a 3-tuple of (INCLUDE, LIB, PATH) as the values
+ of those three environment variables that should be set
+ in order to execute the MSVC tools properly."""
+
+ WINDDKdir = None
+ exe_paths = []
+ lib_paths = []
+ include_paths = []
+
+ WINDDKdir = get_winddk_root(env)
+ if WINDDKdir is None:
+ raise SCons.Errors.InternalError, "WINDDK not found"
+
+ exe_paths.append( os.path.join(WINDDKdir, 'bin') )
+ exe_paths.append( os.path.join(WINDDKdir, 'bin', 'x86') )
+ include_paths.append( os.path.join(WINDDKdir, 'inc', 'wxp') )
+ lib_paths.append( os.path.join(WINDDKdir, 'lib') )
+
+ target_os = 'wxp'
+ target_cpu = 'i386'
+
+ env['SDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', target_os)
+ env['CRT_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'crt')
+ env['DDK_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', target_os)
+ env['WDM_INC_PATH'] = os.path.join(WINDDKdir, 'inc', 'ddk', 'wdm', target_os)
+
+ env['SDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
+ env['CRT_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', 'crt', target_cpu)
+ env['DDK_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
+ env['WDM_LIB_PATH'] = os.path.join(WINDDKdir, 'lib', target_os, target_cpu)
+
+ include_path = string.join( include_paths, os.pathsep )
+ lib_path = string.join(lib_paths, os.pathsep )
+ exe_path = string.join(exe_paths, os.pathsep )
+ return (include_path, lib_path, exe_path)
+
+def generate(env):
+
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
+
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ try:
+ include_path, lib_path, exe_path = get_winddk_paths(env)
+
+ # since other tools can set these, we just make sure that the
+ # relevant stuff from WINDDK is in there somewhere.
+ env.PrependENVPath('INCLUDE', include_path)
+ env.PrependENVPath('LIB', lib_path)
+ env.PrependENVPath('PATH', exe_path)
+ except (SCons.Util.RegError, SCons.Errors.InternalError):
+ pass
+
+def exists(env):
+ return get_winddk_root(env) is not None
+
+# vim:set ts=4 sw=4 et: