diff options
Diffstat (limited to 'scons')
-rw-r--r-- | scons/gallium.py | 109 | ||||
-rw-r--r-- | scons/llvm.py | 13 | ||||
-rw-r--r-- | scons/udis86.py | 4 |
3 files changed, 98 insertions, 28 deletions
diff --git a/scons/gallium.py b/scons/gallium.py index b065b7bc49f..75e9b9e7fc3 100644 --- a/scons/gallium.py +++ b/scons/gallium.py @@ -50,29 +50,34 @@ def symlink(target, source, env): def install(env, source, subdir): target_dir = os.path.join(env.Dir('#.').srcnode().abspath, env['build_dir'], subdir) - env.Install(target_dir, source) + return env.Install(target_dir, source) def install_program(env, source): - install(env, source, 'bin') + 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') - install(env, dlls, 'bin') + targets += install(env, dlls, 'bin') libs = env.FindIxes(sources, 'LIBPREFIX', 'LIBSUFFIX') - install(env, libs, 'lib') + 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') @@ -98,6 +103,41 @@ def num_jobs(): 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""" @@ -110,21 +150,27 @@ def generate(env): env['toolchain'] = 'wcesdk' env.Tool(env['toolchain']) - if env['platform'] == 'embedded': - # Allow overriding compiler 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) - + # 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' @@ -140,10 +186,16 @@ def generate(env): # Backwards compatability with the debug= profile= options if env['build'] == 'debug': if not env['debug']: - print 'scons: debug option is deprecated: use instead build=release' + 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: profile option is deprecated: use instead build=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 @@ -184,6 +236,9 @@ def generate(env): 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'): @@ -499,9 +554,19 @@ def generate(env): # Default libs env.Append(LIBS = []) - # Load LLVM + # 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') diff --git a/scons/llvm.py b/scons/llvm.py index 39fbb910b6d..1b033acb1b3 100644 --- a/scons/llvm.py +++ b/scons/llvm.py @@ -38,6 +38,8 @@ import SCons.Util def generate(env): + env['llvm'] = False + try: llvm_dir = os.environ['LLVM'] except KeyError: @@ -64,13 +66,13 @@ def generate(env): # 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' - env.Exit(1) + 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 - env.Exit(1) + return llvm_version_re = re.compile(r'^#define PACKAGE_VERSION "([^"]*)"') llvm_version = None for line in open(llvm_config, 'rt'): @@ -81,7 +83,7 @@ def generate(env): break if llvm_version is None: print 'scons: could not determine the LLVM version from %s' % llvm_config - env.Exit(1) + return env.Prepend(CPPPATH = [os.path.join(llvm_dir, 'include')]) env.AppendUnique(CPPDEFINES = [ @@ -133,7 +135,7 @@ def generate(env): else: if not env.Detect('llvm-config'): print 'scons: llvm-config script not found' % llvm_version - env.Exit(1) + return llvm_version = env.backtick('llvm-config --version').rstrip() llvm_version = distutils.version.LooseVersion(llvm_version) @@ -144,11 +146,12 @@ def generate(env): env.ParseConfig('llvm-config --ldflags') except OSError: print 'scons: llvm-config version %s failed' % llvm_version - env.Exit(1) + 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 diff --git a/scons/udis86.py b/scons/udis86.py index ba71d4eb0b8..bb91d3c35cf 100644 --- a/scons/udis86.py +++ b/scons/udis86.py @@ -31,8 +31,10 @@ def generate(env): conf = env.Configure() if conf.CheckHeader('udis86.h'): # and conf.CheckLib('udis86'): - env.Append(CPPDEFINES = [('HAVE_UDIS86', '1')]) + env['UDIS86'] = True env.Prepend(LIBS = ['udis86']) + else: + env['UDIS86'] = False conf.Finish() |