aboutsummaryrefslogtreecommitdiff
path: root/mesalib/scons
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/scons')
-rw-r--r--mesalib/scons/crossmingw.py198
-rw-r--r--mesalib/scons/custom.py169
-rw-r--r--mesalib/scons/dxsdk.py73
-rw-r--r--mesalib/scons/fixes.py27
-rw-r--r--mesalib/scons/gallium.py580
-rw-r--r--mesalib/scons/llvm.py168
-rw-r--r--mesalib/scons/mslib_sa.py137
-rw-r--r--mesalib/scons/mslink_sa.py246
-rw-r--r--mesalib/scons/msvc_sa.py246
-rw-r--r--mesalib/scons/python.py72
-rw-r--r--mesalib/scons/udis86.py44
-rw-r--r--mesalib/scons/wcesdk.py176
-rw-r--r--mesalib/scons/winddk.py148
-rw-r--r--mesalib/scons/winsdk.py131
-rw-r--r--mesalib/scons/x11.py52
15 files changed, 2467 insertions, 0 deletions
diff --git a/mesalib/scons/crossmingw.py b/mesalib/scons/crossmingw.py
new file mode 100644
index 000000000..bac51de07
--- /dev/null
+++ b/mesalib/scons/crossmingw.py
@@ -0,0 +1,198 @@
+"""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:
+prefixes32 = SCons.Util.Split("""
+ mingw32-
+ mingw32msvc-
+ i386-mingw32-
+ i486-mingw32-
+ i586-mingw32-
+ i686-mingw32-
+ i386-mingw32msvc-
+ i486-mingw32msvc-
+ i586-mingw32msvc-
+ i686-mingw32msvc-
+ i686-pc-mingw32-
+ i686-w64-mingw32-
+""")
+prefixes64 = SCons.Util.Split("""
+ amd64-mingw32-
+ amd64-mingw32msvc-
+ amd64-pc-mingw32-
+ x86_64-w64-mingw32-
+""")
+
+def find(env):
+ if env['machine'] == 'x86_64':
+ prefixes = prefixes64
+ else:
+ prefixes = prefixes32
+ 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, '$SHLINKCOMSTR', 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(CCFLAGS = ['-gstabs'])
+
+ env.AppendUnique(CPPDEFINES = [('__MSVCRT_VERSION__', '0x0700')])
+ #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/mesalib/scons/custom.py b/mesalib/scons/custom.py
new file mode 100644
index 000000000..457a02011
--- /dev/null
+++ b/mesalib/scons/custom.py
@@ -0,0 +1,169 @@
+"""custom
+
+Custom builders and methods.
+
+"""
+
+#
+# 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
+
+import fixes
+
+
+def quietCommandLines(env):
+ # Quiet command lines
+ # See also http://www.scons.org/wiki/HidingCommandLinesInOutput
+ env['ASCOMSTR'] = " Assembling $SOURCE ..."
+ env['ASPPCOMSTR'] = " Assembling $SOURCE ..."
+ env['CCCOMSTR'] = " Compiling $SOURCE ..."
+ env['SHCCCOMSTR'] = " Compiling $SOURCE ..."
+ env['CXXCOMSTR'] = " Compiling $SOURCE ..."
+ env['SHCXXCOMSTR'] = " Compiling $SOURCE ..."
+ env['ARCOMSTR'] = " Archiving $TARGET ..."
+ env['RANLIBCOMSTR'] = " Indexing $TARGET ..."
+ env['LINKCOMSTR'] = " Linking $TARGET ..."
+ env['SHLINKCOMSTR'] = " Linking $TARGET ..."
+ env['LDMODULECOMSTR'] = " Linking $TARGET ..."
+ env['SWIGCOMSTR'] = " Generating $TARGET ..."
+ env['CODEGENCOMSTR'] = " Generating $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)
+ action = SCons.Action.Action(command, "$CODEGENCOMSTR")
+ code = env.Command(target, source, action)
+
+ # 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 generate(env):
+ """Common environment generation code"""
+
+ if env.get('quiet', True):
+ quietCommandLines(env)
+
+ # Custom builders and methods
+ createConvenienceLibBuilder(env)
+ createCodeGenerateMethod(env)
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/mesalib/scons/dxsdk.py b/mesalib/scons/dxsdk.py
new file mode 100644
index 000000000..4671763d3
--- /dev/null
+++ b/mesalib/scons/dxsdk.py
@@ -0,0 +1,73 @@
+"""dxsdk
+
+Tool-specific initialization for Microsoft DirectX SDK
+
+"""
+
+#
+# Copyright (c) 2009 VMware, 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
+import os.path
+
+import SCons.Errors
+import SCons.Util
+
+
+def get_dxsdk_root(env):
+ try:
+ return os.environ['DXSDK_DIR']
+ except KeyError:
+ return None
+
+def generate(env):
+ dxsdk_root = get_dxsdk_root(env)
+ if dxsdk_root is None:
+ # DirectX SDK not found
+ return
+
+ if env['machine'] in ('generic', 'x86'):
+ target_cpu = 'x86'
+ elif env['machine'] == 'x86_64':
+ target_cpu = 'x64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+
+ include_dir = os.path.join(dxsdk_root, 'Include')
+ lib_dir = os.path.join(dxsdk_root, 'Lib', target_cpu)
+
+ env.Append(CPPDEFINES = [('HAVE_DXSDK', '1')])
+
+ gcc = 'gcc' in os.path.basename(env['CC']).split('-')
+ if gcc:
+ # Make GCC more forgiving towards Microsoft's headers
+ env.Prepend(CPPFLAGS = ['-isystem', include_dir])
+ else:
+ env.Prepend(CPPPATH = [include_dir])
+
+ env.Prepend(LIBPATH = [lib_dir])
+
+def exists(env):
+ return get_dxsdk_root(env) is not None
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/fixes.py b/mesalib/scons/fixes.py
new file mode 100644
index 000000000..5946106ab
--- /dev/null
+++ b/mesalib/scons/fixes.py
@@ -0,0 +1,27 @@
+import sys
+
+# Monkey patch os.spawnve on windows to become thread safe
+if sys.platform == 'win32':
+ import os
+ import threading
+ from os import spawnve as old_spawnve
+
+ spawn_lock = threading.Lock()
+
+ def new_spawnve(mode, file, args, env):
+ spawn_lock.acquire()
+ try:
+ if mode == os.P_WAIT:
+ ret = old_spawnve(os.P_NOWAIT, file, args, env)
+ else:
+ ret = old_spawnve(mode, file, args, env)
+ finally:
+ spawn_lock.release()
+ if mode == os.P_WAIT:
+ pid, status = os.waitpid(ret, 0)
+ ret = status >> 8
+ return ret
+
+ os.spawnve = new_spawnve
+
+
diff --git a/mesalib/scons/gallium.py b/mesalib/scons/gallium.py
new file mode 100644
index 000000000..85749fe2a
--- /dev/null
+++ b/mesalib/scons/gallium.py
@@ -0,0 +1,580 @@
+"""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 distutils.version
+import os
+import os.path
+import re
+import subprocess
+
+import SCons.Action
+import SCons.Builder
+import SCons.Scanner
+
+
+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(env, source, subdir):
+ target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir)
+ return env.Install(target_dir, source)
+
+def install_program(env, source):
+ return install(env, source, 'bin')
+
+def install_shared_library(env, sources, version = ()):
+ targets = []
+ install_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'])
+ version = tuple(map(str, version))
+ if env['SHLIBSUFFIX'] == '.dll':
+ dlls = env.FindIxes(sources, 'SHLIBPREFIX', 'SHLIBSUFFIX')
+ targets += install(env, dlls, 'bin')
+ libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX')
+ targets += install(env, libs, 'lib')
+ else:
+ for source in sources:
+ target_dir = os.path.join(install_dir, 'lib')
+ target_name = '.'.join((str(source),) + version)
+ last = env.InstallAs(os.path.join(target_dir, target_name), source)
+ targets += last
+ 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)
+ targets += last
+ return targets
+
+
+def createInstallMethods(env):
+ env.AddMethod(install_program, 'InstallProgram')
+ env.AddMethod(install_shared_library, 'InstallSharedLibrary')
+
+
+def num_jobs():
+ try:
+ return int(os.environ['NUMBER_OF_PROCESSORS'])
+ except (ValueError, KeyError):
+ pass
+
+ try:
+ return os.sysconf('SC_NPROCESSORS_ONLN')
+ except (ValueError, OSError, AttributeError):
+ pass
+
+ try:
+ return int(os.popen2("sysctl -n hw.ncpu")[1].read())
+ except ValueError:
+ pass
+
+ return 1
+
+
+def pkg_config_modules(env, name, modules):
+ '''Simple wrapper for pkg-config.'''
+
+ env[name] = False
+
+ if env['platform'] == 'windows':
+ return
+
+ if not env.Detect('pkg-config'):
+ return
+
+ if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
+ return
+
+ # Put -I and -L flags directly into the environment, as these don't affect
+ # the compilation of targets that do not use them
+ try:
+ env.ParseConfig('pkg-config --cflags-only-I --libs-only-L ' + ' '.join(modules))
+ except OSError:
+ return
+
+ # Other flags may affect the compilation of unrelated targets, so store
+ # them with a prefix, (e.g., XXX_CFLAGS, XXX_LIBS, etc)
+ try:
+ flags = env.ParseFlags('!pkg-config --cflags-only-other --libs-only-l --libs-only-other ' + ' '.join(modules))
+ except OSError:
+ return
+ prefix = name.upper() + '_'
+ for flag_name, flag_value in flags.iteritems():
+ env[prefix + flag_name] = flag_value
+
+ env[name] = True
+
+
+
+def generate(env):
+ """Common environment generation code"""
+
+ # Toolchain
+ platform = env['platform']
+ if env['toolchain'] == 'default':
+ if platform == 'winddk':
+ env['toolchain'] = 'winddk'
+ elif platform == 'wince':
+ env['toolchain'] = 'wcesdk'
+ env.Tool(env['toolchain'])
+
+ # Allow override compiler and specify additional flags from environment
+ if os.environ.has_key('CC'):
+ env['CC'] = os.environ['CC']
+ # Update CCVERSION to match
+ pipe = SCons.Action._subproc(env, [env['CC'], '--version'],
+ stdin = 'devnull',
+ stderr = 'devnull',
+ stdout = subprocess.PIPE)
+ if pipe.wait() == 0:
+ line = pipe.stdout.readline()
+ match = re.search(r'[0-9]+(\.[0-9]+)+', line)
+ if match:
+ env['CCVERSION'] = match.group(0)
+ if os.environ.has_key('CFLAGS'):
+ env['CCFLAGS'] += SCons.Util.CLVar(os.environ['CFLAGS'])
+ if os.environ.has_key('CXX'):
+ env['CXX'] = os.environ['CXX']
+ if os.environ.has_key('CXXFLAGS'):
+ env['CXXFLAGS'] += SCons.Util.CLVar(os.environ['CXXFLAGS'])
+ if os.environ.has_key('LDFLAGS'):
+ env['LINKFLAGS'] += SCons.Util.CLVar(os.environ['LDFLAGS'])
+
+ env['gcc'] = 'gcc' in os.path.basename(env['CC']).split('-')
+ env['msvc'] = env['CC'] == 'cl'
+
+ # shortcuts
+ machine = env['machine']
+ platform = env['platform']
+ x86 = env['machine'] == 'x86'
+ ppc = env['machine'] == 'ppc'
+ gcc = env['gcc']
+ msvc = env['msvc']
+
+ # Backwards compatability with the debug= profile= options
+ if env['build'] == 'debug':
+ if not env['debug']:
+ print 'scons: warning: debug option is deprecated and will be removed eventually; use instead'
+ print
+ print ' scons build=release'
+ print
+ env['build'] = 'release'
+ if env['profile']:
+ print 'scons: warning: profile option is deprecated and will be removed eventually; use instead'
+ print
+ print ' scons build=profile'
+ print
+ env['build'] = 'profile'
+ if False:
+ # Enforce SConscripts to use the new build variable
+ env.popitem('debug')
+ env.popitem('profile')
+ else:
+ # Backwards portability with older sconscripts
+ if env['build'] in ('debug', 'checked'):
+ env['debug'] = True
+ env['profile'] = False
+ if env['build'] == 'profile':
+ env['debug'] = False
+ env['profile'] = True
+ if env['build'] == 'release':
+ env['debug'] = False
+ env['profile'] = False
+
+ # 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['machine'] != 'generic':
+ build_subdir += '-' + env['machine']
+ if env['build'] != 'release':
+ build_subdir += '-' + env['build']
+ 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_dir'] = build_dir
+ env.SConsignFile(os.path.join(build_dir, '.sconsign'))
+ if 'SCONS_CACHE_DIR' in os.environ:
+ print 'scons: Using build cache in %s.' % (os.environ['SCONS_CACHE_DIR'],)
+ env.CacheDir(os.environ['SCONS_CACHE_DIR'])
+ env['CONFIGUREDIR'] = os.path.join(build_dir, 'conf')
+ env['CONFIGURELOG'] = os.path.join(os.path.abspath(build_dir), 'config.log')
+
+ # Parallel build
+ if env.GetOption('num_jobs') <= 1:
+ env.SetOption('num_jobs', num_jobs())
+
+ env.Decider('MD5-timestamp')
+ env.SetOption('max_drift', 60)
+
+ # C preprocessor options
+ cppdefines = []
+ if env['build'] in ('debug', 'checked'):
+ cppdefines += ['DEBUG']
+ else:
+ cppdefines += ['NDEBUG']
+ if env['build'] == 'profile':
+ cppdefines += ['PROFILE']
+ if platform == 'windows':
+ cppdefines += [
+ 'WIN32',
+ '_WINDOWS',
+ #'_UNICODE',
+ #'UNICODE',
+ # http://msdn.microsoft.com/en-us/library/aa383745.aspx
+ ('_WIN32_WINNT', '0x0601'),
+ ('WINVER', '0x0601'),
+ ]
+ if msvc and env['toolchain'] != 'winddk':
+ cppdefines += [
+ 'VC_EXTRALEAN',
+ '_USE_MATH_DEFINES',
+ '_CRT_SECURE_NO_WARNINGS',
+ '_CRT_SECURE_NO_DEPRECATE',
+ '_SCL_SECURE_NO_WARNINGS',
+ '_SCL_SECURE_NO_DEPRECATE',
+ ]
+ if env['build'] in ('debug', 'checked'):
+ cppdefines += ['_DEBUG']
+ if env['toolchain'] == '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/
+ if machine == 'x86':
+ cppdefines += ['_X86_', 'i386']
+ if machine == 'x86_64':
+ cppdefines += ['_AMD64_', 'AMD64']
+ if platform == 'winddk':
+ cppdefines += [
+ '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 env['build'] in ('debug', 'checked'):
+ 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']
+ if platform == 'embedded':
+ cppdefines += ['PIPE_OS_EMBEDDED']
+ env.Append(CPPDEFINES = cppdefines)
+
+ # C compiler options
+ cflags = [] # C
+ cxxflags = [] # C++
+ ccflags = [] # C & C++
+ if gcc:
+ ccversion = env['CCVERSION']
+ if env['build'] == 'debug':
+ ccflags += ['-O0']
+ elif ccversion.startswith('4.2.'):
+ # gcc 4.2.x optimizer is broken
+ print "warning: gcc 4.2.x optimizer is broken -- disabling optimizations"
+ ccflags += ['-O0']
+ else:
+ ccflags += ['-O3']
+ ccflags += ['-g3']
+ if env['build'] in ('checked', 'profile'):
+ # See http://code.google.com/p/jrfonseca/wiki/Gprof2Dot#Which_options_should_I_pass_to_gcc_when_compiling_for_profiling?
+ ccflags += [
+ '-fno-omit-frame-pointer',
+ '-fno-optimize-sibling-calls',
+ ]
+ if env['machine'] == 'x86':
+ ccflags += [
+ '-m32',
+ #'-march=pentium4',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
+ # NOTE: We need to ensure stack is realigned given that we
+ # produce shared objects, and have no control over the stack
+ # alignment policy of the application. Therefore we need
+ # -mstackrealign ore -mincoming-stack-boundary=2.
+ #
+ # XXX: We could have SSE without -mstackrealign if we always used
+ # __attribute__((force_align_arg_pointer)), but that's not
+ # always the case.
+ ccflags += [
+ '-mstackrealign', # ensure stack is aligned
+ '-mmmx', '-msse', '-msse2', # enable SIMD intrinsics
+ #'-mfpmath=sse',
+ ]
+ if platform in ['windows', 'darwin']:
+ # Workaround http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37216
+ ccflags += ['-fno-common']
+ if env['machine'] == 'x86_64':
+ ccflags += ['-m64']
+ if platform == 'darwin':
+ ccflags += ['-fno-common']
+ # See also:
+ # - http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html
+ ccflags += [
+ '-Wall',
+ '-Wno-long-long',
+ '-ffast-math',
+ '-fmessage-length=0', # be nice to Eclipse
+ ]
+ cflags += [
+ '-Wmissing-prototypes',
+ '-std=gnu99',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.0'):
+ ccflags += [
+ '-Wmissing-field-initializers',
+ ]
+ if distutils.version.LooseVersion(ccversion) >= distutils.version.LooseVersion('4.2'):
+ ccflags += [
+ '-Werror=pointer-arith',
+ ]
+ cflags += [
+ '-Werror=declaration-after-statement',
+ ]
+ if msvc:
+ # See also:
+ # - http://msdn.microsoft.com/en-us/library/19z1t1wy.aspx
+ # - cl /?
+ if env['build'] == 'debug':
+ ccflags += [
+ '/Od', # disable optimizations
+ '/Oi', # enable intrinsic functions
+ '/Oy-', # disable frame pointer omission
+ '/GL-', # disable whole program optimization
+ ]
+ else:
+ ccflags += [
+ '/O2', # optimize for speed
+ '/GL', # enable whole program optimization
+ ]
+ ccflags += [
+ '/fp:fast', # fast floating point
+ '/W3', # warning level
+ #'/Wp64', # enable 64 bit porting warnings
+ ]
+ if env['machine'] == 'x86':
+ ccflags += [
+ #'/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['build'] in ('debug', 'checked'):
+ 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 = []
+ shlinkflags = []
+ if gcc:
+ if env['machine'] == 'x86':
+ linkflags += ['-m32']
+ if env['machine'] == 'x86_64':
+ linkflags += ['-m64']
+ if env['platform'] not in ('darwin'):
+ shlinkflags += [
+ '-Wl,-Bsymbolic',
+ ]
+ # Handle circular dependencies in the libraries
+ if env['platform'] in ('darwin'):
+ pass
+ else:
+ env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
+ if msvc:
+ if env['build'] != 'debug':
+ # enable Link-time Code Generation
+ linkflags += ['/LTCG']
+ env.Append(ARFLAGS = ['/LTCG'])
+ if platform == 'windows' and msvc:
+ # See also:
+ # - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
+ linkflags += [
+ '/fixed:no',
+ '/incremental:no',
+ ]
+ if platform == 'winddk':
+ 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['build'] != 'release':
+ 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)
+ env.Append(SHLINKFLAGS = shlinkflags)
+
+ # Default libs
+ env.Append(LIBS = [])
+
+ # Load tools
+ if env['llvm']:
+ env.Tool('llvm')
+ env.Tool('udis86')
+
+ pkg_config_modules(env, 'x11', ['x11', 'xext'])
+ pkg_config_modules(env, 'drm', ['libdrm'])
+ pkg_config_modules(env, 'drm_intel', ['libdrm_intel'])
+ pkg_config_modules(env, 'drm_radeon', ['libdrm_radeon'])
+ pkg_config_modules(env, 'xorg', ['xorg-server'])
+ pkg_config_modules(env, 'kms', ['libkms'])
+
+ env['dri'] = env['x11'] and env['drm']
+
+ # Custom builders and methods
+ env.Tool('custom')
+ createInstallMethods(env)
+
+ # for debugging
+ #print env.Dump()
+
+
+def exists(env):
+ return 1
diff --git a/mesalib/scons/llvm.py b/mesalib/scons/llvm.py
new file mode 100644
index 000000000..64fb10181
--- /dev/null
+++ b/mesalib/scons/llvm.py
@@ -0,0 +1,168 @@
+"""llvm
+
+Tool-specific initialization for LLVM
+
+"""
+
+#
+# Copyright (c) 2009 VMware, 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
+import os.path
+import re
+import sys
+import distutils.version
+
+import SCons.Errors
+import SCons.Util
+
+
+def generate(env):
+ env['llvm'] = False
+
+ try:
+ llvm_dir = os.environ['LLVM']
+ except KeyError:
+ # Do nothing -- use the system headers/libs
+ llvm_dir = None
+ else:
+ if not os.path.isdir(llvm_dir):
+ raise SCons.Errors.InternalError, "Specified LLVM directory not found"
+
+ if env['debug']:
+ llvm_subdir = 'Debug'
+ else:
+ llvm_subdir = 'Release'
+
+ llvm_bin_dir = os.path.join(llvm_dir, llvm_subdir, 'bin')
+ if not os.path.isdir(llvm_bin_dir):
+ llvm_bin_dir = os.path.join(llvm_dir, 'bin')
+ if not os.path.isdir(llvm_bin_dir):
+ raise SCons.Errors.InternalError, "LLVM binary directory not found"
+
+ env.PrependENVPath('PATH', llvm_bin_dir)
+
+ if env['platform'] == 'windows':
+ # XXX: There is no llvm-config on Windows, so assume a standard layout
+ if llvm_dir is None:
+ print 'scons: LLVM environment variable must be specified when building for windows'
+ return
+
+ # Try to determine the LLVM version from llvm/Config/config.h
+ llvm_config = os.path.join(llvm_dir, 'include/llvm/Config/config.h')
+ if not os.path.exists(llvm_config):
+ print 'scons: could not find %s' % llvm_config
+ return
+ llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"')
+ llvm_version = None
+ for line in open(llvm_config, 'rt'):
+ mo = llvm_version_re.match(line)
+ if mo:
+ llvm_version = mo.group(1)
+ llvm_version = distutils.version.LooseVersion(llvm_version)
+ break
+ if llvm_version is None:
+ print 'scons: could not determine the LLVM version from %s' % llvm_config
+ return
+
+ env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
+ env.AppendUnique(CPPDEFINES = [
+ '__STDC_LIMIT_MACROS',
+ '__STDC_CONSTANT_MACROS',
+ 'HAVE_STDINT_H',
+ ])
+ env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')])
+ if llvm_version >= distutils.version.LooseVersion('2.7'):
+ # 2.7
+ env.Prepend(LIBS = [
+ 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
+ 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
+ 'LLVMBitWriter', 'LLVMX86Disassembler', 'LLVMX86AsmParser',
+ 'LLVMMCParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
+ 'LLVMSelectionDAG', 'LLVMX86Info', 'LLVMAsmPrinter',
+ 'LLVMCodeGen', 'LLVMScalarOpts', 'LLVMInstCombine',
+ 'LLVMTransformUtils', 'LLVMipa', 'LLVMAsmParser',
+ 'LLVMArchive', 'LLVMBitReader', 'LLVMAnalysis', 'LLVMTarget',
+ 'LLVMMC', 'LLVMCore', 'LLVMSupport', 'LLVMSystem',
+ ])
+ else:
+ # 2.6
+ env.Prepend(LIBS = [
+ 'LLVMX86AsmParser', 'LLVMX86AsmPrinter', 'LLVMX86CodeGen',
+ 'LLVMX86Info', 'LLVMLinker', 'LLVMipo', 'LLVMInterpreter',
+ 'LLVMInstrumentation', 'LLVMJIT', 'LLVMExecutionEngine',
+ 'LLVMDebugger', 'LLVMBitWriter', 'LLVMAsmParser',
+ 'LLVMArchive', 'LLVMBitReader', 'LLVMSelectionDAG',
+ 'LLVMAsmPrinter', 'LLVMCodeGen', 'LLVMScalarOpts',
+ 'LLVMTransformUtils', 'LLVMipa', 'LLVMAnalysis',
+ 'LLVMTarget', 'LLVMMC', 'LLVMCore', 'LLVMSupport',
+ 'LLVMSystem',
+ ])
+ env.Append(LIBS = [
+ 'imagehlp',
+ 'psapi',
+ ])
+ if env['msvc']:
+ # Some of the LLVM C headers use the inline keyword without
+ # defining it.
+ env.Append(CPPDEFINES = [('inline', '__inline')])
+ if env['build'] in ('debug', 'checked'):
+ # LLVM libraries are static, build with /MT, and they
+ # automatically link agains LIBCMT. When we're doing a
+ # debug build we'll be linking against LIBCMTD, so disable
+ # that.
+ env.Append(LINKFLAGS = ['/nodefaultlib:LIBCMT'])
+ else:
+ if not env.Detect('llvm-config'):
+ print 'scons: llvm-config script not found' % llvm_version
+ return
+
+ llvm_version = env.backtick('llvm-config --version').rstrip()
+ llvm_version = distutils.version.LooseVersion(llvm_version)
+
+ try:
+ env.ParseConfig('llvm-config --cppflags')
+ env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter')
+ env.ParseConfig('llvm-config --ldflags')
+ except OSError:
+ print 'scons: llvm-config version %s failed' % llvm_version
+ return
+ else:
+ env['LINK'] = env['CXX']
+
+ assert llvm_version is not None
+ env['llvm'] = True
+
+ print 'scons: Found LLVM version %s' % llvm_version
+ env['LLVM_VERSION'] = llvm_version
+
+ # Define HAVE_LLVM macro with the major/minor version number (e.g., 0x0206 for 2.6)
+ llvm_version_major = int(llvm_version.version[0])
+ llvm_version_minor = int(llvm_version.version[1])
+ llvm_version_hex = '0x%02x%02x' % (llvm_version_major, llvm_version_minor)
+ env.Prepend(CPPDEFINES = [('HAVE_LLVM', llvm_version_hex)])
+
+def exists(env):
+ return True
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/mslib_sa.py b/mesalib/scons/mslib_sa.py
new file mode 100644
index 000000000..d7957f705
--- /dev/null
+++ b/mesalib/scons/mslib_sa.py
@@ -0,0 +1,137 @@
+"""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, 2009 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 tempfile
+import string
+
+import SCons.Defaults
+import SCons.Tool
+import SCons.Util
+import SCons.Errors
+
+class TempFileMunge:
+ """Same as SCons.Platform.TempFileMunge, but preserves LINK /LIB
+ together."""
+
+ def __init__(self, cmd):
+ self.cmd = cmd
+
+ def __call__(self, target, source, env, for_signature):
+ if for_signature:
+ return self.cmd
+ cmd = env.subst_list(self.cmd, 0, target, source)[0]
+ try:
+ maxline = int(env.subst('$MAXLINELENGTH'))
+ except ValueError:
+ maxline = 2048
+
+ if (reduce(lambda x, y: x + len(y), cmd, 0) + len(cmd)) <= maxline:
+ return self.cmd
+
+ # We do a normpath because mktemp() has what appears to be
+ # a bug in Windows that will use a forward slash as a path
+ # delimiter. Windows's link mistakes that for a command line
+ # switch and barfs.
+ #
+ # We use the .lnk suffix for the benefit of the Phar Lap
+ # linkloc linker, which likes to append an .lnk suffix if
+ # none is given.
+ tmp = os.path.normpath(tempfile.mktemp('.lnk'))
+ native_tmp = SCons.Util.get_native_path(tmp)
+
+ if env['SHELL'] and env['SHELL'] == 'sh':
+ # The sh shell will try to escape the backslashes in the
+ # path, so unescape them.
+ native_tmp = string.replace(native_tmp, '\\', r'\\\\')
+ # In Cygwin, we want to use rm to delete the temporary
+ # file, because del does not exist in the sh shell.
+ rm = env.Detect('rm') or 'del'
+ else:
+ # Don't use 'rm' if the shell is not sh, because rm won't
+ # work with the Windows shells (cmd.exe or command.com) or
+ # Windows path names.
+ rm = 'del'
+
+ prefix = env.subst('$TEMPFILEPREFIX')
+ if not prefix:
+ prefix = '@'
+
+ if cmd[0:2] == ['link', '/lib']:
+ split = 2
+ else:
+ split = 1
+
+ args = map(SCons.Subst.quote_spaces, cmd[split:])
+ open(tmp, 'w').write(string.join(args, " ") + "\n")
+ # XXX Using the SCons.Action.print_actions value directly
+ # like this is bogus, but expedient. This class should
+ # really be rewritten as an Action that defines the
+ # __call__() and strfunction() methods and lets the
+ # normal action-execution logic handle whether or not to
+ # print/execute the action. The problem, though, is all
+ # of that is decided before we execute this method as
+ # part of expanding the $TEMPFILE construction variable.
+ # Consequently, refactoring this will have to wait until
+ # we get more flexible with allowing Actions to exist
+ # independently and get strung together arbitrarily like
+ # Ant tasks. In the meantime, it's going to be more
+ # user-friendly to not let obsession with architectural
+ # purity get in the way of just being helpful, so we'll
+ # reach into SCons.Action directly.
+ if SCons.Action.print_actions:
+ print("Using tempfile "+native_tmp+" for command line:\n"+
+ " ".join(map(str,cmd)))
+ return cmd[:split] + [ prefix + native_tmp + '\n' + rm, native_tmp ]
+
+def generate(env):
+ """Add Builders and construction variables for lib to an Environment."""
+ SCons.Tool.createStaticLibBuilder(env)
+
+ if env.Detect('lib'):
+ env['AR'] = 'lib'
+ else:
+ # Recent WINDDK versions do not ship with lib.
+ env['AR'] = 'link /lib'
+ env['TEMPFILE'] = TempFileMunge
+ 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') or env.Detect('link')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/mesalib/scons/mslink_sa.py b/mesalib/scons/mslink_sa.py
new file mode 100644
index 000000000..a0cfde33e
--- /dev/null
+++ b/mesalib/scons/mslink_sa.py
@@ -0,0 +1,246 @@
+"""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, 2009 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 _dllTargets(target, source, env, for_signature, paramtp):
+ listCmd = []
+ dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp)
+ 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 _dllSources(target, source, env, for_signature, paramtp):
+ listCmd = []
+
+ deffile = env.FindIxes(source, "WINDOWSDEFPREFIX", "WINDOWSDEFSUFFIX")
+ for src in source:
+ # Check explicitly for a non-None deffile so that the __cmp__
+ # method of the base SCons.Util.Proxy class used for some Node
+ # proxies doesn't try to use a non-existent __dict__ attribute.
+ if deffile and 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 windowsShlinkTargets(target, source, env, for_signature):
+ return _dllTargets(target, source, env, for_signature, 'SHLIB')
+
+def windowsShlinkSources(target, source, env, for_signature):
+ return _dllSources(target, source, env, for_signature, 'SHLIB')
+
+def _windowsLdmodTargets(target, source, env, for_signature):
+ """Get targets for loadable modules."""
+ return _dllTargets(target, source, env, for_signature, 'LDMODULE')
+
+def _windowsLdmodSources(target, source, env, for_signature):
+ """Get sources for loadable modules."""
+ return _dllSources(target, source, env, for_signature, 'LDMODULE')
+
+def _dllEmitter(target, source, env, paramtp):
+ """Common implementation of dll emitter."""
+ SCons.Tool.msvc.validate_vars(env)
+
+ extratargets = []
+ extrasources = []
+
+ dll = env.FindIxes(target, '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp)
+ 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('$%sSUFFIX' % paramtp)
+
+ 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,
+ '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
+ "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,
+ '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
+ "LIBPREFIX", "LIBSUFFIX"))
+ # and .exp file is created if there are exports from a DLL
+ extratargets.append(
+ env.ReplaceIxes(dll,
+ '%sPREFIX' % paramtp, '%sSUFFIX' % paramtp,
+ "WINDOWSEXPPREFIX", "WINDOWSEXPSUFFIX"))
+
+ return (target+extratargets, source+extrasources)
+
+def windowsLibEmitter(target, source, env):
+ return _dllEmitter(target, source, env, 'SHLIB')
+
+def ldmodEmitter(target, source, env):
+ """Emitter for loadable modules.
+
+ Loadable modules are identical to shared libraries on Windows, but building
+ them is subject to different parameters (LDMODULE*).
+ """
+ return _dllEmitter(target, source, env, 'LDMODULE')
+
+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")}')
+compositeShLinkAction = shlibLinkAction + regServerCheck
+ldmodLinkAction = SCons.Action.Action('${TEMPFILE("$LDMODULE $LDMODULEFLAGS $_LDMODULE_TARGETS $_LIBDIRFLAGS $_LIBFLAGS $_PDB $_LDMODULE_SOURCES")}')
+compositeLdmodAction = ldmodLinkAction + 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'] = compositeShLinkAction
+ 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}'
+
+ # Loadable modules are on Windows the same as shared libraries, but they
+ # are subject to different build parameters (LDMODULE* variables).
+ # Therefore LDMODULE* variables correspond as much as possible to
+ # SHLINK*/SHLIB* ones.
+ SCons.Tool.createLoadableModuleBuilder(env)
+ env['LDMODULE'] = '$SHLINK'
+ env['LDMODULEPREFIX'] = '$SHLIBPREFIX'
+ env['LDMODULESUFFIX'] = '$SHLIBSUFFIX'
+ env['LDMODULEFLAGS'] = '$SHLINKFLAGS'
+ env['_LDMODULE_TARGETS'] = _windowsLdmodTargets
+ env['_LDMODULE_SOURCES'] = _windowsLdmodSources
+ env['LDMODULEEMITTER'] = [ldmodEmitter]
+ env['LDMODULECOM'] = compositeLdmodAction
+
+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
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/mesalib/scons/msvc_sa.py b/mesalib/scons/msvc_sa.py
new file mode 100644
index 000000000..0bfc8920f
--- /dev/null
+++ b/mesalib/scons/msvc_sa.py
@@ -0,0 +1,246 @@
+"""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, 2009 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
+import SCons.Scanner.RC
+
+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)
+
+
+# Logic to build .rc files into .res files (resource files)
+res_scanner = SCons.Scanner.RC.RCScan()
+res_action = SCons.Action.Action('$RCCOM', '$RCCOMSTR')
+res_builder = SCons.Builder.Builder(action=res_action,
+ src_suffix='.rc',
+ suffix='.res',
+ src_builder=[],
+ source_scanner=res_scanner)
+
+def msvc_batch_key(action, env, target, source):
+ """
+ Returns a key to identify unique batches of sources for compilation.
+
+ If batching is enabled (via the $MSVC_BATCH setting), then all
+ target+source pairs that use the same action, defined by the same
+ environment, and have the same target and source directories, will
+ be batched.
+
+ Returning None specifies that the specified target+source should not
+ be batched with other compilations.
+ """
+ b = env.subst('$MSVC_BATCH')
+ if b in (None, '', '0'):
+ # We're not using batching; return no key.
+ return None
+ t = target[0]
+ s = source[0]
+ if os.path.splitext(t.name)[0] != os.path.splitext(s.name)[0]:
+ # The base names are different, so this *must* be compiled
+ # separately; return no key.
+ return None
+ return (id(action), id(env), t.dir, s.dir)
+
+def msvc_output_flag(target, source, env, for_signature):
+ """
+ Returns the correct /Fo flag for batching.
+
+ If batching is disabled or there's only one source file, then we
+ return an /Fo string that specifies the target explicitly. Otherwise,
+ we return an /Fo string that just specifies the first target's
+ directory (where the Visual C/C++ compiler will put the .obj files).
+ """
+ b = env.subst('$MSVC_BATCH')
+ if b in (None, '', '0') or len(source) == 1:
+ return '/Fo$TARGET'
+ else:
+ # The Visual C/C++ compiler requires a \ at the end of the /Fo
+ # option to indicate an output directory. We use os.sep here so
+ # that the test(s) for this can be run on non-Windows systems
+ # without having a hard-coded backslash mess up command-line
+ # argument parsing.
+ return '/Fo${TARGET.dir}' + os.sep
+
+CAction = SCons.Action.Action("$CCCOM", "$CCCOMSTR",
+ batch_key=msvc_batch_key,
+ targets='$CHANGED_TARGETS')
+ShCAction = SCons.Action.Action("$SHCCCOM", "$SHCCCOMSTR",
+ batch_key=msvc_batch_key,
+ targets='$CHANGED_TARGETS')
+CXXAction = SCons.Action.Action("$CXXCOM", "$CXXCOMSTR",
+ batch_key=msvc_batch_key,
+ targets='$CHANGED_TARGETS')
+ShCXXAction = SCons.Action.Action("$SHCXXCOM", "$SHCXXCOMSTR",
+ batch_key=msvc_batch_key,
+ targets='$CHANGED_TARGETS')
+
+def generate(env):
+ """Add Builders and construction variables for MSVC++ to an Environment."""
+ static_obj, shared_obj = SCons.Tool.createObjBuilders(env)
+
+ # TODO(batch): shouldn't reach in to cmdgen this way; necessary
+ # for now to bypass the checks in Builder.DictCmdGenerator.__call__()
+ # and allow .cc and .cpp to be compiled in the same command line.
+ static_obj.cmdgen.source_ext_match = False
+ shared_obj.cmdgen.source_ext_match = False
+
+ for suffix in CSuffixes:
+ static_obj.add_action(suffix, CAction)
+ shared_obj.add_action(suffix, 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, CXXAction)
+ shared_obj.add_action(suffix, 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['_MSVC_OUTPUT_FLAG'] = msvc_output_flag
+ env['_CCCOMCOM'] = '$CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS $CCPCHFLAGS $CCPDBFLAGS'
+ env['CC'] = 'cl'
+ env['CCFLAGS'] = SCons.Util.CLVar('/nologo')
+ env['CFLAGS'] = SCons.Util.CLVar('')
+ env['CCCOM'] = '$CC $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $CFLAGS $CCFLAGS $_CCCOMCOM'
+ env['SHCC'] = '$CC'
+ env['SHCCFLAGS'] = SCons.Util.CLVar('$CCFLAGS')
+ env['SHCFLAGS'] = SCons.Util.CLVar('$CFLAGS')
+ env['SHCCCOM'] = '$SHCC $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $SHCFLAGS $SHCCFLAGS $_CCCOMCOM'
+ env['CXX'] = '$CC'
+ env['CXXFLAGS'] = SCons.Util.CLVar('$( /TP $)')
+ env['CXXCOM'] = '$CXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $CXXFLAGS $CCFLAGS $_CCCOMCOM'
+ env['SHCXX'] = '$CXX'
+ env['SHCXXFLAGS'] = SCons.Util.CLVar('$CXXFLAGS')
+ env['SHCXXCOM'] = '$SHCXX $_MSVC_OUTPUT_FLAG /c $CHANGED_SOURCES $SHCXXFLAGS $SHCCFLAGS $_CCCOMCOM'
+ 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['RCSUFFIXES']=['.rc','.rc2']
+ 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 /Fo${TARGETS[1]} $CXXFLAGS $CCFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS /c $SOURCES /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')
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/mesalib/scons/python.py b/mesalib/scons/python.py
new file mode 100644
index 000000000..2314d481a
--- /dev/null
+++ b/mesalib/scons/python.py
@@ -0,0 +1,72 @@
+"""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 ['win32']:
+ 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)
+ env.AppendUnique(CPPFLAGS = ['/U_DEBUG'])
+ env.AppendUnique(LINKFLAGS = ['/nodefaultlib:python25_d.lib'])
+ 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/mesalib/scons/udis86.py b/mesalib/scons/udis86.py
new file mode 100644
index 000000000..82dd01a8f
--- /dev/null
+++ b/mesalib/scons/udis86.py
@@ -0,0 +1,44 @@
+"""udis86
+
+Tool-specific initialization for udis86
+
+"""
+
+#
+# Copyright (c) 2009 VMware, 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.
+#
+
+def generate(env):
+ conf = env.Configure()
+
+ if conf.CheckHeader('udis86.h'): # and conf.CheckLib('udis86'):
+ env['UDIS86'] = True
+ env.Prepend(LIBS = ['udis86'])
+ else:
+ env['UDIS86'] = False
+
+ conf.Finish()
+
+def exists(env):
+ return True
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/wcesdk.py b/mesalib/scons/wcesdk.py
new file mode 100644
index 000000000..cd797a789
--- /dev/null
+++ b/mesalib/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['build'] == '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/mesalib/scons/winddk.py b/mesalib/scons/winddk.py
new file mode 100644
index 000000000..9e47b9428
--- /dev/null
+++ b/mesalib/scons/winddk.py
@@ -0,0 +1,148 @@
+"""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
+
+versions = [
+ '6001.18002',
+ '3790.1830',
+]
+
+def cpu_bin(target_cpu):
+ if target_cpu == 'i386':
+ return 'x86'
+ else:
+ return target_cpu
+
+def get_winddk_root(env, version):
+ 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, version, root):
+ version_major, version_minor = map(int, version.split('.'))
+
+ if version_major >= 6000:
+ target_os = 'wlh'
+ else:
+ target_os = 'wxp'
+
+ if env['machine'] in ('generic', 'x86'):
+ target_cpu = 'i386'
+ elif env['machine'] == 'x86_64':
+ target_cpu = 'amd64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+
+ if version_major >= 6000:
+ # TODO: take in consideration the host cpu
+ bin_dir = os.path.join(root, 'bin', 'x86', cpu_bin(target_cpu))
+ else:
+ if target_cpu == 'i386':
+ bin_dir = os.path.join(root, 'bin', 'x86')
+ else:
+ # TODO: take in consideration the host cpu
+ bin_dir = os.path.join(root, 'bin', 'win64', 'x86', cpu_bin(target_cpu))
+
+ crt_inc_dir = os.path.join(root, 'inc', 'crt')
+ if version_major >= 6000:
+ sdk_inc_dir = os.path.join(root, 'inc', 'api')
+ ddk_inc_dir = os.path.join(root, 'inc', 'ddk')
+ wdm_inc_dir = os.path.join(root, 'inc', 'ddk')
+ else:
+ ddk_inc_dir = os.path.join(root, 'inc', 'ddk', target_os)
+ sdk_inc_dir = os.path.join(root, 'inc', target_os)
+ wdm_inc_dir = os.path.join(root, 'inc', 'ddk', 'wdm', target_os)
+
+ if env['toolchain'] == 'winddk':
+ env.PrependENVPath('PATH', [bin_dir])
+ env.PrependENVPath('INCLUDE', [
+ wdm_inc_dir,
+ ddk_inc_dir,
+ crt_inc_dir,
+ sdk_inc_dir,
+ ])
+ env.PrependENVPath('LIB', [
+ os.path.join(root, 'lib', 'crt', target_cpu),
+ os.path.join(root, 'lib', target_os, target_cpu),
+ ])
+ elif env['toolchain'] == 'crossmingw':
+ env.Prepend(CPPFLAGS = [
+ '-isystem', ddk_inc_dir,
+ '-isystem', sdk_inc_dir,
+ ])
+ else:
+ env.Prepend(CPPPATH = [
+ wdm_inc_dir,
+ ddk_inc_dir,
+ sdk_inc_dir,
+ ])
+ env.Prepend(LIBPATH = [
+ os.path.join(root, 'lib', target_os, target_cpu),
+ ])
+
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ for version in versions:
+ root = get_winddk_root(env, version)
+ if root is not None:
+ get_winddk_paths(env, version, root)
+ break
+
+ if env['toolchain'] == 'winddk':
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
+
+def exists(env):
+ for version in versions:
+ if get_winddk_root(env, version) is not None:
+ return True
+ return False
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/winsdk.py b/mesalib/scons/winsdk.py
new file mode 100644
index 000000000..ab4369046
--- /dev/null
+++ b/mesalib/scons/winsdk.py
@@ -0,0 +1,131 @@
+"""winsdk
+
+Tool-specific initialization for Microsoft Windows SDK.
+
+"""
+
+#
+# Copyright (c) 2001-2007 The SCons Foundation
+# Copyright (c) 2008 Tungsten Graphics, Inc.
+# Copyright (c) 2009 VMware, 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 platform
+
+import SCons.Errors
+import SCons.Util
+
+import msvc_sa
+import mslib_sa
+import mslink_sa
+
+
+def get_vs_root(env):
+ # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7
+ path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0')
+ return path
+
+def get_vs_paths(env):
+ vs_root = get_vs_root(env)
+ if vs_root is None:
+ raise SCons.Errors.InternalError, "WINSDK compiler not found"
+
+ tool_path = os.path.join(vs_root, 'Common7', 'IDE')
+
+ env.PrependENVPath('PATH', tool_path)
+
+def get_vc_root(env):
+ # TODO: Check HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VC7
+ path = os.path.join(os.getenv('ProgramFiles', r'C:\Program Files'), 'Microsoft Visual Studio 9.0', 'VC')
+ return path
+
+def get_vc_paths(env):
+ vc_root = get_vc_root(env)
+ if vc_root is None:
+ raise SCons.Errors.InternalError, "WINSDK compiler not found"
+
+ target_cpu = env['machine']
+
+ if target_cpu in ('generic', 'x86'):
+ bin_dir = 'bin'
+ lib_dir = 'lib'
+ elif target_cpu == 'x86_64':
+ # TODO: take in consideration the host cpu
+ bin_dir = r'bin\x86_amd64'
+ lib_dir = r'lib\amd64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+ include_dir = 'include'
+
+ env.PrependENVPath('PATH', os.path.join(vc_root, bin_dir))
+ env.PrependENVPath('INCLUDE', os.path.join(vc_root, include_dir))
+ env.PrependENVPath('LIB', os.path.join(vc_root, lib_dir))
+
+def get_sdk_root(env):
+ if SCons.Util.can_read_reg:
+ key = r'SOFTWARE\Microsoft\Microsoft SDKs\Windows\CurrentInstallFolder'
+ try:
+ path, t = SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, key)
+ except SCons.Util.RegError:
+ pass
+ else:
+ return path
+
+ return None
+
+def get_sdk_paths(env):
+ sdk_root = get_sdk_root(env)
+ if sdk_root is None:
+ raise SCons.Errors.InternalError, "WINSDK not found"
+
+ target_cpu = env['machine']
+
+ bin_dir = 'Bin'
+ if target_cpu in ('generic', 'x86'):
+ lib_dir = 'Lib'
+ elif target_cpu == 'x86_64':
+ lib_dir = r'Lib\x64'
+ else:
+ raise SCons.Errors.InternalError, "Unsupported target machine"
+ include_dir = 'Include'
+
+ env.PrependENVPath('PATH', os.path.join(sdk_root, bin_dir))
+ env.PrependENVPath('INCLUDE', os.path.join(sdk_root, include_dir))
+ env.PrependENVPath('LIB', os.path.join(sdk_root, lib_dir))
+
+def generate(env):
+ if not env.has_key('ENV'):
+ env['ENV'] = {}
+
+ get_vs_paths(env)
+ get_vc_paths(env)
+ get_sdk_paths(env)
+
+ msvc_sa.generate(env)
+ mslib_sa.generate(env)
+ mslink_sa.generate(env)
+
+def exists(env):
+ return get_vc_root(env) is not None and get_sdk_root(env) is not None
+
+# vim:set ts=4 sw=4 et:
diff --git a/mesalib/scons/x11.py b/mesalib/scons/x11.py
new file mode 100644
index 000000000..86f090e37
--- /dev/null
+++ b/mesalib/scons/x11.py
@@ -0,0 +1,52 @@
+"""x11
+
+Tool-specific initialization for X11
+
+"""
+
+#
+# Copyright (c) 2010 VMware, 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.
+#
+
+
+def generate(env):
+ env.Append(CPPPATH = ['/usr/X11R6/include'])
+ env.Append(LIBPATH = ['/usr/X11R6/lib'])
+
+ env.Append(LIBS = [
+ 'X11',
+ 'Xext',
+ 'Xxf86vm',
+ 'Xdamage',
+ 'Xfixes',
+ ])
+
+
+def exists(env):
+ # TODO: actually detect the presence of the headers
+ if env['platform'] in ('linux', 'freebsd', 'darwin'):
+ return True
+ else:
+ return False
+
+
+# vim:set ts=4 sw=4 et: