scons: better handling of PYTHON_INCLUDES and HAVE_LIBXML2

This commit is contained in:
Dane Springmeyer 2010-07-15 00:20:38 +00:00
parent d75fb586d0
commit 9a45c9d820
6 changed files with 42 additions and 18 deletions

View file

@ -324,7 +324,8 @@ pickle_store = [# Scons internal variables
'HAS_BOOST_SYSTEM', 'HAS_BOOST_SYSTEM',
'SVN_REVISION', 'SVN_REVISION',
'HAS_CAIRO', 'HAS_CAIRO',
'HAS_PYCAIRO' 'HAS_PYCAIRO',
'HAS_LIBXML2'
] ]
# Add all other user configurable options to pickle pickle_store # Add all other user configurable options to pickle pickle_store
@ -717,6 +718,7 @@ if not preconfigured:
env['SKIPPED_DEPS'] = [] env['SKIPPED_DEPS'] = []
env['HAS_CAIRO'] = False env['HAS_CAIRO'] = False
env['HAS_PYCAIRO'] = False env['HAS_PYCAIRO'] = False
env['HAS_LIBXML2'] = False
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
env['PLUGINS'] = PLUGINS env['PLUGINS'] = PLUGINS
@ -775,7 +777,7 @@ if not preconfigured:
env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL')
elif env['XMLPARSER'] == 'libxml2': elif env['XMLPARSER'] == 'libxml2':
if conf.parse_config('XML2_CONFIG'): if conf.parse_config('XML2_CONFIG'):
env.Append(CXXFLAGS = '-DHAVE_LIBXML2') env['HAS_LIBXML2'] = True
if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('cairomm-1.0'): if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('cairomm-1.0'):
env['HAS_CAIRO'] = True env['HAS_CAIRO'] = True
@ -1076,11 +1078,18 @@ if not preconfigured:
majver, minver = env['PYTHON_VERSION'].split('.') majver, minver = env['PYTHON_VERSION'].split('.')
# TODO - this needs to be moved up... # we don't want the includes it in the main environment...
env.AppendUnique(CPPPATH = env['PYTHON_INCLUDES']) # as they are later set in the python SConscript
if not conf.CheckHeader(header='Python.h',language='C'): # ugly hack needed until we have env specific conf
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION']) backup = env.Clone().Dictionary()
env['MISSING_DEPS'].append('python %s development headers' % env['PYTHON_VERSION']) env.AppendUnique(CPPPATH = env['PYTHON_INCLUDES'])
if not conf.CheckHeader(header='Python.h',language='C'):
color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION'])
env.Replace(**backup)
env['MISSING_DEPS'].append('python %s development headers' % env['PYTHON_VERSION'])
else:
env.Replace(**backup)
if (int(majver), int(minver)) < (2, 2): if (int(majver), int(minver)) < (2, 2):
color_print(1,"Python version 2.2 or greater required") color_print(1,"Python version 2.2 or greater required")

View file

@ -21,7 +21,9 @@ import glob
Import('env') Import('env')
agg_env = env.Clone()
if env['PLATFORM'] == 'SunOS': if env['PLATFORM'] == 'SunOS':
env.StaticLibrary('agg', glob.glob('./src/' + '*.cpp'), LIBS=[], CPPPATH='./include', CXXFLAGS='-O -KPIC -DNDEBUG') agg_env.StaticLibrary('agg', glob.glob('./src/' + '*.cpp'), LIBS=[], CPPPATH='./include', CXXFLAGS='-O -KPIC -DNDEBUG')
else: else:
env.StaticLibrary('agg', glob.glob('./src/' + '*.cpp'), LIBS=[], CPPPATH='./include', CXXFLAGS='-O%s -fPIC -DNDEBUG' % env['OPTIMIZATION']) agg_env.StaticLibrary('agg', glob.glob('./src/' + '*.cpp'), LIBS=[], CPPPATH='./include', CXXFLAGS='-O%s -fPIC -DNDEBUG' % env['OPTIMIZATION'])

View file

