diff options
Diffstat (limited to 'scons')
-rw-r--r-- | scons/crossmingw.py | 2 | ||||
-rw-r--r-- | scons/gallium.py | 6 | ||||
-rw-r--r-- | scons/llvm.py | 139 | ||||
-rw-r--r-- | scons/x11.py | 52 |
4 files changed, 143 insertions, 56 deletions
diff --git a/scons/crossmingw.py b/scons/crossmingw.py index 03bfbd7eb3c..9533b2b362c 100644 --- a/scons/crossmingw.py +++ b/scons/crossmingw.py @@ -176,7 +176,7 @@ def generate(env): # 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(CCFLAGS = ['-gstabs']) env.AppendUnique(CPPDEFINES = [('__MSVCRT_VERSION__', '0x0700')]) #env.AppendUnique(LIBS = ['iberty']) diff --git a/scons/gallium.py b/scons/gallium.py index 925effc25d6..dd7275460da 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -142,8 +142,6 @@ def generate(env): # 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']: @@ -471,6 +469,10 @@ def generate(env): # Default libs env.Append(LIBS = []) + # Load LLVM + if env['llvm']: + env.Tool('llvm') + # Custom builders and methods env.Tool('custom') createInstallMethods(env) diff --git a/scons/llvm.py b/scons/llvm.py index 37c503ec986..d88d6e3a5ad 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -29,7 +29,9 @@ Tool-specific initialization for LLVM import os import os.path +import re import sys +import distutils.version import SCons.Errors import SCons.Util @@ -60,71 +62,102 @@ def generate(env): if env['platform'] == 'windows': # XXX: There is no llvm-config on Windows, so assume a standard layout - if llvm_dir is not None: - env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) - env.AppendUnique(CPPDEFINES = [ - '__STDC_LIMIT_MACROS', - '__STDC_CONSTANT_MACROS', - 'HAVE_STDINT_H', + if llvm_dir is None: + print 'scons: LLVM environment variable must be specified when building for windows' + env.Exit(1) + + # 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 + env.Exit(1) + 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 + env.Exit(1) + + 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', ]) - env.Prepend(LIBPATH = [os.path.join(llvm_dir, 'lib')]) + 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', + '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', - '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['debug']: - # 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']) - env['LLVM_VERSION'] = '2.6' - return - elif env.Detect('llvm-config'): - version = env.backtick('llvm-config --version').rstrip() + 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['debug']: + # 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 + env.Exit(1) + + 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 'llvm-config version %s failed' % version + print 'scons: llvm-config version %s failed' % llvm_version + env.Exit(1) else: - if env['platform'] == 'windows': - env.Append(LIBS = ['imagehlp', 'psapi']) env['LINK'] = env['CXX'] - env['LLVM_VERSION'] = version + + assert llvm_version is not None + + 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 diff --git a/scons/x11.py b/scons/x11.py new file mode 100644 index 00000000000..99bf079626e --- /dev/null +++ b/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: |