scons: Expose pkg-config in a simpler manner.
This commit is contained in:
@@ -33,6 +33,8 @@ Custom builders and methods.
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
|
||||||
import SCons.Action
|
import SCons.Action
|
||||||
import SCons.Builder
|
import SCons.Builder
|
||||||
@@ -154,6 +156,79 @@ def createCodeGenerateMethod(env):
|
|||||||
env.AddMethod(code_generate, 'CodeGenerate')
|
env.AddMethod(code_generate, 'CodeGenerate')
|
||||||
|
|
||||||
|
|
||||||
|
def _pkg_check_modules(env, name, modules):
|
||||||
|
'''Simple wrapper for pkg-config.'''
|
||||||
|
|
||||||
|
env['HAVE_' + name] = False
|
||||||
|
|
||||||
|
# For backwards compatability
|
||||||
|
env[name.lower()] = False
|
||||||
|
|
||||||
|
if env['platform'] == 'windows':
|
||||||
|
return
|
||||||
|
|
||||||
|
if not env.Detect('pkg-config'):
|
||||||
|
return
|
||||||
|
|
||||||
|
if subprocess.call(["pkg-config", "--exists", ' '.join(modules)]) != 0:
|
||||||
|
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 --libs ' + ' '.join(modules))
|
||||||
|
except OSError:
|
||||||
|
return
|
||||||
|
prefix = name + '_'
|
||||||
|
for flag_name, flag_value in flags.iteritems():
|
||||||
|
assert '_' not in flag_name
|
||||||
|
env[prefix + flag_name] = flag_value
|
||||||
|
|
||||||
|
env['HAVE_' + name] = True
|
||||||
|
|
||||||
|
def pkg_check_modules(env, name, modules):
|
||||||
|
|
||||||
|
sys.stdout.write('Checking for %s...' % name)
|
||||||
|
_pkg_check_modules(env, name, modules)
|
||||||
|
result = env['HAVE_' + name]
|
||||||
|
sys.stdout.write(' %s\n' % ['no', 'yes'][int(bool(result))])
|
||||||
|
|
||||||
|
# XXX: For backwards compatability
|
||||||
|
env[name.lower()] = result
|
||||||
|
|
||||||
|
|
||||||
|
def pkg_use_modules(env, names):
|
||||||
|
'''Search for all environment flags that match NAME_FOO and append them to
|
||||||
|
the FOO environment variable.'''
|
||||||
|
|
||||||
|
names = env.Flatten(names)
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
prefix = name + '_'
|
||||||
|
|
||||||
|
if not 'HAVE_' + name in env:
|
||||||
|
print 'Attempt to use unknown module %s' % name
|
||||||
|
env.Exit(1)
|
||||||
|
|
||||||
|
if not env['HAVE_' + name]:
|
||||||
|
print 'Attempt to use unavailable module %s' % name
|
||||||
|
env.Exit(1)
|
||||||
|
|
||||||
|
flags = {}
|
||||||
|
for flag_name, flag_value in env.Dictionary().iteritems():
|
||||||
|
if flag_name.startswith(prefix):
|
||||||
|
flag_name = flag_name[len(prefix):]
|
||||||
|
if '_' not in flag_name:
|
||||||
|
flags[flag_name] = flag_value
|
||||||
|
if flags:
|
||||||
|
env.MergeFlags(flags)
|
||||||
|
|
||||||
|
|
||||||
|
def createPkgConfigMethods(env):
|
||||||
|
env.AddMethod(pkg_check_modules, 'PkgCheckModules')
|
||||||
|
env.AddMethod(pkg_use_modules, 'PkgUseModules')
|
||||||
|
|
||||||
|
|
||||||
def generate(env):
|
def generate(env):
|
||||||
"""Common environment generation code"""
|
"""Common environment generation code"""
|
||||||
|
|
||||||
@@ -164,6 +239,7 @@ def generate(env):
|
|||||||
# Custom builders and methods
|
# Custom builders and methods
|
||||||
createConvenienceLibBuilder(env)
|
createConvenienceLibBuilder(env)
|
||||||
createCodeGenerateMethod(env)
|
createCodeGenerateMethod(env)
|
||||||
|
createPkgConfigMethods(env)
|
||||||
|
|
||||||
# for debugging
|
# for debugging
|
||||||
#print env.Dump()
|
#print env.Dump()
|
||||||
|
@@ -104,41 +104,6 @@ def num_jobs():
|
|||||||
return 1
|
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):
|
def generate(env):
|
||||||
"""Common environment generation code"""
|
"""Common environment generation code"""
|
||||||
|
|
||||||
@@ -637,19 +602,21 @@ def generate(env):
|
|||||||
if env['llvm']:
|
if env['llvm']:
|
||||||
env.Tool('llvm')
|
env.Tool('llvm')
|
||||||
|
|
||||||
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
|
# Custom builders and methods
|
||||||
env.Tool('custom')
|
env.Tool('custom')
|
||||||
createInstallMethods(env)
|
createInstallMethods(env)
|
||||||
|
|
||||||
|
env.PkgCheckModules('X11', ['x11', 'xext', 'xdamage', 'xfixes'])
|
||||||
|
env.PkgCheckModules('XF86VIDMODE', ['xxf86vm'])
|
||||||
|
env.PkgCheckModules('DRM', ['libdrm'])
|
||||||
|
env.PkgCheckModules('DRM_INTEL', ['libdrm_intel'])
|
||||||
|
env.PkgCheckModules('DRM_RADEON', ['libdrm_radeon'])
|
||||||
|
env.PkgCheckModules('XORG', ['xorg-server'])
|
||||||
|
env.PkgCheckModules('KMS', ['libkms'])
|
||||||
|
env.PkgCheckModules('UDEV', ['libudev'])
|
||||||
|
|
||||||
|
env['dri'] = env['x11'] and env['drm']
|
||||||
|
|
||||||
# for debugging
|
# for debugging
|
||||||
#print env.Dump()
|
#print env.Dump()
|
||||||
|
|
||||||
|
@@ -2,11 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
try:
|
env.PkgUseModules('DRM_RADEON')
|
||||||
env.ParseConfig('pkg-config --cflags libdrm_radeon')
|
|
||||||
except OSError:
|
|
||||||
print 'warning: not building r600'
|
|
||||||
Return()
|
|
||||||
|
|
||||||
env.Append(CPPPATH = [
|
env.Append(CPPPATH = [
|
||||||
'#/include',
|
'#/include',
|
||||||
|
@@ -5,7 +5,7 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm')
|
env.PkgUseModules(['DRM'])
|
||||||
|
|
||||||
env.Append(CPPPATH = [
|
env.Append(CPPPATH = [
|
||||||
'#/src/mapi',
|
'#/src/mapi',
|
||||||
|
@@ -40,6 +40,7 @@ else:
|
|||||||
env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING'])
|
env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING'])
|
||||||
sources.append(['#/src/glx/dri2.c'])
|
sources.append(['#/src/glx/dri2.c'])
|
||||||
if env['drm']:
|
if env['drm']:
|
||||||
|
env.PkgUseModules('DRM')
|
||||||
env.Append(CPPDEFINES = ['HAVE_DRM_BACKEND'])
|
env.Append(CPPDEFINES = ['HAVE_DRM_BACKEND'])
|
||||||
env.Append(CPPPATH = [
|
env.Append(CPPPATH = [
|
||||||
'#/src/gbm/main',
|
'#/src/gbm/main',
|
||||||
|
@@ -9,10 +9,11 @@ env.Append(CPPPATH = [
|
|||||||
'#/src/mesa',
|
'#/src/mesa',
|
||||||
])
|
])
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
|
env.PkgUseModules(['DRM', 'XORG'])
|
||||||
|
|
||||||
if env['kms']:
|
if env['HAVE_KMS']:
|
||||||
env.Append(CPPDEFINES = ['HAVE_LIBKMS'])
|
env.Append(CPPDEFINES = ['HAVE_LIBKMS'])
|
||||||
|
env.PkgUseModules(['KMS'])
|
||||||
|
|
||||||
conf = env.Configure()
|
conf = env.Configure()
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ drienv.Replace(CPPPATH = [
|
|||||||
'#src/egl/drivers/dri',
|
'#src/egl/drivers/dri',
|
||||||
])
|
])
|
||||||
|
|
||||||
drienv.ParseConfig('pkg-config --cflags --libs libdrm')
|
drienv.PkgUseModules('DRM')
|
||||||
|
|
||||||
dri_common_utils = drienv.SharedObject(
|
dri_common_utils = drienv.SharedObject(
|
||||||
target = 'utils.o',
|
target = 'utils.o',
|
||||||
|
@@ -2,7 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = drienv.Clone()
|
env = drienv.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
|
env.PkgUseModules('DRM_INTEL')
|
||||||
|
|
||||||
env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
|
env.Append(CPPDEFINES = ['GALLIUM_RBUG', 'GALLIUM_TRACE', 'GALLIUM_GALAHAD'])
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = drienv.Clone()
|
env = drienv.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
|
env.PkgUseModules('DRM_INTEL')
|
||||||
|
|
||||||
env.Append(CPPDEFINES = [
|
env.Append(CPPDEFINES = [
|
||||||
'GALLIUM_SOFTPIPE',
|
'GALLIUM_SOFTPIPE',
|
||||||
|
@@ -39,4 +39,6 @@ module = env.LoadableModule(
|
|||||||
SHLIBPREFIX = '',
|
SHLIBPREFIX = '',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
module = env.InstallSharedLibrary(module)
|
||||||
|
|
||||||
env.Alias('dri-swrast', module)
|
env.Alias('dri-swrast', module)
|
||||||
|
@@ -79,21 +79,17 @@ if True:
|
|||||||
openvg_name = 'OpenVG' if env['platform'] != 'windows' else 'libOpenVG'
|
openvg_name = 'OpenVG' if env['platform'] != 'windows' else 'libOpenVG'
|
||||||
env.Prepend(LIBS = [openvg_name, st_vega])
|
env.Prepend(LIBS = [openvg_name, st_vega])
|
||||||
|
|
||||||
if env['x11']:
|
if env['HAVE_X11']:
|
||||||
env.Prepend(LIBS = [
|
env.Prepend(LIBS = [
|
||||||
ws_xlib,
|
ws_xlib,
|
||||||
env['X11_LIBS'],
|
|
||||||
])
|
])
|
||||||
|
env.PkgUseModules('X11')
|
||||||
if env['dri']:
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs xfixes')
|
|
||||||
|
|
||||||
# pipe drivers
|
# pipe drivers
|
||||||
if env['drm']:
|
if env['HAVE_DRM']:
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm')
|
env.PkgUseModules('DRM')
|
||||||
|
|
||||||
if env['drm_intel']:
|
if env['HAVE_DRM_INTEL']:
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm_intel')
|
|
||||||
env.Append(CPPDEFINES = ['_EGL_PIPE_I915', '_EGL_PIPE_I965'])
|
env.Append(CPPDEFINES = ['_EGL_PIPE_I915', '_EGL_PIPE_I965'])
|
||||||
env.Prepend(LIBS = [
|
env.Prepend(LIBS = [
|
||||||
i915drm,
|
i915drm,
|
||||||
@@ -103,7 +99,7 @@ if env['drm']:
|
|||||||
ws_wrapper,
|
ws_wrapper,
|
||||||
])
|
])
|
||||||
|
|
||||||
if env['drm_radeon']:
|
if env['HAVE_DRM_RADEON']:
|
||||||
env.Append(CPPDEFINES = ['_EGL_PIPE_R300', '_EGL_PIPE_R600'])
|
env.Append(CPPDEFINES = ['_EGL_PIPE_R300', '_EGL_PIPE_R600'])
|
||||||
env.Prepend(LIBS = [
|
env.Prepend(LIBS = [
|
||||||
radeonwinsys,
|
radeonwinsys,
|
||||||
|
@@ -4,10 +4,10 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags --libs libdrm xorg-server')
|
env.PkgUseModules(['DRM', 'XORG'])
|
||||||
|
|
||||||
if env['kms']:
|
if env['kms']:
|
||||||
env.ParseConfig('pkg-config --cflags --libs libkms')
|
env.PkgUseModules(['KMS'])
|
||||||
|
|
||||||
env.Prepend(CPPPATH = [
|
env.Prepend(CPPPATH = [
|
||||||
'#/include',
|
'#/include',
|
||||||
|
@@ -2,7 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags libdrm')
|
env.PkgUseModules('DRM')
|
||||||
|
|
||||||
i915drm_sources = [
|
i915drm_sources = [
|
||||||
'i915_drm_batchbuffer.c',
|
'i915_drm_batchbuffer.c',
|
||||||
|
@@ -2,7 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags libdrm')
|
env.PkgUseModules('DRM')
|
||||||
|
|
||||||
i965drm_sources = [
|
i965drm_sources = [
|
||||||
'i965_drm_buffer.c',
|
'i965_drm_buffer.c',
|
||||||
|
@@ -13,11 +13,7 @@ r600_sources = [
|
|||||||
'r600_bomgr.c',
|
'r600_bomgr.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
env.PkgUseModules('DRM_RADEON')
|
||||||
env.ParseConfig('pkg-config --cflags libdrm_radeon')
|
|
||||||
except OSError:
|
|
||||||
print 'warning: not building r600g'
|
|
||||||
Return()
|
|
||||||
|
|
||||||
env.Append(CPPPATH = '#/src/gallium/drivers/r600')
|
env.Append(CPPPATH = '#/src/gallium/drivers/r600')
|
||||||
|
|
||||||
|
@@ -8,11 +8,7 @@ radeon_sources = [
|
|||||||
'radeon_drm_winsys.c',
|
'radeon_drm_winsys.c',
|
||||||
]
|
]
|
||||||
|
|
||||||
try:
|
env.PkgUseModules('DRM')
|
||||||
env.ParseConfig('pkg-config --cflags libdrm')
|
|
||||||
except:
|
|
||||||
print 'warning: not building Gallium Radeon'
|
|
||||||
Return()
|
|
||||||
|
|
||||||
radeonwinsys = env.ConvenienceLibrary(
|
radeonwinsys = env.ConvenienceLibrary(
|
||||||
target ='radeonwinsys',
|
target ='radeonwinsys',
|
||||||
|
@@ -2,7 +2,7 @@ Import('*')
|
|||||||
|
|
||||||
env = env.Clone()
|
env = env.Clone()
|
||||||
|
|
||||||
env.ParseConfig('pkg-config --cflags libdrm')
|
env.PkgUseModules('DRM')
|
||||||
|
|
||||||
if env['gcc']:
|
if env['gcc']:
|
||||||
env.Append(CCFLAGS = ['-fvisibility=hidden'])
|
env.Append(CCFLAGS = ['-fvisibility=hidden'])
|
||||||
|
Reference in New Issue
Block a user