scons: fix boost_regex and sqlite_rtree config checks and be resilient to plugins that cannot be built due to the boost version

This commit is contained in:
Dane Springmeyer 2013-06-02 14:56:21 -07:00
parent c5f01be4e2
commit ef1b99532b
3 changed files with 72 additions and 53 deletions

View file

@ -902,8 +902,7 @@ int main()
def boost_regex_has_icu(context): def boost_regex_has_icu(context):
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
context.env.Append(LIBS='icui18n') context.env.AppendUnique(LIBS='icudata')
context.env.Append(LIBS='icudata')
ret = context.TryRun(""" ret = context.TryRun("""
#include <boost/regex/icu.hpp> #include <boost/regex/icu.hpp>
@ -1299,6 +1298,9 @@ if not preconfigured:
if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']: if env['ICU_LIB_NAME'] not in env['MISSING_DEPS']:
# http://lists.boost.org/Archives/boost/2009/03/150076.php # http://lists.boost.org/Archives/boost/2009/03/150076.php
# we need libicui18n if using static boost libraries, so it is
# important to try this check with the library linked
env.AppendUnique(LIBS='icui18n')
if conf.boost_regex_has_icu(): if conf.boost_regex_has_icu():
# TODO - should avoid having this be globally defined... # TODO - should avoid having this be globally defined...
env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU') env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU')
@ -1307,7 +1309,7 @@ if not preconfigured:
env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
SQLITE_HAS_RTREE = conf.sqlite_has_rtree() SQLITE_HAS_RTREE = None
CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0') CHECK_PKG_CONFIG = conf.CheckPKGConfig('0.15.0')
if len(env['REQUESTED_PLUGINS']): if len(env['REQUESTED_PLUGINS']):
@ -1342,6 +1344,7 @@ if not preconfigured:
env.Replace(**backup) env.Replace(**backup)
env['SKIPPED_DEPS'].append(details['lib']) env['SKIPPED_DEPS'].append(details['lib'])
if plugin == 'sqlite': if plugin == 'sqlite':
SQLITE_HAS_RTREE = conf.sqlite_has_rtree()
sqlite_backup = env.Clone().Dictionary() sqlite_backup = env.Clone().Dictionary()
# if statically linking, on linux we likely # if statically linking, on linux we likely
@ -1358,6 +1361,8 @@ if not preconfigured:
except OSError,e: except OSError,e:
pass pass
if SQLITE_HAS_RTREE is None:
SQLITE_HAS_RTREE = conf.sqlite_has_rtree()
if not SQLITE_HAS_RTREE: if not SQLITE_HAS_RTREE:
env.Replace(**sqlite_backup) env.Replace(**sqlite_backup)
if details['lib'] in env['LIBS']: if details['lib'] in env['LIBS']:

View file

