def generate(env):
+ env['llvm'] = False
+
try:
llvm_dir = os.environ['LLVM']
except KeyError:
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
print 'scons: could not determine the LLVM version from %s' % llvm_config
return
- if llvm_version >= distutils.version.LooseVersion('2.7'):
- print 'scons: Ignoring unsupported LLVM version %s' % llvm_version
- print 'scons: See http://www.llvm.org/bugs/show_bug.cgi?id=6429'
- return
-
env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')])
env.AppendUnique(CPPDEFINES = [
'__STDC_LIMIT_MACROS',
# Some of the LLVM C headers use the inline keyword without
# defining it.
env.Append(CPPDEFINES = [('inline', '__inline')])
- if env['debug']:
+ 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'])
- elif env.Detect('llvm-config'):
+ 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)
- if llvm_version >= distutils.version.LooseVersion('2.7'):
- print 'scons: Ignoring unsupported LLVM version %s' % llvm_version
- print 'scons: See http://www.llvm.org/bugs/show_bug.cgi?id=6429'
- return
-
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' % llvm_version
+ print 'scons: llvm-config version %s failed' % llvm_version
+ return
else:
env['LINK'] = env['CXX']
- else:
- return
assert llvm_version is not None
+ env['llvm'] = True
print 'scons: Found LLVM version %s' % llvm_version
env['LLVM_VERSION'] = llvm_version