summaryrefslogtreecommitdiff
path: root/scons
diff options
context:
space:
mode:
authorJosé Fonseca <jfonseca@vmware.com>2010-11-01 13:30:22 +0000
committerJosé Fonseca <jfonseca@vmware.com>2010-11-01 13:30:22 +0000
commit601498ae73e654c2de997ea75075613a694d604d (patch)
treefb1eb85143f5222b3c4b4d059276095e658506f5 /scons
parenta84bd587c68a48c675aae538934a0de48421ff08 (diff)
scons: Revamp how to specify targets to build.
Use scons target and dependency system instead of ad-hoc options. Now is simply a matter of naming what to build. For example: scons libgl-xlib scons libgl-gdi scons graw-progs scons llvmpipe and so on. And there is also the possibility of scepcified subdirs, e.g. scons src/gallium/drivers If nothing is specified then everything will be build. There might be some rough corners over the next days. Please bare with me.
Diffstat (limited to 'scons')
-rw-r--r--scons/gallium.py88
-rw-r--r--scons/llvm.py13
-rw-r--r--scons/udis86.py4
-rw-r--r--scons/x11.py18
4 files changed, 84 insertions, 39 deletions
diff --git a/scons/gallium.py b/scons/gallium.py
index b065b7bc49..194b1524e6 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -98,6 +98,38 @@ 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
+
+ # 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 +142,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 +178,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 +228,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 +546,14 @@ 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, 'dri', ['libdrm'])
+ pkg_config_modules(env, 'xorg', ['xorg-server'])
# Custom builders and methods
env.Tool('custom')
diff --git a/scons/llvm.py b/scons/llvm.py
index 39fbb910b6..1b033acb1b 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 ba71d4eb0b..bb91d3c35c 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()
diff --git a/scons/x11.py b/scons/x11.py
index 99bf079626..7368618f3b 100644
--- a/scons/x11.py
+++ b/scons/x11.py
@@ -29,24 +29,12 @@ Tool-specific initialization for X11
def generate(env):
- env.Append(CPPPATH = ['/usr/X11R6/include'])
- env.Append(LIBPATH = ['/usr/X11R6/lib'])
-
- env.Append(LIBS = [
- 'X11',
- 'Xext',
- 'Xxf86vm',
- 'Xdamage',
- 'Xfixes',
- ])
+ # XXX: backwards compatability only
+ pass
def exists(env):
- # TODO: actually detect the presence of the headers
- if env['platform'] in ('linux', 'freebsd', 'darwin'):
- return True
- else:
- return False
+ return True
# vim:set ts=4 sw=4 et: