From 836a9f0ae6e03d2f92dc024703015c25a5b3c353 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 1 Sep 2009 12:22:52 +0100 Subject: scons: Tool for LLVM. Gracefully disable llvmpipe if LLVM not found. --- scons/llvm.py | 81 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 scons/llvm.py (limited to 'scons/llvm.py') diff --git a/scons/llvm.py b/scons/llvm.py new file mode 100644 index 0000000000..14306bc0fe --- /dev/null +++ b/scons/llvm.py @@ -0,0 +1,81 @@ +"""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 subprocess + +import SCons.Action +import SCons.Errors +import SCons.Util + + +def generate(env): + try: + llvm_dir = os.environ['LLVM'] + except KeyError: + # Do nothing -- use the system headers/libs + pass + 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): + raise SCons.Errors.InternalError, "LLVM build directory not found" + + env.PrependENVPath('PATH', llvm_bin_dir) + + if env.Detect('llvm-config'): + pipe = SCons.Action._subproc(env, + ['llvm-config', '--version'], + stdin = 'devnull', + stderr = 'devnull', + stdout = subprocess.PIPE) + if pipe.wait() != 0: + return + line = pipe.stdout.read().strip() + if not line: + return + env['LLVM_VERSION'] = line + + env.ParseConfig('llvm-config --cppflags') + env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') + env.ParseConfig('llvm-config --ldflags') + env['LINK'] = env['CXX'] + +def exists(env): + return True + +# vim:set ts=4 sw=4 et: -- cgit v1.2.3 From b9f56078cd8b68e3f473d23232c1aa2f0f664a19 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 4 Sep 2009 19:33:41 +0100 Subject: scons: Don't use scons internal functions. --- scons/llvm.py | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'scons/llvm.py') diff --git a/scons/llvm.py b/scons/llvm.py index 14306bc0fe..53cf71c03f 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -29,9 +29,7 @@ Tool-specific initialization for LLVM import os import os.path -import subprocess -import SCons.Action import SCons.Errors import SCons.Util @@ -58,17 +56,10 @@ def generate(env): env.PrependENVPath('PATH', llvm_bin_dir) if env.Detect('llvm-config'): - pipe = SCons.Action._subproc(env, - ['llvm-config', '--version'], - stdin = 'devnull', - stderr = 'devnull', - stdout = subprocess.PIPE) - if pipe.wait() != 0: - return - line = pipe.stdout.read().strip() - if not line: - return - env['LLVM_VERSION'] = line + try: + env['LLVM_VERSION'] = env.backtick('llvm-config --version') + except NameError: + env['LLVM_VERSION'] = 'X.X' env.ParseConfig('llvm-config --cppflags') env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') -- cgit v1.2.3 From 9216b4e7be942fed432ceb42a4337d7298d0bc6c Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 4 Sep 2009 19:38:35 +0100 Subject: scons: Used wrong exception class. --- scons/llvm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scons/llvm.py') diff --git a/scons/llvm.py b/scons/llvm.py index 53cf71c03f..702f1e354f 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -58,7 +58,7 @@ def generate(env): if env.Detect('llvm-config'): try: env['LLVM_VERSION'] = env.backtick('llvm-config --version') - except NameError: + except AttributeError: env['LLVM_VERSION'] = 'X.X' env.ParseConfig('llvm-config --cppflags') -- cgit v1.2.3 From 79f48c9f9e739a1f6b0810072e41bc826f2b789d Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Mon, 7 Sep 2009 15:16:25 +0100 Subject: scons: Don't set LLVM_VERSION if one of the llvm-config calls fails. Ubuntu 8.10 has llvm-config version 2.2, which doesn't have nativecodegen. This triggers an exception. --- scons/llvm.py | 18 ++++++++++-------- src/gallium/drivers/llvmpipe/SConscript | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'scons/llvm.py') diff --git a/scons/llvm.py b/scons/llvm.py index 702f1e354f..46a8d829ca 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -56,15 +56,17 @@ def generate(env): env.PrependENVPath('PATH', llvm_bin_dir) if env.Detect('llvm-config'): - try: - env['LLVM_VERSION'] = env.backtick('llvm-config --version') - except AttributeError: - env['LLVM_VERSION'] = 'X.X' + version = env.backtick('llvm-config --version').rstrip() - env.ParseConfig('llvm-config --cppflags') - env.ParseConfig('llvm-config --libs jit interpreter nativecodegen bitwriter') - env.ParseConfig('llvm-config --ldflags') - env['LINK'] = env['CXX'] + 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 + else: + env['LINK'] = env['CXX'] + env['LLVM_VERSION'] = version def exists(env): return True diff --git a/src/gallium/drivers/llvmpipe/SConscript b/src/gallium/drivers/llvmpipe/SConscript index ac1b5d6d1d..dea4b703c4 100644 --- a/src/gallium/drivers/llvmpipe/SConscript +++ b/src/gallium/drivers/llvmpipe/SConscript @@ -3,7 +3,7 @@ Import('*') env = env.Clone() env.Tool('llvm') -if 'LLVM_VERSION' not in env: +if env.has_key('LLVM_VERSION') is False: print 'warning: LLVM not found: not building llvmpipe' Return() -- cgit v1.2.3