@ -19,44 +19,55 @@
# #
# #
Import ('plugin_base')
Import ('env') Import ('env')
PLUGIN_NAME = 'csv' can_build = False
plugin_env = plugin_base.Clone() if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1])
if boost_version_from_header >= 47:
can_build = True
plugin_sources = Split( if not can_build:
""" print 'WARNING: skipping building the optional geojson datasource plugin which requires boost >= 1.47'
%(PLUGIN_NAME)s_datasource.cpp else:
""" % locals() Import ('plugin_base')
)
# Link Library to Dependencies PLUGIN_NAME = 'csv'
libraries = []
libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append(env['ICU_LIB_NAME'])
if env['PLUGIN_LINKING'] == 'shared': plugin_env = plugin_base.Clone()
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME, plugin_sources = Split(
SHLIBPREFIX='', """
SHLIBSUFFIX='.input', %(PLUGIN_NAME)s_datasource.cpp
source=plugin_sources, """ % locals()
LIBS=libraries, )
LINKFLAGS=env.get('CUSTOM_LDFLAGS'))
# if the plugin links to libmapnik ensure it is built first # Link Library to Dependencies
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) libraries = []
libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append(env['ICU_LIB_NAME'])
if 'uninstall' not in COMMAND_LINE_TARGETS: if env['PLUGIN_LINKING'] == 'shared':
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET) libraries.append('mapnik')
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = { TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
'LIBS': libraries, SHLIBPREFIX='',
'SOURCES': plugin_sources, SHLIBSUFFIX='.input',
} source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env.get('CUSTOM_LDFLAGS'))
Return('plugin_obj') # if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -74,17 +74,17 @@ if env['TIFF']:
if len(env['EXTRA_FREETYPE_LIBS']): if len(env['EXTRA_FREETYPE_LIBS']):
lib_env['LIBS'].extend(copy(env['EXTRA_FREETYPE_LIBS'])) lib_env['LIBS'].extend(copy(env['EXTRA_FREETYPE_LIBS']))
# libxml2 should be optional but is currently not
# https://github.com/mapnik/mapnik/issues/913
lib_env['LIBS'].append('xml2') lib_env['LIBS'].append('xml2')
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND']) lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
if '-DBOOST_REGEX_HAS_ICU' in env['CPPDEFINES']:
lib_env['LIBS'].append('icui18n')
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
if 'icuuc' in env['ICU_LIB_NAME']: if 'icuuc' in env['ICU_LIB_NAME']:
lib_env['LIBS'].append('icudata') lib_env['LIBS'].append('icudata')
lib_env['LIBS'].append('icui18n')
else: else:
lib_env['LIBS'].insert(0, 'agg') lib_env['LIBS'].insert(0, 'agg')
@ -213,24 +213,27 @@ if env['PLUGIN_LINKING'] == 'static':
for plugin in env['REQUESTED_PLUGINS']: for plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin] details = env['PLUGINS'][plugin]
if details['lib'] in env['LIBS'] or not details['lib']: if details['lib'] in env['LIBS'] or not details['lib']:
hit = True
DEF = '-DMAPNIK_STATIC_PLUGIN_%s' % plugin.upper()
lib_env.Append(CPPDEFINES = DEF)
if DEF not in libmapnik_defines:
libmapnik_defines.append(DEF)
plugin_env = SConscript('../plugins/input/%s/build.py' % plugin) plugin_env = SConscript('../plugins/input/%s/build.py' % plugin)
if plugin_env.has_key('SOURCES') and plugin_env['SOURCES']: if not plugin_env:
source += ['../plugins/input/%s/%s' % (plugin, src) for src in plugin_env['SOURCES']] print("Notice: no 'plugin_env' variable found for plugin: '%s'" % plugin)
if plugin_env.has_key('CPPDEFINES') and plugin_env['CPPDEFINES']: else:
lib_env.AppendUnique(CPPDEFINES=plugin_env['CPPDEFINES']) hit = True
if plugin_env.has_key('CXXFLAGS') and plugin_env['CXXFLAGS']: DEF = '-DMAPNIK_STATIC_PLUGIN_%s' % plugin.upper()
lib_env.AppendUnique(CXXFLAGS=plugin_env['CXXFLAGS']) lib_env.Append(CPPDEFINES = DEF)
if plugin_env.has_key('LINKFLAGS') and plugin_env['LINKFLAGS']: if DEF not in libmapnik_defines:
lib_env.AppendUnique(LINKFLAGS=plugin_env['LINKFLAGS']) libmapnik_defines.append(DEF)
if plugin_env.has_key('CPPPATH') and plugin_env['CPPPATH']: if plugin_env.has_key('SOURCES') and plugin_env['SOURCES']:
lib_env.AppendUnique(CPPPATH=copy(plugin_env['CPPPATH'])) source += ['../plugins/input/%s/%s' % (plugin, src) for src in plugin_env['SOURCES']]
if plugin_env.has_key('LIBS') and plugin_env['LIBS']: if plugin_env.has_key('CPPDEFINES') and plugin_env['CPPDEFINES']:
lib_env.AppendUnique(LIBS=plugin_env['LIBS']) lib_env.AppendUnique(CPPDEFINES=plugin_env['CPPDEFINES'])
if plugin_env.has_key('CXXFLAGS') and plugin_env['CXXFLAGS']:
lib_env.AppendUnique(CXXFLAGS=plugin_env['CXXFLAGS'])
if plugin_env.has_key('LINKFLAGS') and plugin_env['LINKFLAGS']:
lib_env.AppendUnique(LINKFLAGS=plugin_env['LINKFLAGS'])
if plugin_env.has_key('CPPPATH') and plugin_env['CPPPATH']:
lib_env.AppendUnique(CPPPATH=copy(plugin_env['CPPPATH']))
if plugin_env.has_key('LIBS') and plugin_env['LIBS']:
lib_env.AppendUnique(LIBS=plugin_env['LIBS'])
else: else:
print("Notice: dependencies not met for plugin '%s', not building..." % plugin) print("Notice: dependencies not met for plugin '%s', not building..." % plugin)
if hit: if hit: