From b80bd6bc298e9398d13c6949a7f6cd1314da0395 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Mon, 29 Aug 2011 18:52:35 +0000 Subject: [PATCH] scons: allow passing CAIRO_LIBS and CAIRO_INCLUDES to optionally avoid pkg-config usage, and if pkg-config is needed and not found report cairo/cairomm will not be available - closes both #835 and #836 --- SConstruct | 101 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 85 insertions(+), 16 deletions(-) diff --git a/SConstruct b/SConstruct index 5489b92ec..0b7ef1b68 100644 --- a/SConstruct +++ b/SConstruct @@ -356,6 +356,8 @@ opts.AddVariables( # Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config # Therefore, we use a single boolean for whether to attempt to build cairo support. BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'), + PathVariable('CAIRO_INCLUDES', 'Search path for cairo/cairomm include files', '',PathVariable.PathAccept), + PathVariable('CAIRO_LIBS', 'Search path for cairo/cairomm library files','',PathVariable.PathAccept), ('GDAL_CONFIG', 'The path to the gdal-config executable for finding gdal and ogr details.', 'gdal-config'), ('PG_CONFIG', 'The path to the pg_config executable.', 'pg_config'), PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include', PathVariable.PathAccept), @@ -436,7 +438,13 @@ pickle_store = [# Scons internal variables 'MAPNIK_FONTS', 'MAPNIK_FONTS_DEST', 'MAPNIK_LIB_BASE', - 'MAPNIK_LIB_BASE_DEST' + 'MAPNIK_LIB_BASE_DEST', + 'EXTRA_FREETYPE_LIBS', + 'LIBMAPNIK_CPPATHS', + 'LIBMAPNIK_CXXFLAGS', + 'CAIROMM_LIBPATHS', + 'CAIROMM_LINKFLAGS', + 'CAIROMM_CPPPATHS', ] # Add all other user configurable options to pickle pickle_store @@ -950,12 +958,17 @@ if not preconfigured: env['MISSING_DEPS'] = [] env['SKIPPED_DEPS'] = [] env['HAS_CAIRO'] = False + env['CAIROMM_LIBPATHS'] = [] + env['CAIROMM_CPPPATHS'] = [] env['HAS_PYCAIRO'] = False env['HAS_LIBXML2'] = False env['SVN_REVISION'] = None env['LIBMAPNIK_LIBS'] = [] + env['LIBMAPNIK_CPPATHS'] = [] + env['LIBMAPNIK_CXXFLAGS'] = [] env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA env['PLUGINS'] = PLUGINS + env['EXTRA_FREETYPE_LIBS'] = [] # previously a leading / was expected for LIB_DIR_NAME # now strip it to ensure expected behavior @@ -1055,8 +1068,16 @@ if not preconfigured: env.AppendUnique(CPPPATH = os.path.realpath(inc_path)) env.AppendUnique(LIBPATH = os.path.realpath(lib_path)) + conf.parse_config('FREETYPE_CONFIG') + # check if freetype links to bz2 + temp_env = env.Clone() + temp_env['LIBS'] = [] + temp_env.ParseConfig('%s --libs' % env['FREETYPE_CONFIG']) + if 'bz2' in temp_env['LIBS']: + env['EXTRA_FREETYPE_LIBS'].append('bz2') + if env['XMLPARSER'] == 'tinyxml': env['CPPPATH'].append('#tinyxml') env.Append(CXXFLAGS = '-DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL') @@ -1193,8 +1214,9 @@ if not preconfigured: # Note, the 'delete_existing' keyword makes sure that these paths are prepended # to the beginning of the path list even if they already exist incpath = env['%s_INCLUDES' % details['path']] + libpath = env['%s_LIBS' % details['path']] env.PrependUnique(CPPPATH = os.path.realpath(incpath),delete_existing=True) - env.PrependUnique(LIBPATH = env['%s_LIBS' % details['path']],delete_existing=True) + env.PrependUnique(LIBPATH = os.path.realpath(libpath),delete_existing=True) if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']): env.Replace(**backup) env['SKIPPED_DEPS'].append(details['lib']) @@ -1231,20 +1253,67 @@ if not preconfigured: env.ParseConfig('pkg-config --libs --cflags libagg') if env['CAIRO']: - if not conf.CheckPKGConfig('0.15.0'): - env['HAS_CAIRO'] = False - env['SKIPPED_DEPS'].append('pkg-config') - elif not conf.CheckPKG('cairo'): - env['HAS_CAIRO'] = False - env['SKIPPED_DEPS'].append('cairo') - elif not conf.CheckPKG('cairomm-1.0'): - env['HAS_CAIRO'] = False - env['SKIPPED_DEPS'].append('cairomm') - elif not conf.CheckPKGVersion('cairomm-1.0',CAIROMM_MIN_VERSION): - env['HAS_CAIRO'] = False - env['SKIPPED_DEPS'].append('cairomm-version') + if env['CAIRO_LIBS'] or env['CAIRO_INCLUDES']: + c_inc = env['CAIRO_INCLUDES'] + if env['CAIRO_LIBS']: + env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS'])) + if not env['CAIRO_INCLUDES']: + c_inc = env['CAIRO_LIBS'].replace('lib','',1) + if c_inc: + c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES'])) + if c_inc.endswith('include'): + c_inc = os.path.dirname(c_inc) + env["CAIROMM_CPPPATHS"].extend( + [ + os.path.join(c_inc,'include/cairomm-1.0'), + os.path.join(c_inc,'lib/cairomm-1.0/include'), + os.path.join(c_inc,'include/cairo'), + os.path.join(c_inc,'include/sigc++-2.0'), + os.path.join(c_inc,'lib/sigc++-2.0/include'), + os.path.join(c_inc,'include/pixman-1'), + #os.path.join(c_inc,'include/freetype2'), + #os.path.join(c_inc,'include/libpng'), + ] + ) + env["CAIROMM_LINKFLAGS"] = ['cairo','cairomm-1.0'] + if env['RUNTIME_LINK'] == 'static': + env["CAIROMM_LINKFLAGS"].extend( + ['sigc-2.0','pixman-1','expat','fontconfig','iconv'] + ) + # todo - run actual checkLib? + env['HAS_CAIRO'] = True else: - env['HAS_CAIRO'] = True + if not conf.CheckPKGConfig('0.15.0'): + env['HAS_CAIRO'] = False + env['SKIPPED_DEPS'].append('pkg-config') + env['SKIPPED_DEPS'].append('cairo') + env['SKIPPED_DEPS'].append('cairomm') + elif not conf.CheckPKG('cairo'): + env['HAS_CAIRO'] = False + env['SKIPPED_DEPS'].append('cairo') + elif not conf.CheckPKG('cairomm-1.0'): + env['HAS_CAIRO'] = False + env['SKIPPED_DEPS'].append('cairomm') + elif not conf.CheckPKGVersion('cairomm-1.0',CAIROMM_MIN_VERSION): + env['HAS_CAIRO'] = False + env['SKIPPED_DEPS'].append('cairomm-version') + else: + cmd = 'pkg-config --libs --cflags cairomm-1.0' + if env['RUNTIME_LINK'] == 'static': + cmd += ' --static' + cairo_env = env.Clone() + cairo_env.ParseConfig(cmd) + for lib in cairo_env['LIBS']: + if not lib in env['LIBS']: + env["CAIROMM_LINKFLAGS"].append(lib) + for lpath in cairo_env['LIBPATH']: + if not lpath in env['LIBPATH']: + env["CAIROMM_LIBPATHS"].append(lpath) + for inc in cairo_env['CPPPATH']: + if not inc in env['CPPPATH']: + env["CAIROMM_CPPPATHS"].append(inc) + env['HAS_CAIRO'] = True + else: color_print(4,'Not building with cairo support, pass CAIRO=True to enable') @@ -1269,7 +1338,7 @@ if not preconfigured: if env['MISSING_DEPS']: # if required dependencies are missing, print warnings and then let SCons finish without building or saving local config color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']])) - color_print(1,"\nSee '%s' for details on possible problems." % (os.path.abspath(SCONS_LOCAL_LOG))) + color_print(1,"\nSee '%s' for details on possible problems." % (os.path.realpath(SCONS_LOCAL_LOG))) if env['SKIPPED_DEPS']: color_print(4,'\nAlso, these OPTIONAL dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['SKIPPED_DEPS']])) color_print(4,"\nSet custom paths to these libraries and header files on the command-line or in a file called '%s'" % SCONS_LOCAL_CONFIG)