Added new mapnik-config options: git-describe, defines, includes, dep-includes, and cxxflags - closes #1443

This commit is contained in:
Dane Springmeyer 2013-03-13 19:49:59 -07:00
parent 5e1f81d954
commit e2c7283522
13 changed files with 209 additions and 167 deletions

View file

@ -8,6 +8,8 @@ For a complete change history, see the git log.
## Future ## 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 - Added `text-halo-rasterizer` property. Set to `fast` for lower quality but faster
halo rendering (#1298) halo rendering (#1298)

View file

@ -54,6 +54,7 @@ test:
test-local: test-local:
@echo "*** Boostrapping local test environment..." @echo "*** Boostrapping local test environment..."
@export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \ @export ${LINK_FIX}=`pwd`/src:${${LINK_FIX}} && \
export PATH=`pwd`/utils/mapnik-config/:${PATH} && \
export PYTHONPATH=`pwd`/bindings/python/:${PYTHONPATH} && \ export PYTHONPATH=`pwd`/bindings/python/:${PYTHONPATH} && \
export MAPNIK_FONT_DIRECTORY=`pwd`/fonts/dejavu-fonts-ttf-2.33/ttf/ && \ export MAPNIK_FONT_DIRECTORY=`pwd`/fonts/dejavu-fonts-ttf-2.33/ttf/ && \
export MAPNIK_INPUT_PLUGINS_DIRECTORY=`pwd`/plugins/input/ && \ export MAPNIK_INPUT_PLUGINS_DIRECTORY=`pwd`/plugins/input/ && \

View file

@ -261,6 +261,7 @@ opts.AddVariables(
('CXX', 'The C++ compiler to use to compile mapnik (defaults to g++).', 'g++'), ('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'), ('CC', 'The C compiler used for configure checks of C libs (defaults to gcc).', 'gcc'),
('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''), ('CUSTOM_CXXFLAGS', 'Custom C++ flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir>', ''),
('CUSTOM_DEFINES', 'Custom Compiler DEFINES, e.g. -DENABLE_THIS', ''),
('CUSTOM_CFLAGS', 'Custom C flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> (only used for configure checks)', ''), ('CUSTOM_CFLAGS', 'Custom C flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> (only used for configure checks)', ''),
('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''), ('CUSTOM_LDFLAGS', 'Custom linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir>', ''),
EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']), EnumVariable('LINKING', "Set library format for libmapnik",'shared', ['shared','static']),
@ -388,6 +389,7 @@ pickle_store = [# Scons internal variables
'LIBS', 'LIBS',
'LINKFLAGS', 'LINKFLAGS',
'CUSTOM_LDFLAGS', # user submitted 'CUSTOM_LDFLAGS', # user submitted
'CUSTOM_DEFINES', # user submitted
'CUSTOM_CXXFLAGS', # user submitted 'CUSTOM_CXXFLAGS', # user submitted
'CUSTOM_CFLAGS', # user submitted 'CUSTOM_CFLAGS', # user submitted
'MAPNIK_LIB_NAME', 'MAPNIK_LIB_NAME',
@ -428,6 +430,7 @@ pickle_store = [# Scons internal variables
'MAPNIK_LIB_BASE_DEST', 'MAPNIK_LIB_BASE_DEST',
'EXTRA_FREETYPE_LIBS', 'EXTRA_FREETYPE_LIBS',
'LIBMAPNIK_CPPATHS', 'LIBMAPNIK_CPPATHS',
'LIBMAPNIK_DEFINES',
'LIBMAPNIK_CXXFLAGS', 'LIBMAPNIK_CXXFLAGS',
'CAIRO_LIBPATHS', 'CAIRO_LIBPATHS',
'CAIRO_LINKFLAGS', 'CAIRO_LINKFLAGS',
@ -1009,6 +1012,7 @@ if not preconfigured:
env['HAS_LIBXML2'] = False env['HAS_LIBXML2'] = False
env['LIBMAPNIK_LIBS'] = [] env['LIBMAPNIK_LIBS'] = []
env['LIBMAPNIK_CPPATHS'] = [] env['LIBMAPNIK_CPPATHS'] = []
env['LIBMAPNIK_DEFINES'] = []
env['LIBMAPNIK_CXXFLAGS'] = [] env['LIBMAPNIK_CXXFLAGS'] = []
env['PLUGINS'] = PLUGINS env['PLUGINS'] = PLUGINS
env['EXTRA_FREETYPE_LIBS'] = [] env['EXTRA_FREETYPE_LIBS'] = []
@ -1068,6 +1072,7 @@ if not preconfigured:
env['LIBPATH'] = ['#src'] env['LIBPATH'] = ['#src']
# set any custom cxxflags and ldflags to come first # set any custom cxxflags and ldflags to come first
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
env.Append(CFLAGS = env['CUSTOM_CFLAGS']) env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS']) env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS'])
@ -1101,8 +1106,8 @@ if not preconfigured:
# http://www.opensource.apple.com/tarballs/ICU/ # http://www.opensource.apple.com/tarballs/ICU/
# then copy the headers to a location that mapnik will find # then copy the headers to a location that mapnik will find
if 'core' in env['ICU_LIB_NAME']: if 'core' in env['ICU_LIB_NAME']:
env.Append(CXXFLAGS = '-DU_HIDE_DRAFT_API') env.Append(CPPDEFINES = '-DU_HIDE_DRAFT_API')
env.Append(CXXFLAGS = '-DUDISABLE_RENAMING') env.Append(CPPDEFINES = '-DUDISABLE_RENAMING')
if os.path.exists(env['ICU_LIB_NAME']): if os.path.exists(env['ICU_LIB_NAME']):
#-sICU_LINK=" -L/usr/lib -licucore #-sICU_LINK=" -L/usr/lib -licucore
env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','') 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']: if env['JPEG']:
env.Append(CXXFLAGS = '-DHAVE_JPEG') env.Append(CPPDEFINES = '-DHAVE_JPEG')
LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], True,'C']) LIBSHEADERS.append(['jpeg', ['stdio.h', 'jpeglib.h'], True,'C'])
inc_path = env['%s_INCLUDES' % 'JPEG'] inc_path = env['%s_INCLUDES' % 'JPEG']
lib_path = env['%s_LIBS' % 'JPEG'] lib_path = env['%s_LIBS' % 'JPEG']
@ -1149,7 +1154,7 @@ if not preconfigured:
env['SKIPPED_DEPS'].extend(['jpeg']) env['SKIPPED_DEPS'].extend(['jpeg'])
if env['PROJ']: if env['PROJ']:
env.Append(CXXFLAGS = '-DMAPNIK_USE_PROJ4') env.Append(CPPDEFINES = '-DMAPNIK_USE_PROJ4')
LIBSHEADERS.append(['proj', 'proj_api.h', True,'C']) LIBSHEADERS.append(['proj', 'proj_api.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'PROJ'] inc_path = env['%s_INCLUDES' % 'PROJ']
lib_path = env['%s_LIBS' % 'PROJ'] lib_path = env['%s_LIBS' % 'PROJ']
@ -1159,7 +1164,7 @@ if not preconfigured:
env['SKIPPED_DEPS'].extend(['proj']) env['SKIPPED_DEPS'].extend(['proj'])
if env['PNG']: if env['PNG']:
env.Append(CXXFLAGS = '-DHAVE_PNG') env.Append(CPPDEFINES = '-DHAVE_PNG')
LIBSHEADERS.append(['png', 'png.h', True,'C']) LIBSHEADERS.append(['png', 'png.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'PNG'] inc_path = env['%s_INCLUDES' % 'PNG']
lib_path = env['%s_LIBS' % 'PNG'] lib_path = env['%s_LIBS' % 'PNG']
@ -1169,7 +1174,7 @@ if not preconfigured:
env['SKIPPED_DEPS'].extend(['png']) env['SKIPPED_DEPS'].extend(['png'])
if env['TIFF']: if env['TIFF']:
env.Append(CXXFLAGS = '-DHAVE_TIFF') env.Append(CPPDEFINES = '-DHAVE_TIFF')
LIBSHEADERS.append(['tiff', 'tiff.h', True,'C']) LIBSHEADERS.append(['tiff', 'tiff.h', True,'C'])
inc_path = env['%s_INCLUDES' % 'TIFF'] inc_path = env['%s_INCLUDES' % 'TIFF']
lib_path = env['%s_LIBS' % 'TIFF'] lib_path = env['%s_LIBS' % 'TIFF']
@ -1197,7 +1202,7 @@ if not preconfigured:
env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) env['MISSING_DEPS'].append(env['ICU_LIB_NAME'])
if env['BIGINT']: if env['BIGINT']:
env.Append(CXXFLAGS = '-DBIGINT') env.Append(CPPDEFINES = '-DBIGINT')
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
thread_flag = thread_suffix thread_flag = thread_suffix
@ -1252,7 +1257,7 @@ if not preconfigured:
# http://lists.boost.org/Archives/boost/2009/03/150076.php # http://lists.boost.org/Archives/boost/2009/03/150076.php
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(CXXFLAGS = '-DBOOST_REGEX_HAS_ICU') env.Append(CPPDEFINES = '-DBOOST_REGEX_HAS_ICU')
else: else:
env['SKIPPED_DEPS'].append('boost_regex_icu') env['SKIPPED_DEPS'].append('boost_regex_icu')
@ -1535,29 +1540,22 @@ if not preconfigured:
env['ABI_VERSION'] = abi.replace('-pre','').split('.') env['ABI_VERSION'] = abi.replace('-pre','').split('.')
env['MAPNIK_VERSION_STRING'] = abi env['MAPNIK_VERSION_STRING'] = abi
# Common C++ flags. # Common DEFINES.
env.Append(CPPDEFINES = '-D%s' % env['PLATFORM'].upper())
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
common_cxx_flags = '-D%s -DMAPNIK_THREADSAFE ' % env['PLATFORM'].upper() env.Append(CPPDEFINES = '-DMAPNIK_THREADSAFE')
else :
common_cxx_flags = '-D%s ' % env['PLATFORM'].upper()
# Mac OSX (Darwin) special settings # Mac OSX (Darwin) special settings
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
pthread = '' 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: else:
pthread = '-pthread' pthread = '-pthread'
# Common debugging flags. # Common debugging flags.
# http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html
debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' debug_flags = '-g -fno-omit-frame-pointer'
ndebug_flags = '-DNDEBUG' debug_defines = '-DDEBUG -DMAPNIK_DEBUG'
ndebug_defines = '-DNDEBUG'
# Enable logging in debug mode (always) and release mode (when specified) # Enable logging in debug mode (always) and release mode (when specified)
if env['DEFAULT_LOG_SEVERITY']: if env['DEFAULT_LOG_SEVERITY']:
@ -1575,39 +1573,37 @@ if not preconfigured:
log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity
if env['DEBUG']: if env['DEBUG']:
debug_flags += log_enabled debug_defines += log_enabled
else: else:
if env['ENABLE_LOG']: if env['ENABLE_LOG']:
ndebug_flags += log_enabled ndebug_defines += log_enabled
# Enable statistics reporting # Enable statistics reporting
if env['ENABLE_STATS']: if env['ENABLE_STATS']:
debug_flags += ' -DMAPNIK_STATS' debug_defines += ' -DMAPNIK_STATS'
ndebug_flags += ' -DMAPNIK_STATS' ndebug_defines += ' -DMAPNIK_STATS'
# Add rdynamic to allow using statics between application and plugins # Add rdynamic to allow using statics between application and plugins
# http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux # http://stackoverflow.com/questions/8623657/multiple-instances-of-singleton-across-shared-libraries-on-linux
if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++': if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++':
env.MergeFlags('-rdynamic') env.MergeFlags('-rdynamic')
# Customizing the C++ compiler flags depending on: if env['DEBUG']:
# (1) the C++ compiler used; and env.Append(CXXFLAGS = debug_flags)
# (2) whether debug binaries are requested. env.Append(CPPDEFINES = debug_defines)
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)
else: else:
env.Append(CPPDEFINES = ndebug_defines)
if not env['SUNCC']:
# Common flags for GCC. # 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']: 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: 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']: 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']: if 'python' in env['BINDINGS'] or 'python' in env['REQUESTED_PLUGINS']:
majver, minver = env['PYTHON_VERSION'].split('.') majver, minver = env['PYTHON_VERSION'].split('.')
@ -1731,13 +1727,6 @@ if not HELP_REQUESTED:
Export('plugin_base') 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']: if env['FAST']:
# caching is 'auto' by default in SCons # caching is 'auto' by default in SCons
# But let's also cache implicit deps... # But let's also cache implicit deps...

View file

@ -175,13 +175,13 @@ if 'install' in COMMAND_LINE_TARGETS:
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
py_env.Append(CPPPATH = env['CAIRO_CPPPATHS']) py_env.Append(CPPPATH = env['CAIRO_CPPPATHS'])
py_env.Append(CXXFLAGS = '-DHAVE_CAIRO') py_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
py_env.Append(LIBS=env['CAIRO_LINKFLAGS']) py_env.Append(LIBS=env['CAIRO_LINKFLAGS'])
if env['HAS_PYCAIRO']: if env['HAS_PYCAIRO']:
py_env.ParseConfig('pkg-config --cflags 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']) libraries.append('boost_thread%s' % env['BOOST_APPEND'])
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) _mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)

View file

@ -37,7 +37,7 @@ demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
demo_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) 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 = copy(env['LIBMAPNIK_LIBS'])
libraries.append('mapnik') libraries.append('mapnik')

View file

@ -47,7 +47,7 @@ libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
if env['SHAPE_MEMORY_MAPPED_FILE']: 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'): if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1]) boost_version_from_header = int(env['BOOST_LIB_VERSION_FROM_HEADER'].split('_')[1])

View file

@ -48,6 +48,7 @@ mapnik_lib_link_flag = ''
# note: .data gets the actual list to allow a true copy # note: .data gets the actual list to allow a true copy
# and avoids unintended pollution of other environments # and avoids unintended pollution of other environments
libmapnik_cxxflags = copy(lib_env['CXXFLAGS'].data) libmapnik_cxxflags = copy(lib_env['CXXFLAGS'].data)
libmapnik_defines = copy(lib_env['CPPDEFINES'])
ABI_VERSION = env['ABI_VERSION'] ABI_VERSION = env['ABI_VERSION']
@ -209,8 +210,8 @@ source = Split(
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
lib_env.AppendUnique(LIBPATH=env['CAIRO_LIBPATHS']) lib_env.AppendUnique(LIBPATH=env['CAIRO_LIBPATHS'])
lib_env.Append(LIBS=env['CAIRO_LINKFLAGS']) lib_env.Append(LIBS=env['CAIRO_LINKFLAGS'])
lib_env.Append(CXXFLAGS = '-DHAVE_CAIRO') lib_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
libmapnik_cxxflags.append('-DHAVE_CAIRO') libmapnik_defines.append('-DHAVE_CAIRO')
lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS'])) lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
source.insert(0,'cairo_renderer.cpp') source.insert(0,'cairo_renderer.cpp')
source.insert(0,'cairo_context.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_shield_symbolizer.cpp
svg/output/process_text_symbolizer.cpp svg/output/process_text_symbolizer.cpp
""") """)
lib_env.Append(CXXFLAGS = '-DSVG_RENDERER') lib_env.Append(CPPDEFINES = '-DSVG_RENDERER')
libmapnik_cxxflags.append('-DSVG_RENDERER') libmapnik_defines.append('-DSVG_RENDERER')
if env.get('BOOST_LIB_VERSION_FROM_HEADER'): if env.get('BOOST_LIB_VERSION_FROM_HEADER'):
@ -320,8 +321,8 @@ if env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
libxml2_loader.cpp libxml2_loader.cpp
""") """)
env2 = lib_env.Clone() env2 = lib_env.Clone()
env2.Append(CXXFLAGS = '-DHAVE_LIBXML2') env2.Append(CPPDEFINES = '-DHAVE_LIBXML2')
libmapnik_cxxflags.append('-DHAVE_LIBXML2') libmapnik_defines.append('-DHAVE_LIBXML2')
fixup = ['libxml2_loader.cpp'] fixup = ['libxml2_loader.cpp']
for cpp in fixup: for cpp in fixup:
if cpp in source: if cpp in source:
@ -341,7 +342,7 @@ processor_cpp = 'feature_style_processor.cpp'
if env['RENDERING_STATS']: if env['RENDERING_STATS']:
env3 = lib_env.Clone() env3 = lib_env.Clone()
env3.Append(CXXFLAGS='-DRENDERING_STATS') env3.Append(CPPDEFINES='-DRENDERING_STATS')
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
source.insert(0,env3.StaticObject(processor_cpp)) source.insert(0,env3.StaticObject(processor_cpp))
else: else:
@ -357,6 +358,7 @@ else:
# cache library values for other builds to use # cache library values for other builds to use
env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS']) env['LIBMAPNIK_LIBS'] = copy(lib_env['LIBS'])
env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags
env['LIBMAPNIK_DEFINES'] = libmapnik_defines
mapnik = None mapnik = None

View file

@ -15,7 +15,7 @@ test_env['CXXFLAGS'] = copy(test_env['LIBMAPNIK_CXXFLAGS'])
if test_env['HAS_CAIRO']: if test_env['HAS_CAIRO']:
test_env.PrependUnique(CPPPATH=test_env['CAIRO_CPPPATHS']) 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'): for cpp_test in glob.glob('*_test.cpp'):
name = cpp_test.replace('.cpp','-bin') name = cpp_test.replace('.cpp','-bin')

View file

@ -1,35 +1,77 @@
#!/usr/bin/env python #!/usr/bin/env python
from nose.tools import * from nose.tools import *
from subprocess import call from subprocess import Popen, PIPE, STDOUT
import os import os
#import os, sys, glob, mapnik import os, sys, glob, mapnik
#def test(): def test_mapnik_config_no_args():
# # mapnik-config program process = Popen('mapnik-config', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
# # should be on default path... result = process.communicate()
# mc = 'mapnik-config' eq_(process.returncode,1)
# valid = ['--help', eq_('Usage: mapnik-config ' in result[0],True)
# '--prefix', eq_(result[1],'')
# '--libs',
# '--dep-libs', def test_mapnik_config_help():
# '--ldflags', process = Popen('mapnik-config --help', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
# '--cflags', result = process.communicate()
# '--fonts', eq_(process.returncode,0)
# '--input-plugins', eq_('Usage: mapnik-config ' in result[0],True)
# '-v', eq_(result[1],'')
# '--version',
# '--svn-revision', def test_mapnik_config_help_short():
# ] process = Popen('mapnik-config -h', shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
# result = process.communicate()
# # valid args should return 1 eq_(process.returncode,0)
# for item in valid: eq_('Usage: mapnik-config ' in result[0],True)
# eq_(0,call([mc,item])) eq_(result[1],'')
#
# # errors should return 1 def test_mapnik_config_valid_opts():
# eq_(1,call([mc,''])) valid_args = [
# eq_(1,call([mc,'foo'])) '-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__": if __name__ == "__main__":
[eval(run)() for run in dir() if 'test_' in run] [eval(run)() for run in dir() if 'test_' in run]

View file

@ -17,18 +17,20 @@ config_variables = '''#!/bin/sh
## variables ## 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_VERSION='%(version)s'
CONFIG_MAPNIK_LDFLAGS='%(ldflags)s' CONFIG_GIT_REVISION='%(git_revision)s'
CONFIG_DEP_LIBS='%(dep_libs)s' CONFIG_GIT_DESCRIBE='%(git_describe)s'
CONFIG_OTHER_INCLUDES='%(other_includes)s'
CONFIG_FONTS='%(fonts)s' CONFIG_FONTS='%(fonts)s'
CONFIG_INPUT_PLUGINS='%(input_plugins)s' CONFIG_INPUT_PLUGINS='%(input_plugins)s'
CONFIG_GIT_REVISION='%(git_revision)s' CONFIG_MAPNIK_DEFINES='%(defines)s'
CONFIG_MAPNIK_AGG_INCLUDE=${CONFIG_PREFIX}/include/mapnik/agg 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) os.chmod(config_file,0755)
except: pass 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 += ' ' dep_includes += ' '
other_includes += ' '.join(config_env['LIBMAPNIK_CXXFLAGS'])
other_includes += ' '
if config_env['HAS_CAIRO']: 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('#')]) 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','') dep_libs = dep_libs.replace('-lagg','')
git_revision = 'unknown' 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 # more info: https://github.com/mapnik/mapnik/wiki/MapnikReleaseSteps
revision_release_file = '../../GIT_REVISION' revision_release_file = '../../GIT_REVISION'
if os.path.exists(revision_release_file): if os.path.exists(revision_release_file):
@ -73,16 +73,28 @@ else:
if not stderr: if not stderr:
git_revision = stdin.strip() 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 = { configuration = {
"git_revision": git_revision,
"git_describe": git_describe,
"version": config_env['MAPNIK_VERSION_STRING'],
"mapnik_libname": 'mapnik', "mapnik_libname": 'mapnik',
"libdir_schema": config_env['LIBDIR_SCHEMA'], "libdir_schema": config_env['LIBDIR_SCHEMA'],
"ldflags": ldflags, "ldflags": ldflags,
"dep_libs": dep_libs, "dep_libs": dep_libs,
"other_includes": other_includes, "dep_includes": dep_includes,
"fonts": config_env['MAPNIK_FONTS'], "fonts": config_env['MAPNIK_FONTS'],
"input_plugins": config_env['MAPNIK_INPUT_PLUGINS'], "input_plugins": config_env['MAPNIK_INPUT_PLUGINS'],
"git_revision": git_revision, "defines":defines,
"version": config_env['MAPNIK_VERSION_STRING'], "cxxflags":cxxflags
} }
## if we are statically linking depedencies ## if we are statically linking depedencies

View file

@ -1,21 +1,6 @@
## program below ## 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() usage()
{ {
cat <<EOF cat <<EOF
@ -23,67 +8,61 @@ Usage: mapnik-config [OPTION]
Known values for OPTION are: Known values for OPTION are:
--prefix display Mapnik prefix [default $CONFIG_PREFIX] -h --help display this help and exit
--prefix=DIR change Mapnik prefix [default $CONFIG_PREFIX] -v --version version information
--libs print library linking information --git-revision git hash from "git rev-list --max-count=1 HEAD"
--dep-libs print library linking information for Mapnik dependencies --git-describe git decribe output (new in 2.2.x)
--ldflags print library paths (-L) information --fonts default fonts directory
--defines print pre-processor defines for mapnik build --input-plugins default input plugins directory
--includes print include paths --defines pre-processor defines for Mapnik build (new in 2.2.x)
--dep-includes print include paths --prefix Mapnik prefix [default $CONFIG_PREFIX]
--cxxflags print c++ compiler flags and pre-processor defines --lib-name Mapnik library name
--cflags print c++ compiler flags and pre-processor defines (same as cxxflags, for back-compatibility) --libs library linking information
--fonts print default fonts directory --dep-libs library linking information for Mapnik dependencies
--input-plugins print default input plugins directory --ldflags library paths (-L) information
--json print all config options as json object --includes include paths (-I) for Mapnik headers (new in 2.2.x)
--help display this help and exit --dep-includes include paths (-I) for Mapnik dependencies (new in 2.2.x)
-v --version output version information --cxxflags c++ compiler flags and pre-processor defines (new in 2.2.x)
--git-revision output git hash --cflags c++ compiler flags and pre-processor defines (same as cxxflags, for back-compatibility)
EOF EOF
exit $1 exit $1
} }
echoerr() { echo "$@" 1>&2; }
if test $# -eq 0; then if test $# -eq 0; then
usage 1 usage 1
fi fi
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac esac
case "$1" in case "$1" in
--prefix=*) --help)
prefix=$optarg usage 0
includedir=$CONFIG_PREFIX/include
CONFIG_MAPNIK_LIB=$CONFIG_PREFIX/lib
;; ;;
--prefix) -h)
echo $CONFIG_PREFIX usage 0
;; ;;
-v) -v)
echo $CONFIG_MAPNIK_VERSION echo ${CONFIG_MAPNIK_VERSION}
;; ;;
--version) --version)
echo $CONFIG_MAPNIK_VERSION echo $CONFIG_MAPNIK_VERSION
;; ;;
--json)
echo $CONFIG_JSON
;;
--git-revision) --git-revision)
echo ${CONFIG_GIT_REVISION} echo ${CONFIG_GIT_REVISION}
;; ;;
--help) --git-describe)
usage 0 echo ${CONFIG_GIT_DESCRIBE}
;; ;;
--fonts) --fonts)
@ -94,34 +73,49 @@ while test $# -gt 0; do
echo ${CONFIG_INPUT_PLUGINS} echo ${CONFIG_INPUT_PLUGINS}
;; ;;
--cxxflags) --defines)
echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES} echo ${CONFIG_MAPNIK_DEFINES}
;; ;;
--cflags) --prefix)
echo -I${CONFIG_MAPNIK_INCLUDE} -I${CONFIG_MAPNIK_AGG_INCLUDE} ${CONFIG_OTHER_INCLUDES} echo ${CONFIG_PREFIX}
;;
--libs)
echo -L${CONFIG_MAPNIK_LIB} -l${CONFIG_MAPNIK_LIBNAME}
;;
--ldflags)
echo ${CONFIG_MAPNIK_LDFLAGS}
;; ;;
--lib-name) --lib-name)
echo ${CONFIG_MAPNIK_LIBNAME} echo ${CONFIG_MAPNIK_LIBNAME}
;; ;;
--libs)
echo -L${CONFIG_MAPNIK_LIB} -l${CONFIG_MAPNIK_LIBNAME}
;;
--dep-libs) --dep-libs)
echo ${CONFIG_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) # push to stderr any invalid options
usage 1 echo "unknown option $1" 1>&2;
exit 1
;; ;;
esac esac
shift shift

View file

@ -39,7 +39,7 @@ program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) 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']) program_env.PrependUnique(CPPPATH=['#plugins/input/postgis'])

View file

@ -37,7 +37,7 @@ program_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS']) program_env.PrependUnique(CPPPATH=env['CAIRO_CPPPATHS'])
program_env.Append(CXXFLAGS = '-DHAVE_CAIRO') program_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
libraries = copy(env['LIBMAPNIK_LIBS']) libraries = copy(env['LIBMAPNIK_LIBS'])
boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND']