From 08e96be4a12b152fafe15d5aefb8c9d38bf51232 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Thu, 15 Jul 2010 00:20:50 +0000 Subject: [PATCH] scons: better handling of PYTHON_INCLUDES and HAVE_LIBXML2 --- SConstruct | 15 ++++++++++++--- agg/SConscript | 6 ++++-- bindings/python/SConscript | 14 +++++++++----- src/SConscript | 12 +++++++++--- src/libxml2_loader.cpp | 4 ++++ src/load_map.cpp | 2 ++ 6 files changed, 40 insertions(+), 13 deletions(-) diff --git a/SConstruct b/SConstruct index b68c55c85..413d33229 100644 --- a/SConstruct +++ b/SConstruct @@ -333,7 +333,8 @@ pickle_store = [# Scons internal variables 'HAS_BOOST_SYSTEM', 'SVN_REVISION', 'HAS_CAIRO', - 'HAS_PYCAIRO' + 'HAS_PYCAIRO', + 'HAS_LIBXML2' ] # Add all other user configurable options to pickle pickle_store @@ -726,6 +727,7 @@ if not preconfigured: env['SKIPPED_DEPS'] = [] env['HAS_CAIRO'] = False env['HAS_PYCAIRO'] = False + env['HAS_LIBXML2'] = False env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA env['PLUGINS'] = PLUGINS @@ -778,7 +780,7 @@ if not preconfigured: env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') elif env['XMLPARSER'] == 'libxml2': 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'): env['HAS_CAIRO'] = True @@ -1084,11 +1086,18 @@ if not preconfigured: majver, minver = env['PYTHON_VERSION'].split('.') - # TODO - this needs to be moved up... + # we don't want the includes it in the main environment... + # as they are later set in the python SConscript + # ugly hack needed until we have env specific conf + backup = env.Clone().Dictionary() 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): color_print(1,"Python version 2.2 or greater required") diff --git a/agg/SConscript b/agg/SConscript index ce9a3321b..90cd27ada 100644 --- a/agg/SConscript +++ b/agg/SConscript @@ -21,7 +21,9 @@ import glob Import('env') +agg_env = env.Clone() + 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: - 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']) diff --git a/bindings/python/SConscript b/bindings/python/SConscript index d6b9f9f07..a72a82ea7 100644 --- a/bindings/python/SConscript +++ b/bindings/python/SConscript @@ -30,7 +30,6 @@ install_prefix = env['DESTDIR'] + '/' + prefix linkflags = '' libraries = ['mapnik2','png','jpeg'] -headers = [env['PYTHON_INCLUDES']] + env['CPPPATH'] if env['BOOST_PYTHON_LIB']: if os.path.sep in env['BOOST_PYTHON_LIB']: @@ -141,9 +140,12 @@ env.Alias(target='install', source=ogcserver_module) sources = glob.glob('*.cpp') +py_env = env.Clone() +py_env.Append(CPPPATH = env['PYTHON_INCLUDES']) + if env['SVN_REVISION']: sources.remove('mapnik_python.cpp') - env2 = env.Clone() + env2 = py_env.Clone() env2.Append(CCFLAGS='-DSVN_REVISION=%s' % env['SVN_REVISION']) if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: if env['HAS_CAIRO']: @@ -155,7 +157,7 @@ if env['SVN_REVISION']: sources.insert(0,env2.SharedObject('mapnik_python.cpp')) if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: - env2 = env.Clone() + env2 = py_env.Clone() env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0') fixup = ['mapnik_image.cpp','python_cairo.cpp'] for cpp in fixup: @@ -168,6 +170,8 @@ if env['HAS_CAIRO'] or env['HAS_PYCAIRO']: for cpp in fixup: sources.insert(0,env2.SharedObject(cpp)) -_mapnik = env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so', CPPPATH=headers,LINKFLAGS=linkflags) + +_mapnik = py_env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) + pymapniklib = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik2',_mapnik) -env.Alias(target='install',source=pymapniklib) +py_env.Alias(target='install',source=pymapniklib) diff --git a/src/SConscript b/src/SConscript index d4f3f224e..abacbc979 100644 --- a/src/SConscript +++ b/src/SConscript @@ -150,12 +150,11 @@ if True : # agg backend if env['HAS_CAIRO']: env2 = env.Clone() env2.Append(CXXFLAGS = '-DHAVE_CAIRO') - env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0') + env2.ParseConfig('pkg-config --libs --cflags cairomm-1.0') fixup = ['cairo_renderer.cpp','graphics.cpp','image_util.cpp'] for cpp in fixup: if cpp in source: source.remove(cpp) - for cpp in fixup: source.insert(0,env2.SharedObject(cpp)) if env['XMLPARSER'] == 'tinyxml': @@ -166,11 +165,18 @@ if env['XMLPARSER'] == 'tinyxml': ../tinyxml/tinyxmlerror.cpp ../tinyxml/tinyxmlparser.cpp """) -elif env['XMLPARSER'] == 'libxml2': +elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']: source += Split( """ 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('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags) if env['PLATFORM'] != 'Darwin': diff --git a/src/libxml2_loader.cpp b/src/libxml2_loader.cpp index d8eca3dec..00e3d2ac1 100644 --- a/src/libxml2_loader.cpp +++ b/src/libxml2_loader.cpp @@ -20,6 +20,8 @@ * *****************************************************************************/ +#ifdef HAVE_LIBXML2 + #include #include @@ -222,3 +224,5 @@ void read_xml2_string( std::string const & str, boost::property_tree::ptree & pt } } // end of namespace mapnik + +#endif diff --git a/src/load_map.cpp b/src/load_map.cpp index 8be34d54d..a64438060 100644 --- a/src/load_map.cpp +++ b/src/load_map.cpp @@ -33,7 +33,9 @@ #include #include +#ifdef HAVE_LIBXML2 #include +#endif #include #include