@ -30,7 +30,6 @@ install_prefix = env['DESTDIR'] + '/' + prefix
linkflags = '' linkflags = ''
libraries = ['mapnik','png','jpeg'] libraries = ['mapnik','png','jpeg']
headers = [env['PYTHON_INCLUDES']] + env['CPPPATH']
if env['BOOST_PYTHON_LIB']: if env['BOOST_PYTHON_LIB']:
if os.path.sep in env['BOOST_PYTHON_LIB']: if os.path.sep in env['BOOST_PYTHON_LIB']:
@ -138,9 +137,12 @@ env.Alias(target='install', source=ogcserver_module)
sources = glob.glob('*.cpp') sources = glob.glob('*.cpp')
py_env = env.Clone()
py_env.Append(CPPPATH = env['PYTHON_INCLUDES'])
if env['SVN_REVISION']: if env['SVN_REVISION']:
sources.remove('mapnik_python.cpp') sources.remove('mapnik_python.cpp')
env2 = env.Clone() env2 = py_env.Clone()
env2.Append(CCFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION']) env2.Append(CCFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION'])
if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: if env['HAS_CAIRO'] or env['HAS_PYCAIRO']:
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
@ -149,12 +151,11 @@ if env['SVN_REVISION']:
if env['HAS_PYCAIRO']: if env['HAS_PYCAIRO']:
env2.ParseConfig('pkg-config --cflags pycairo') env2.ParseConfig('pkg-config --cflags pycairo')
env2.Append(CXXFLAGS = '-DHAVE_PYCAIRO') env2.Append(CXXFLAGS = '-DHAVE_PYCAIRO')
sources.insert(0,env2.SharedObject('mapnik_python.cpp')) sources.insert(0,env2.SharedObject('mapnik_python.cpp'))
if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: if env['HAS_CAIRO'] or env['HAS_PYCAIRO']:
env2 = env.Clone() env2 = py_env.Clone()
env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0') env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0')
fixup = ['mapnik_image.cpp','python_cairo.cpp'] fixup = ['mapnik_image.cpp','python_cairo.cpp']
for cpp in fixup: for cpp in fixup:
if cpp in sources: if cpp in sources:
@ -166,6 +167,6 @@ if env['HAS_CAIRO'] or env['HAS_PYCAIRO']:
for cpp in fixup: for cpp in fixup:
sources.insert(0,env2.SharedObject(cpp)) sources.insert(0,env2.SharedObject(cpp))
_mapnik = env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so', CPPPATH=headers,LINKFLAGS=linkflags) _mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
pymapniklib = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik',_mapnik) pymapniklib = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik',_mapnik)
env.Alias(target='install',source=pymapniklib) env.Alias(target='install',source=pymapniklib)

View file

@ -119,10 +119,8 @@ if env['HAS_CAIRO']:
for cpp in fixup: for cpp in fixup:
if cpp in source: if cpp in source:
source.remove(cpp) source.remove(cpp)
for cpp in fixup:
source.insert(0,env2.SharedObject(cpp)) source.insert(0,env2.SharedObject(cpp))
if env['XMLPARSER'] == 'tinyxml': if env['XMLPARSER'] == 'tinyxml':
source += Split( source += Split(
""" """
@ -131,11 +129,18 @@ if env['XMLPARSER'] == 'tinyxml':
../tinyxml/tinyxmlerror.cpp ../tinyxml/tinyxmlerror.cpp
../tinyxml/tinyxmlparser.cpp ../tinyxml/tinyxmlparser.cpp
""") """)
elif env['XMLPARSER'] == 'libxml2': elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
source += Split( source += Split(
""" """
libxml2_loader.cpp libxml2_loader.cpp
""") """)
env2 = env.Clone()
env2.Append(CXXFLAGS = '-DHAVE_LIBXML2')
fixup = ['load_map.cpp','libxml2_loader.cpp']
for cpp in fixup:
if cpp in source:
source.remove(cpp)
source.insert(0,env2.SharedObject(cpp))
mapnik = env.SharedLibrary('mapnik', source, LIBS=libraries, LINKFLAGS=linkflags) mapnik = env.SharedLibrary('mapnik', source, LIBS=libraries, LINKFLAGS=linkflags)
if env['PLATFORM'] != 'Darwin': if env['PLATFORM'] != 'Darwin':

View file

@ -20,6 +20,8 @@
* *
*****************************************************************************/ *****************************************************************************/
#ifdef HAVE_LIBXML2
#include <mapnik/libxml2_loader.hpp> #include <mapnik/libxml2_loader.hpp>
#include <mapnik/config_error.hpp> #include <mapnik/config_error.hpp>
@ -222,3 +224,5 @@ namespace mapnik
} }
} // end of namespace mapnik } // end of namespace mapnik
#endif

View file

@ -34,7 +34,10 @@
#include <mapnik/font_set.hpp> #include <mapnik/font_set.hpp>
#include <mapnik/ptree_helpers.hpp> #include <mapnik/ptree_helpers.hpp>
#ifdef HAVE_LIBXML2
#include <mapnik/libxml2_loader.hpp> #include <mapnik/libxml2_loader.hpp>
#endif
// boost // boost
#include <boost/optional.hpp> #include <boost/optional.hpp>