From e2c72835221a907cb5edad2a63de99603f0fe90d Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 13 Mar 2013 19:49:59 -0700 Subject: [PATCH] Added new mapnik-config options: git-describe, defines, includes, dep-includes, and cxxflags - closes #1443 --- CHANGELOG.md | 2 + Makefile | 1 + SConstruct | 77 +++++------- bindings/python/build.py | 4 +- demo/c++/build.py | 2 +- plugins/input/shape/build.py | 2 +- src/build.py | 16 +-- tests/cpp_tests/build.py | 2 +- tests/python_tests/mapnik_config_test.py | 94 ++++++++++---- utils/mapnik-config/build.py | 56 +++++---- utils/mapnik-config/mapnik-config.template.sh | 116 +++++++++--------- utils/pgsql2sqlite/build.py | 2 +- utils/svg2png/build.py | 2 +- 13 files changed, 209 insertions(+), 167 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a7978afcf..25229725c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ For a complete change history, see the git log. ## Future +- Added new mapnik-config options: `git-describe`, `defines`, `includes`, `dep-includes`, and `cxxflags` (#1443) + - Added `text-halo-rasterizer` property. Set to `fast` for lower quality but faster halo rendering (#1298) diff --git a/Makefile b/Makefile index 8907c5bf9..5ce0b85bf 100755 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ test: test-local: @echo "*** Boostrapping local test environment..." @export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \ + export PATH=`pwd`/utils/mapnik-config/:${PATH} && \ export PYTHONPATH=`pwd`/bindings/python/:${PYTHONPATH} && \ export MAPNIK_FONT_DIRECTORY=`pwd`/fonts/dejavu-fonts-ttf-2.33/ttf/ && \ export MAPNIK_INPUT_PLUGINS_DIRECTORY=`pwd`/plugins/input/ && \ diff --git a/SConstruct b/SConstruct index b3b30c4fb..058e121a5 100644 --- a/SConstruct +++ b/SConstruct @@ -261,6 +261,7 @@ opts.AddVariables( ('CXX', 'The C++ compiler to use to compile mapnik (defaults to g++).', 'g++'), ('CC', 'The C compiler used for configure checks of C libs (defaults to gcc).', 'gcc'), ('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I if you have headers in a nonstandard directory ', ''), + ('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''), ('CUSTOM_CFLAGS', 'Custom C flags, e.g. -I if you have headers in a nonstandard directory (only used for configure checks)', ''), ('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L if you have libraries in a nonstandard directory ', ''), EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']), @@ -388,6 +389,7 @@ pickle_store = [# Scons internal variables 'LIBS', 'LINKFLAGS', 'CUSTOM_LDFLAGS', # user submitted + 'CUSTOM_DEFINES', # user submitted 'CUSTOM_CXXFLAGS', # user submitted 'CUSTOM_CFLAGS', # user submitted 'MAPNIK_LIB_NAME', @@ -428,6 +430,7 @@ pickle_store = [# Scons internal variables 'MAPNIK_LIB_BASE_DEST', 'EXTRA_FREETYPE_LIBS', 'LIBMAPNIK_CPPATHS', + 'LIBMAPNIK_DEFINES', 'LIBMAPNIK_CXXFLAGS', 'CAIRO_LIBPATHS', 'CAIRO_LINKFLAGS', @@ -1009,6 +1012,7 @@ if not preconfigured: env['HAS_LIBXML2'] = False env['LIBMAPNIK_LIBS'] = [] env['LIBMAPNIK_CPPATHS'] = [] + env['LIBMAPNIK_DEFINES'] = [] env['LIBMAPNIK_CXXFLAGS'] = [] env['PLUGINS'] = PLUGINS env['EXTRA_FREETYPE_LIBS'] = [] @@ -1068,6 +1072,7 @@ if not preconfigured: env['LIBPATH'] = ['#src'] # set any custom cxxflags and ldflags to come first + env.Append(CPPDEFINES = env['CUSTOM_DEFINES']) env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) env.Append(CFLAGS = env['CUSTOM_CFLAGS']) env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS']) @@ -1101,8 +1106,8 @@ if not preconfigured: # http://www.opensource.apple.com/tarballs/ICU/ # then copy the headers to a location that mapnik will find if 'core' in env['ICU_LIB_NAME']: - env.Append(CXXFLAGS = '-DU_HIDE_DRAFT_API') - env.Append(CXXFLAGS = '-DUDISABLE_RENAMING') + env.Append(CPPDEFINES = '-DU_HIDE_DRAFT_API') + env.Append(CPPDEFINES = '-DUDISABLE_RENAMING') if os.path.exists(env['ICU_LIB_NAME']): #-sICU_LINK=" -L/usr/lib -licucore env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','') @@ -1139,7 +1144,7 @@ if not preconfigured: ] if env['JPEG']: - env.Append(CXXFLAGS = '-DHAVE_JPEG') + env.Append(CPPDEFINES = '-DHAVE_JPEG') LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], True,'C']) inc_path = env['%s_INCLUDES' % 'JPEG'] lib_path = env['%s_LIBS' % 'JPEG'] @@ -1149,7 +1154,7 @@ if not preconfigured: env['SKIPPED_DEPS'].extend(['jpeg']) if env['PROJ']: - env.Append(CXXFLAGS = '-DMAPNIK_USE_PROJ4') + env.Append(CPPDEFINES = '-DMAPNIK_USE_PROJ4') LIBSHEADERS.append(['proj', 'proj_api.h', True,'C']) inc_path = env['%s_INCLUDES' % 'PROJ'] lib_path = env['%s_LIBS' % 'PROJ'] @@ -1159,7 +1164,7 @@ if not preconfigured: env['SKIPPED_DEPS'].extend(['proj']) if env['PNG']: - env.Append(CXXFLAGS = '-DHAVE_PNG') + env.Append(CPPDEFINES = '-DHAVE_PNG') LIBSHEADERS.append(['png', 'png.h', True,'C']) inc_path = env['%s_INCLUDES' % 'PNG'] lib_path = env['%s_LIBS' % 'PNG'] @@ -1169,7 +1174,7 @@ if not preconfigured: env['SKIPPED_DEPS'].extend(['png']) if env['TIFF']: - env.Append(CXXFLAGS = '-DHAVE_TIFF') + env.Append(CPPDEFINES = '-DHAVE_TIFF') LIBSHEADERS.append(['tiff', 'tiff.h', True,'C']) inc_path = env['%s_INCLUDES' % 'TIFF'] lib_path = env['%s_LIBS' % 'TIFF'] @@ -1197,7 +1202,7 @@ if not preconfigured: env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) if env['BIGINT']: - env.Append(CXXFLAGS = '-DBIGINT') + env.Append(CPPDEFINES = '-DBIGINT') if env['THREADING'] == 'multi': thread_flag = thread_suffix @@ -1252,7 +1257,7 @@ if not preconfigured: # http://lists.boost.org/Archives/boost/2009/03/150076.php if conf.boost_regex_has_icu(): # TODO - should avoid having this be globally defined... - env.Append(CXXFLAGS = '-DBOOST_REGEX_HAS_ICU') + env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU') else: env['SKIPPED_DEPS'].append('boost_regex_icu') @@ -1535,29 +1540,22 @@ if not preconfigured: env['ABI_VERSION'] = abi.replace('-pre','').split('.') env['MAPNIK_VERSION_STRING'] = abi - # Common C++ flags. + # Common DEFINES. + env.Append(CPPDEFINES = '-D%s' % env['PLATFORM'].upper()) if env['THREADING'] == 'multi': - common_cxx_flags = '-D%s -DMAPNIK_THREADSAFE ' % env['PLATFORM'].upper() - else : - common_cxx_flags = '-D%s ' % env['PLATFORM'].upper() + env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE') # Mac OSX (Darwin) special settings if env['PLATFORM'] == 'Darwin': pthread = '' - # Getting the macintosh version number, sticking as a compiler macro - # for Leopard -- needed because different workarounds are needed than - # for Tiger. - # this was used for fribidi - not longer needed - # but will retain logic for future use - #if platform.mac_ver()[0].startswith('10.5'): - # common_cxx_flags += '-DOSX_LEOPARD ' else: pthread = '-pthread' # Common debugging flags. # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html - debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' - ndebug_flags = '-DNDEBUG' + debug_flags = '-g -fno-omit-frame-pointer' + debug_defines = '-DDEBUG -DMAPNIK_DEBUG' + ndebug_defines = '-DNDEBUG' # Enable logging in debug mode (always) and release mode (when specified) if env['DEFAULT_LOG_SEVERITY']: @@ -1575,39 +1573,37 @@ if not preconfigured: log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity if env['DEBUG']: - debug_flags += log_enabled + debug_defines += log_enabled else: if env['ENABLE_LOG']: - ndebug_flags += log_enabled + ndebug_defines += log_enabled # Enable statistics reporting if env['ENABLE_STATS']: - debug_flags += ' -DMAPNIK_STATS' - ndebug_flags += ' -DMAPNIK_STATS' + debug_defines += ' -DMAPNIK_STATS' + ndebug_defines += ' -DMAPNIK_STATS' # Add rdynamic to allow using statics between application and plugins # http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++': env.MergeFlags('-rdynamic') - # Customizing the C++ compiler flags depending on: - # (1) the C++ compiler used; and - # (2) whether debug binaries are requested. - if env['SUNCC']: - if env['DEBUG']: - env.Append(CXXFLAGS = common_cxx_flags + debug_flags) - else: - env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags) + if env['DEBUG']: + env.Append(CXXFLAGS = debug_flags) + env.Append(CPPDEFINES = debug_defines) else: + env.Append(CPPDEFINES = ndebug_defines) + + if not env['SUNCC']: # Common flags for GCC. - gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags) + gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 ' % (env['WARNING_CXXFLAGS'], pthread) if env['DEBUG']: - env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags) + env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline') else: - env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags)) + env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -fno-strict-aliasing -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts' % (env['OPTIMIZATION'])) if env['DEBUG_UNDEFINED']: - env.Append(CXXFLAGS = '-fcatch-undefined-behavior -ftrapv -fwrapv') + env.Append(CXXFLAGS = '-fsanitize=undefined-trap -fsanitize-undefined-trap-on-error -ftrapv -fwrapv') if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']: majver, minver = env['PYTHON_VERSION'].split('.') @@ -1731,13 +1727,6 @@ if not HELP_REQUESTED: Export('plugin_base') - # clear the '_CPPDEFFLAGS' variable - # for unknown reasons this variable puts -DNone - # in the g++ args prompting unnecessary recompiles - env['_CPPDEFFLAGS'] = None - plugin_base['_CPPDEFFLAGS'] = None - - if env['FAST']: # caching is 'auto' by default in SCons # But let's also cache implicit deps... diff --git a/bindings/python/build.py b/bindings/python/build.py index a16bb4533..40bc6c254 100644 --- a/bindings/python/build.py +++ b/bindings/python/build.py @@ -175,13 +175,13 @@ if 'install' in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS: if env['HAS_CAIRO']: py_env.Append(CPPPATH = env['CAIRO_CPPPATHS']) - py_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + py_env.Append(CPPDEFINES = '-DHAVE_CAIRO') if env['PLATFORM'] == 'Darwin': py_env.Append(LIBS=env['CAIRO_LINKFLAGS']) if env['HAS_PYCAIRO']: py_env.ParseConfig('pkg-config --cflags pycairo') - py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO') + py_env.Append(CPPDEFINES = '-DHAVE_PYCAIRO') libraries.append('boost_thread%s' % env['BOOST_APPEND']) _mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) diff --git a/demo/c++/build.py b/demo/c++/build.py index b36a95840..adcad4048 100644 --- a/demo/c++/build.py +++ b/demo/c++/build.py @@ -37,7 +37,7 @@ demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) if env['HAS_CAIRO']: demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) - demo_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + demo_env.Append(CPPDEFINES = '-DHAVE_CAIRO') libraries = copy(env['LIBMAPNIK_LIBS']) libraries.append('mapnik') diff --git a/plugins/input/shape/build.py b/plugins/input/shape/build.py index 5a1e0d89a..5dd9995ac 100644 --- a/plugins/input/shape/build.py +++ b/plugins/input/shape/build.py @@ -47,7 +47,7 @@ libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) if env['SHAPE_MEMORY_MAPPED_FILE']: - plugin_env.Append(CXXFLAGS = '-DSHAPE_MEMORY_MAPPED_FILE') + plugin_env.Append(CPPDEFINES = '-DSHAPE_MEMORY_MAPPED_FILE') if env.get('BOOST_LIB_VERSION_FROM_HEADER'): boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1]) diff --git a/src/build.py b/src/build.py index e78bebc43..5e0bb54d6 100644 --- a/src/build.py +++ b/src/build.py @@ -48,6 +48,7 @@ mapnik_lib_link_flag = '' # note: .data gets the actual list to allow a true copy # and avoids unintended pollution of other environments libmapnik_cxxflags = copy(lib_env['CXXFLAGS'].data) +libmapnik_defines = copy(lib_env['CPPDEFINES']) ABI_VERSION = env['ABI_VERSION'] @@ -209,8 +210,8 @@ source = Split( if env['HAS_CAIRO']: lib_env.AppendUnique(LIBPATH=env['CAIRO_LIBPATHS']) lib_env.Append(LIBS=env['CAIRO_LINKFLAGS']) - lib_env.Append(CXXFLAGS = '-DHAVE_CAIRO') - libmapnik_cxxflags.append('-DHAVE_CAIRO') + lib_env.Append(CPPDEFINES = '-DHAVE_CAIRO') + libmapnik_defines.append('-DHAVE_CAIRO') lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS'])) source.insert(0,'cairo_renderer.cpp') source.insert(0,'cairo_context.cpp') @@ -296,8 +297,8 @@ if env['SVG_RENDERER']: # svg backend svg/output/process_shield_symbolizer.cpp svg/output/process_text_symbolizer.cpp """) - lib_env.Append(CXXFLAGS = '-DSVG_RENDERER') - libmapnik_cxxflags.append('-DSVG_RENDERER') + lib_env.Append(CPPDEFINES = '-DSVG_RENDERER') + libmapnik_defines.append('-DSVG_RENDERER') if env.get('BOOST_LIB_VERSION_FROM_HEADER'): @@ -320,8 +321,8 @@ if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']: libxml2_loader.cpp """) env2 = lib_env.Clone() - env2.Append(CXXFLAGS = '-DHAVE_LIBXML2') - libmapnik_cxxflags.append('-DHAVE_LIBXML2') + env2.Append(CPPDEFINES = '-DHAVE_LIBXML2') + libmapnik_defines.append('-DHAVE_LIBXML2') fixup = ['libxml2_loader.cpp'] for cpp in fixup: if cpp in source: @@ -341,7 +342,7 @@ processor_cpp = 'feature_style_processor.cpp' if env['RENDERING_STATS']: env3 = lib_env.Clone() - env3.Append(CXXFLAGS='-DRENDERING_STATS') + env3.Append(CPPDEFINES='-DRENDERING_STATS') if env['LINKING'] == 'static': source.insert(0,env3.StaticObject(processor_cpp)) else: @@ -357,6 +358,7 @@ else: # cache library values for other builds to use env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS']) env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags +env['LIBMAPNIK_DEFINES'] = libmapnik_defines mapnik = None diff --git a/tests/cpp_tests/build.py b/tests/cpp_tests/build.py index 119894dec..dd244b19d 100644 --- a/tests/cpp_tests/build.py +++ b/tests/cpp_tests/build.py @@ -15,7 +15,7 @@ test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS']) if test_env['HAS_CAIRO']: test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS']) - test_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + test_env.Append(CPPDEFINES = '-DHAVE_CAIRO') for cpp_test in glob.glob('*_test.cpp'): name = cpp_test.replace('.cpp','-bin') diff --git a/tests/python_tests/mapnik_config_test.py b/tests/python_tests/mapnik_config_test.py index 5698b3392..b6daa80a8 100644 --- a/tests/python_tests/mapnik_config_test.py +++ b/tests/python_tests/mapnik_config_test.py @@ -1,35 +1,77 @@ #!/usr/bin/env python from nose.tools import * -from subprocess import call +from subprocess import Popen, PIPE, STDOUT import os -#import os, sys, glob, mapnik +import os, sys, glob, mapnik -#def test(): -# # mapnik-config program -# # should be on default path... -# mc = 'mapnik-config' -# valid = ['--help', -# '--prefix', -# '--libs', -# '--dep-libs', -# '--ldflags', -# '--cflags', -# '--fonts', -# '--input-plugins', -# '-v', -# '--version', -# '--svn-revision', -# ] -# -# # valid args should return 1 -# for item in valid: -# eq_(0,call([mc,item])) -# -# # errors should return 1 -# eq_(1,call([mc,''])) -# eq_(1,call([mc,'foo'])) +def test_mapnik_config_no_args(): + process = Popen('mapnik-config', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,1) + eq_('Usage: mapnik-config ' in result[0],True) + eq_(result[1],'') + +def test_mapnik_config_help(): + process = Popen('mapnik-config --help', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,0) + eq_('Usage: mapnik-config ' in result[0],True) + eq_(result[1],'') + +def test_mapnik_config_help_short(): + process = Popen('mapnik-config -h', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,0) + eq_('Usage: mapnik-config ' in result[0],True) + eq_(result[1],'') + +def test_mapnik_config_valid_opts(): + valid_args = [ + '-h', + '--help', + '-v', + '--version', + '--git-revision', + '--git-describe', + '--fonts', + '--input-plugins', + '--defines', + '--prefix', + '--lib-name', + '--libs', + '--dep-libs', + '--ldflags', + '--includes', + '--dep-includes', + '--cxxflags', + '--cflags', + '--all-flags' + ] + for item in valid_args: + cmd = 'mapnik-config ' + item + process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,0) + eq_(len(result[0]) > 1,True,cmd) + eq_(result[1],'') + +def test_mapnik_config_invalid_option(): + cmd = 'mapnik-config --invalid-does-not-exist' + process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,0) + eq_(result[0],'') + eq_(result[1],'unknown option --invalid-does-not-exist\n') + +def test_mapnik_config_valid_and_invalid_option(): + cmd = 'mapnik-config --libs --invalid-does-not-exist' + process = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE) + result = process.communicate() + eq_(process.returncode,0) + eq_('-lmapnik' in result[0],True) + eq_(result[1],'unknown option --invalid-does-not-exist\n') if __name__ == "__main__": [eval(run)() for run in dir() if 'test_' in run] diff --git a/utils/mapnik-config/build.py b/utils/mapnik-config/build.py index 08b1055c1..9f74eb98b 100644 --- a/utils/mapnik-config/build.py +++ b/utils/mapnik-config/build.py @@ -17,18 +17,20 @@ config_variables = '''#!/bin/sh ## variables -CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )" -CONFIG_MAPNIK_LIBNAME=%(mapnik_libname)s -CONFIG_MAPNIK_INCLUDE=${CONFIG_PREFIX}/include -CONFIG_MAPNIK_LIB=${CONFIG_PREFIX}/%(libdir_schema)s CONFIG_MAPNIK_VERSION='%(version)s' -CONFIG_MAPNIK_LDFLAGS='%(ldflags)s' -CONFIG_DEP_LIBS='%(dep_libs)s' -CONFIG_OTHER_INCLUDES='%(other_includes)s' +CONFIG_GIT_REVISION='%(git_revision)s' +CONFIG_GIT_DESCRIBE='%(git_describe)s' CONFIG_FONTS='%(fonts)s' CONFIG_INPUT_PLUGINS='%(input_plugins)s' -CONFIG_GIT_REVISION='%(git_revision)s' -CONFIG_MAPNIK_AGG_INCLUDE=${CONFIG_PREFIX}/include/mapnik/agg +CONFIG_MAPNIK_DEFINES='%(defines)s' +CONFIG_PREFIX="$( cd "$( dirname $( dirname "$0" ))" && pwd )" +CONFIG_MAPNIK_LIBNAME='%(mapnik_libname)s' +CONFIG_MAPNIK_LIB="${CONFIG_PREFIX}/%(libdir_schema)s" +CONFIG_DEP_LIBS='%(dep_libs)s' +CONFIG_MAPNIK_LDFLAGS='%(ldflags)s' +CONFIG_MAPNIK_INCLUDE="${CONFIG_PREFIX}/include -I${CONFIG_PREFIX}/include/mapnik/agg" +CONFIG_DEP_INCLUDES='%(dep_includes)s' +CONFIG_CXXFLAGS='%(cxxflags)s' ''' @@ -39,20 +41,16 @@ def write_config(configuration,template,config_file): os.chmod(config_file,0755) except: pass +cxxflags = ' '.join(config_env['LIBMAPNIK_CXXFLAGS']) -# todo - refine this list +defines = ' '.join(config_env['LIBMAPNIK_DEFINES']) -other_includes = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')]) +dep_includes = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')]) -other_includes += ' ' - -other_includes += ' '.join(config_env['LIBMAPNIK_CXXFLAGS']) - -other_includes += ' ' +dep_includes += ' ' if config_env['HAS_CAIRO']: - other_includes += ''.join([' -I%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')]) - + dep_includes += ''.join([' -I%s' % i for i in env['CAIRO_CPPPATHS'] if not i.startswith('#')]) ldflags = config_env['CUSTOM_LDFLAGS'] + ''.join([' -L%s' % i for i in config_env['LIBPATH'] if not i.startswith('#')]) @@ -62,7 +60,9 @@ dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']]) dep_libs = dep_libs.replace('-lagg','') git_revision = 'unknown' -# present only for official releases where git metadata is stripped +git_describe = 'unknown' +# special GIT_REVISION/GIT_DESCRIBE files present only for official releases +# where the git directory metadata is stripped # more info: https://github.com/mapnik/mapnik/wiki/MapnikReleaseSteps revision_release_file = '../../GIT_REVISION' if os.path.exists(revision_release_file): @@ -73,16 +73,28 @@ else: if not stderr: git_revision = stdin.strip() +describe_release_file = '../../GIT_DESCRIBE' +if os.path.exists(describe_release_file): + git_describe = open(describe_release_file,'r').read() +else: + git_cmd = "git describe" + stdin, stderr = Popen(git_cmd, shell=True, stdout=PIPE, stderr=PIPE).communicate() + if not stderr: + git_describe = stdin.strip() + configuration = { + "git_revision": git_revision, + "git_describe": git_describe, + "version": config_env['MAPNIK_VERSION_STRING'], "mapnik_libname": 'mapnik', "libdir_schema": config_env['LIBDIR_SCHEMA'], "ldflags": ldflags, "dep_libs": dep_libs, - "other_includes": other_includes, + "dep_includes": dep_includes, "fonts": config_env['MAPNIK_FONTS'], "input_plugins": config_env['MAPNIK_INPUT_PLUGINS'], - "git_revision": git_revision, - "version": config_env['MAPNIK_VERSION_STRING'], + "defines":defines, + "cxxflags":cxxflags } ## if we are statically linking depedencies diff --git a/utils/mapnik-config/mapnik-config.template.sh b/utils/mapnik-config/mapnik-config.template.sh index f3a30d6df..190095631 100755 --- a/utils/mapnik-config/mapnik-config.template.sh +++ b/utils/mapnik-config/mapnik-config.template.sh @@ -1,21 +1,6 @@ ## program below -CONFIG_JSON="{ - \"prefix\": \"${CONFIG_PREFIX}\", - \"mapnik_libname\": \"${CONFIG_MAPNIK_LIBNAME}\", - \"mapnik_include\": \"${CONFIG_MAPNIK_INCLUDE}\", - \"mapnik_lib\": \"${CONFIG_MAPNIK_LIB}\", - \"version\": \"${CONFIG_MAPNIK_VERSION}\", - \"ldflags\": \"${CONFIG_MAPNIK_LDFLAGS}\", - \"dep_libs\": \"${CONFIG_DEP_LIBS}\", - \"other_includes\": \"${CONFIG_OTHER_INCLUDES}\", - \"fonts\": \"${CONFIG_FONTS}\", - \"input_plugins\": \"${CONFIG_INPUT_PLUGINS}\", - \"git_revision\": \"${CONFIG_GIT_REVISION}\" -}" - -## https://github.com/mapnik/mapnik/issues/1443 usage() { cat <&2; } + if test $# -eq 0; then usage 1 fi while test $# -gt 0; do case "$1" in - -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; - *) optarg= ;; esac case "$1" in - --prefix=*) - prefix=$optarg - includedir=$CONFIG_PREFIX/include - CONFIG_MAPNIK_LIB=$CONFIG_PREFIX/lib + --help) + usage 0 ;; - --prefix) - echo $CONFIG_PREFIX + -h) + usage 0 ;; -v) - echo $CONFIG_MAPNIK_VERSION + echo ${CONFIG_MAPNIK_VERSION} ;; --version) echo $CONFIG_MAPNIK_VERSION ;; - --json) - echo $CONFIG_JSON - ;; - --git-revision) echo ${CONFIG_GIT_REVISION} ;; - --help) - usage 0 + --git-describe) + echo ${CONFIG_GIT_DESCRIBE} ;; --fonts) @@ -94,34 +73,49 @@ while test $# -gt 0; do echo ${CONFIG_INPUT_PLUGINS} ;; - --cxxflags) - echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES} + --defines) + echo ${CONFIG_MAPNIK_DEFINES} ;; - --cflags) - echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES} - ;; - - --libs) - echo -L${CONFIG_MAPNIK_LIB} -l${CONFIG_MAPNIK_LIBNAME} - ;; - - --ldflags) - echo ${CONFIG_MAPNIK_LDFLAGS} + --prefix) + echo ${CONFIG_PREFIX} ;; --lib-name) echo ${CONFIG_MAPNIK_LIBNAME} ;; + --libs) + echo -L${CONFIG_MAPNIK_LIB} -l${CONFIG_MAPNIK_LIBNAME} + ;; + --dep-libs) echo ${CONFIG_DEP_LIBS} ;; + --ldflags) + echo ${CONFIG_MAPNIK_LDFLAGS} + ;; + + --includes) + echo -I${CONFIG_MAPNIK_INCLUDE} + ;; + + --dep-includes) + echo ${CONFIG_DEP_INCLUDES} + ;; + + --cxxflags) + echo ${CONFIG_CXXFLAGS} + ;; + + --cflags) + echo -I${CONFIG_MAPNIK_INCLUDE} ${CONFIG_DEP_INCLUDES} ${CONFIG_MAPNIK_DEFINES} + ;; + *) - # if no matches, return 'usage 1' meaning usage + 1 (error return type) - usage 1 - exit 1 + # push to stderr any invalid options + echo "unknown option $1" 1>&2; ;; esac shift diff --git a/utils/pgsql2sqlite/build.py b/utils/pgsql2sqlite/build.py index 0be6d4944..6246ee463 100644 --- a/utils/pgsql2sqlite/build.py +++ b/utils/pgsql2sqlite/build.py @@ -39,7 +39,7 @@ program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) if env['HAS_CAIRO']: program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) - program_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + program_env.Append(CPPDEFINES = '-DHAVE_CAIRO') program_env.PrependUnique(CPPPATH=['#plugins/input/postgis']) diff --git a/utils/svg2png/build.py b/utils/svg2png/build.py index 7712cec59..210e63c63 100644 --- a/utils/svg2png/build.py +++ b/utils/svg2png/build.py @@ -37,7 +37,7 @@ program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS']) if env['HAS_CAIRO']: program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) - program_env.Append(CXXFLAGS = '-DHAVE_CAIRO') + program_env.Append(CPPDEFINES = '-DHAVE_CAIRO') libraries = copy(env['LIBMAPNIK_LIBS']) boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']