add support for statically linking datasource input plugins - closes #1810 and #1821 - refs #249

This commit is contained in:
Dane Springmeyer 2013-05-16 11:33:23 -07:00
parent c34f86e08f
commit 3fbf4df67d
20 changed files with 622 additions and 355 deletions

View file

@ -68,6 +68,8 @@ For a complete change history, see the git log.
now the combined layer extents will be again respected: they will be clipped to the maximum-extent if possible now the combined layer extents will be again respected: they will be clipped to the maximum-extent if possible
and only when back-projecting fails for all layers will the maximum-extent be used as a fallback (#1473) and only when back-projecting fails for all layers will the maximum-extent be used as a fallback (#1473)
- Compile time flag called `PLUGIN_LINKING` to allow input datasource plugins to be statically linked with the mapnik library (#249)
## Mapnik 2.1.0 ## Mapnik 2.1.0
Released Aug 23, 2012 Released Aug 23, 2012

View file

@ -313,8 +313,8 @@ opts.AddVariables(
('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'), ('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'),
PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept), PathVariable('ICU_INCLUDES', 'Search path for ICU include files', '/usr/include', PathVariable.PathAccept),
PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('ICU_LIBS','Search path for ICU include files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc', ('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc', PathVariable.PathAccept),
PathVariable.PathAccept),
BoolVariable('PNG', 'Build Mapnik with PNG read and write support', 'True'), BoolVariable('PNG', 'Build Mapnik with PNG read and write support', 'True'),
PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept), PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept),
PathVariable('PNG_LIBS','Search path for libpng library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept), PathVariable('PNG_LIBS','Search path for libpng library files','/usr/' + LIBDIR_SCHEMA_DEFAULT, PathVariable.PathAccept),
@ -357,6 +357,9 @@ PathVariable.PathAccept),
BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'), BoolVariable('ENABLE_STATS', 'Enable global statistics during map processing', 'False'),
('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities) + ')', 'error'), ('DEFAULT_LOG_SEVERITY', 'The default severity of the logger (eg. ' + ', '.join(severities) + ')', 'error'),
# Plugin linking
EnumVariable('PLUGIN_LINKING', "Set plugin linking with libmapnik", 'shared', ['shared','static']),
# Other variables # Other variables
BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'), BoolVariable('SHAPE_MEMORY_MAPPED_FILE', 'Utilize memory-mapped files in Shapefile Plugin (higher memory usage, better performance)', 'True'),
('SYSTEM_FONTS','Provide location for python bindings to register fonts (if provided then the bundled DejaVu fonts are not installed)',''), ('SYSTEM_FONTS','Provide location for python bindings to register fonts (if provided then the bundled DejaVu fonts are not installed)',''),
@ -439,7 +442,7 @@ pickle_store = [# Scons internal variables
'LIBMAPNIK_DEFINES', 'LIBMAPNIK_DEFINES',
'LIBMAPNIK_CXXFLAGS', 'LIBMAPNIK_CXXFLAGS',
'CAIRO_LIBPATHS', 'CAIRO_LIBPATHS',
'CAIRO_LINKFLAGS', 'CAIRO_ALL_LIBS',
'CAIRO_CPPPATHS', 'CAIRO_CPPPATHS',
'SVG_RENDERER', 'SVG_RENDERER',
'SQLITE_LINKFLAGS', 'SQLITE_LINKFLAGS',
@ -1039,11 +1042,12 @@ if not preconfigured:
env['SKIPPED_DEPS'] = [] env['SKIPPED_DEPS'] = []
env['HAS_CAIRO'] = False env['HAS_CAIRO'] = False
env['CAIRO_LIBPATHS'] = [] env['CAIRO_LIBPATHS'] = []
env['CAIRO_LINKFLAGS'] = [] env['CAIRO_ALL_LIBS'] = []
env['CAIRO_CPPPATHS'] = [] env['CAIRO_CPPPATHS'] = []
env['HAS_PYCAIRO'] = False env['HAS_PYCAIRO'] = False
env['HAS_LIBXML2'] = False env['HAS_LIBXML2'] = False
env['LIBMAPNIK_LIBS'] = [] env['LIBMAPNIK_LIBS'] = []
env['LIBMAPNIK_LINKFLAGS'] = []
env['LIBMAPNIK_CPPATHS'] = [] env['LIBMAPNIK_CPPATHS'] = []
env['LIBMAPNIK_DEFINES'] = [] env['LIBMAPNIK_DEFINES'] = []
env['LIBMAPNIK_CXXFLAGS'] = [] env['LIBMAPNIK_CXXFLAGS'] = []
@ -1401,9 +1405,9 @@ if not preconfigured:
#os.path.join(c_inc,'include/libpng'), #os.path.join(c_inc,'include/libpng'),
] ]
) )
env["CAIRO_LINKFLAGS"] = ['cairo'] env["CAIRO_ALL_LIBS"] = ['cairo']
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
env["CAIRO_LINKFLAGS"].extend( env["CAIRO_ALL_LIBS"].extend(
['pixman-1','expat','fontconfig','iconv'] ['pixman-1','expat','fontconfig','iconv']
) )
# todo - run actual checkLib? # todo - run actual checkLib?
@ -1426,7 +1430,7 @@ if not preconfigured:
cairo_env.ParseConfig(cmd) cairo_env.ParseConfig(cmd)
for lib in cairo_env['LIBS']: for lib in cairo_env['LIBS']:
if not lib in env['LIBS']: if not lib in env['LIBS']:
env["CAIRO_LINKFLAGS"].append(lib) env["CAIRO_ALL_LIBS"].append(lib)
for lpath in cairo_env['LIBPATH']: for lpath in cairo_env['LIBPATH']:
if not lpath in env['LIBPATH']: if not lpath in env['LIBPATH']:
env["CAIRO_LIBPATHS"].append(lpath) env["CAIRO_LIBPATHS"].append(lpath)
@ -1794,6 +1798,7 @@ if not HELP_REQUESTED:
for plugin in env['REQUESTED_PLUGINS']: for plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin] details = env['PLUGINS'][plugin]
if details['lib'] in env['LIBS']: if details['lib'] in env['LIBS']:
if env['PLUGIN_LINKING'] == 'shared':
SConscript('plugins/input/%s/build.py' % plugin) SConscript('plugins/input/%s/build.py' % plugin)
if plugin == 'ogr': OGR_BUILT = True if plugin == 'ogr': OGR_BUILT = True
if plugin == 'gdal': GDAL_BUILT = True if plugin == 'gdal': GDAL_BUILT = True
@ -1803,7 +1808,8 @@ if not HELP_REQUESTED:
else: else:
env['LIBS'].remove(details['lib']) env['LIBS'].remove(details['lib'])
elif not details['lib']: elif not details['lib']:
# build internal shape and raster plugins if env['PLUGIN_LINKING'] == 'shared':
# build internal datasource input plugins
SConscript('plugins/input/%s/build.py' % plugin) SConscript('plugins/input/%s/build.py' % plugin)
else: else:
color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin) color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin)
@ -1818,9 +1824,9 @@ if not HELP_REQUESTED:
# installed plugins that we are no longer building # installed plugins that we are no longer building
if 'install' in COMMAND_LINE_TARGETS: if 'install' in COMMAND_LINE_TARGETS:
for plugin in PLUGINS.keys(): for plugin in PLUGINS.keys():
if plugin not in env['REQUESTED_PLUGINS']:
plugin_path = os.path.join(env['MAPNIK_INPUT_PLUGINS_DEST'],'%s.input' % plugin) plugin_path = os.path.join(env['MAPNIK_INPUT_PLUGINS_DEST'],'%s.input' % plugin)
if os.path.exists(plugin_path): if os.path.exists(plugin_path):
if plugin not in env['REQUESTED_PLUGINS'] or env['PLUGIN_LINKING'] == 'static':
color_print(3,"Notice: removing out of date plugin: '%s'" % plugin_path) color_print(3,"Notice: removing out of date plugin: '%s'" % plugin_path)
os.unlink(plugin_path) os.unlink(plugin_path)

View file

@ -177,7 +177,7 @@ if 'uninstall' not in COMMAND_LINE_TARGETS:
py_env.Append(CPPPATH = env['CAIRO_CPPPATHS']) py_env.Append(CPPPATH = env['CAIRO_CPPPATHS'])
py_env.Append(CPPDEFINES = '-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_ALL_LIBS'])
if env['HAS_PYCAIRO']: if env['HAS_PYCAIRO']:
py_env.ParseConfig('pkg-config --cflags pycairo') py_env.ParseConfig('pkg-config --cflags pycairo')

View file

@ -134,6 +134,9 @@ public:
typedef boost::shared_ptr<datasource> datasource_ptr; typedef boost::shared_ptr<datasource> datasource_ptr;
#ifdef MAPNIK_STATIC_PLUGINS
#define DATASOURCE_PLUGIN(classname)
#else
#define DATASOURCE_PLUGIN(classname) \ #define DATASOURCE_PLUGIN(classname) \
extern "C" MAPNIK_EXP const char * datasource_name() \ extern "C" MAPNIK_EXP const char * datasource_name() \
{ \ { \
@ -147,6 +150,7 @@ typedef boost::shared_ptr<datasource> datasource_ptr;
{ \ { \
delete ds; \ delete ds; \
} }
#endif
} }

View file

@ -1,12 +1,29 @@
#!/usr/bin/env python #
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
import os
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
PLUGIN_NAME = 'csv' PLUGIN_NAME = 'csv'
install_dest = env['MAPNIK_INPUT_PLUGINS_DEST']
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
plugin_sources = Split( plugin_sources = Split(
@ -15,23 +32,31 @@ plugin_sources = Split(
""" % locals() """ % locals()
) )
# Link Library to Dependencies
libraries = [] libraries = []
libraries.append('mapnik')
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
TARGET = plugin_env.SharedLibrary( if env['PLUGIN_LINKING'] == 'shared':
'../%s' % PLUGIN_NAME, libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='', SHLIBPREFIX='',
SHLIBSUFFIX='.input', SHLIBSUFFIX='.input',
source=plugin_sources, source=plugin_sources,
LIBS=libraries, LIBS=libraries,
LINKFLAGS=env.get('CUSTOM_LDFLAGS') LINKFLAGS=env.get('CUSTOM_LDFLAGS'))
)
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_dest, TARGET) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', install_dest) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,35 +22,47 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'gdal'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
gdal_src = Split( plugin_sources = Split(
"""
gdal_datasource.cpp
gdal_featureset.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
""" % locals()
) )
# clear out and rebuild libs
plugin_env['LIBS'] = [env['PLUGINS']['gdal']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
plugin_env['LIBS'].append('mapnik') libraries = [env['PLUGINS']['gdal']['lib']]
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
plugin_env['LIBS'].append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
cmd = 'gdal-config --dep-libs' cmd = 'gdal-config --dep-libs'
plugin_env.ParseConfig(cmd) plugin_env.ParseConfig(cmd)
plugin_env['LIBS'].append('proj') libraries.append('proj')
input_plugin = plugin_env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2012 Artem Pavlenko # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -17,7 +17,7 @@
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# #
#
Import ('env') Import ('env')
@ -32,27 +32,45 @@ if not can_build:
print 'WARNING: skipping building the optional geojson datasource plugin which requires boost >= 1.47' print 'WARNING: skipping building the optional geojson datasource plugin which requires boost >= 1.47'
else: else:
Import ('plugin_base') Import ('plugin_base')
prefix = env['PREFIX']
PLUGIN_NAME = 'geojson'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
geojson_src = Split(
""" plugin_sources = Split(
geojson_datasource.cpp
geojson_featureset.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
""" % locals()
) )
libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik') libraries = []
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
libraries.append('boost_thread%s' % env['BOOST_APPEND']) libraries.append('boost_thread%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../geojson', source=geojson_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,30 +22,44 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'occi'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
occi_src = Split( plugin_sources = Split(
""" """
occi_types.cpp %(PLUGIN_NAME)s_types.cpp
occi_datasource.cpp %(PLUGIN_NAME)s_datasource.cpp
occi_featureset.cpp %(PLUGIN_NAME)s_featureset.cpp
spatial_classesm.cpp spatial_classesm.cpp
spatial_classeso.cpp spatial_classeso.cpp
""" """ % locals()
) )
libraries = [ 'occi', 'ociei' ] libraries = [ 'occi', 'ociei' ]
libraries.append('mapnik')
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
input_plugin = plugin_env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -19,48 +19,65 @@
# #
# #
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'ogr'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
ogr_src = Split( plugin_sources = Split(
"""
ogr_converter.cpp
ogr_datasource.cpp
ogr_featureset.cpp
ogr_index_featureset.cpp
""" """
%(PLUGIN_NAME)s_converter.cpp
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
%(PLUGIN_NAME)s_index_featureset.cpp
""" % locals()
) )
plugin_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
plugin_env['LIBS'].append('mapnik') libraries = [env['PLUGINS']['ogr']['lib']]
plugin_env['LIBS'].append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
plugin_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
cxxflags = []
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
cmd = 'gdal-config --dep-libs' cmd = 'gdal-config --dep-libs'
plugin_env.ParseConfig(cmd) plugin_env.ParseConfig(cmd)
plugin_env['LIBS'].append('proj') libraries.append('proj')
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])
if boost_version_from_header < 46: if boost_version_from_header < 46:
# avoid ubuntu issue with boost interprocess: # avoid ubuntu issue with boost interprocess:
# https://github.com/mapnik/mapnik/issues/1082 # https://github.com/mapnik/mapnik/issues/1082
plugin_env.Append(CXXFLAGS = '-fpermissive') cxxflags.Append('-fpermissive')
input_plugin = plugin_env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS']) plugin_env.Append(CXXFLAGS=cxxflags)
if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'CXXFLAGS': cxxflags,
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,33 +22,48 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'osm'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
osm_src = Split( plugin_sources = Split(
""" """
%(PLUGIN_NAME)s.cpp
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
osmparser.cpp osmparser.cpp
osm.cpp
osm_datasource.cpp
osm_featureset.cpp
dataset_deliverer.cpp dataset_deliverer.cpp
basiccurl.cpp basiccurl.cpp
""" """ % locals()
) )
# Link Library to Dependencies
libraries = [ 'xml2' ] libraries = [ 'xml2' ]
libraries.append('curl') libraries.append('curl')
libraries.append('mapnik')
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,39 +22,52 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'postgis'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
postgis_src = Split( plugin_sources = Split(
"""
postgis_datasource.cpp
postgis_featureset.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
""" % locals()
) )
# clear out and rebuild libs
plugin_env['LIBS'] = ['pq']
# Link Library to Dependencies # Link Library to Dependencies
plugin_env['LIBS'].append('mapnik') libraries = ['pq']
plugin_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
plugin_env['LIBS'].append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
plugin_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND']) libraries.append('boost_thread%s' % env['BOOST_APPEND'])
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
#cmd = 'pg_config --libs' #cmd = 'pg_config --libs'
#plugin_env.ParseConfig(cmd) #plugin_env.ParseConfig(cmd)
# pg_config does not seem to report correct deps of libpq # pg_config does not seem to report correct deps of libpq
# so resort to hardcoding for now # so resort to hardcoding for now
plugin_env['LIBS'].extend(['ldap','pam','ssl','crypto','krb5']) libraries.extend(['ldap', 'pam', 'ssl', 'crypto', 'krb5'])
input_plugin = plugin_env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,13 +1,29 @@
#!/usr/bin/env python #
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2013 Artem Pavlenko
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
import os import os
PLUGIN_NAME = 'python'
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
install_dest = env['MAPNIK_INPUT_PLUGINS_DEST'] PLUGIN_NAME = 'python'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
@ -19,9 +35,15 @@ plugin_sources = Split(
""" % locals() """ % locals()
) )
boost_system = 'boost_system%s' % env['BOOST_APPEND'] # Link Library to Dependencies
libraries = ['mapnik',env['BOOST_PYTHON_LIB'],boost_system,env['ICU_LIB_NAME']] libraries = []
libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append(env['BOOST_PYTHON_LIB'])
libraries.append(env['ICU_LIB_NAME'])
python_cpppath = env['PYTHON_INCLUDES']
allcpp_paths = env['CPPPATH']
allcpp_paths.extend(python_cpppath)
# NOTE: explicit linking to libpython is uneeded on most linux version if the # NOTE: explicit linking to libpython is uneeded on most linux version if the
# python plugin is used by a app in python using mapnik's python bindings # python plugin is used by a app in python using mapnik's python bindings
# we explicitly link to libpython here so that this plugin # we explicitly link to libpython here so that this plugin
@ -48,26 +70,15 @@ if env['CUSTOM_LDFLAGS']:
else: else:
linkflags = python_link_flag linkflags = python_link_flag
plugin_env.Append(CPPPATH = env['PYTHON_INCLUDES']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary( TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
# the name of the target to build, eg 'sqlite.input'
'../%s' % PLUGIN_NAME,
# prefix - normally none used
SHLIBPREFIX='', SHLIBPREFIX='',
# extension, mapnik expects '.input'
SHLIBSUFFIX='.input', SHLIBSUFFIX='.input',
# list of source files to compile
source=plugin_sources, source=plugin_sources,
# libraries to link to CPPPATH=allcpp_paths,
LIBS=libraries, LIBS=libraries,
# any custom linkflags, eg. LDFLAGS LINKFLAGS=linkflags)
# in this case CUSTOM_LDFLAGS comes
# from Mapnik's main SConstruct file
# and can be removed here if you do
# not need it
LINKFLAGS=linkflags
)
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
@ -76,5 +87,14 @@ Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
# then we actually create the install targets that # then we actually create the install targets that
# scons will install if 'install' is passed as an arg # scons will install if 'install' is passed as an arg
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_dest, TARGET) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', install_dest) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
'CPPPATH': python_cpppath,
'LINKFLAGS': linkflags.replace('-Z','').split(' '),
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,30 +22,44 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'raster'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
raster_src = Split( plugin_sources = Split(
"""
raster_datasource.cpp
raster_featureset.cpp
raster_info.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
%(PLUGIN_NAME)s_info.cpp
""" % locals()
) )
libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik') libraries = []
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,30 +22,43 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'rasterlite'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
rasterlite_src = Split( plugin_sources = Split(
"""
rasterlite_datasource.cpp
rasterlite_featureset.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
""" % locals()
) )
libraries = [env['PLUGINS']['rasterlite']['lib']]
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik') libraries = [env['PLUGINS']['rasterlite']['lib']]
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
input_plugin = plugin_env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
#
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2006 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -19,48 +19,68 @@
# #
# #
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'shape'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
shape_src = Split( plugin_sources = Split(
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
%(PLUGIN_NAME)s_index_featureset.cpp
%(PLUGIN_NAME)s_io.cpp
%(PLUGIN_NAME)s_utils.cpp
dbfile.cpp dbfile.cpp
shape_datasource.cpp """ % locals()
shape_featureset.cpp
shape_index_featureset.cpp
shape_io.cpp
shape_utils.cpp
"""
) )
libraries = []
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik') libraries = []
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
cppdefines = []
cxxflags = []
if env['SHAPE_MEMORY_MAPPED_FILE']: if env['SHAPE_MEMORY_MAPPED_FILE']:
plugin_env.Append(CPPDEFINES = '-DSHAPE_MEMORY_MAPPED_FILE') cppdefines.append('-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])
if boost_version_from_header < 46: if boost_version_from_header < 46:
# avoid ubuntu issue with boost interprocess: # avoid ubuntu issue with boost interprocess:
# https://github.com/mapnik/mapnik/issues/1082 # https://github.com/mapnik/mapnik/issues/1082
plugin_env.Append(CXXFLAGS = '-fpermissive') cxxflags.append('-fpermissive')
input_plugin = plugin_env.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) plugin_env.Append(CXXFLAGS=cxxflags)
plugin_env.Append(CPPDEFINES=cppdefines)
if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary('../shape',
SHLIBSUFFIX='.input',
SHLIBPREFIX='',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=env['CUSTOM_LDFLAGS'])
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
'CXXFLAGS': cxxflags,
'CPPDEFINES': cppdefines,
}
Return('plugin_obj')

View file

@ -1,7 +1,7 @@
# #
# This file is part of Mapnik (c++ mapping toolkit) # This file is part of Mapnik (c++ mapping toolkit)
# #
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon # Copyright (C) 2013 Artem Pavlenko
# #
# Mapnik is free software; you can redistribute it and/or # Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public # modify it under the terms of the GNU Lesser General Public
@ -22,34 +22,49 @@
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
prefix = env['PREFIX'] PLUGIN_NAME = 'sqlite'
plugin_env = plugin_base.Clone() plugin_env = plugin_base.Clone()
sqlite_src = Split( plugin_sources = Split(
"""
sqlite_datasource.cpp
sqlite_featureset.cpp
""" """
%(PLUGIN_NAME)s_datasource.cpp
%(PLUGIN_NAME)s_featureset.cpp
""" % locals()
) )
libraries = [ 'sqlite3' ]
# Link Library to Dependencies # Link Library to Dependencies
libraries.append('mapnik') libraries = [ 'sqlite3' ]
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
libraries.append('boost_filesystem%s' % env['BOOST_APPEND']) libraries.append('boost_filesystem%s' % env['BOOST_APPEND'])
linkflags = env['CUSTOM_LDFLAGS'] linkflags = []
if env['SQLITE_LINKFLAGS']: if env['SQLITE_LINKFLAGS']:
linkflags.append(env['SQLITE_LINKFLAGS']) linkflags.append(env['SQLITE_LINKFLAGS'])
input_plugin = plugin_env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries, LINKFLAGS=linkflags) if env['PLUGIN_LINKING'] == 'shared':
libraries.append('mapnik')
linkflags.append(env['CUSTOM_LDFLAGS'])
TARGET = plugin_env.SharedLibrary('../%s' % PLUGIN_NAME,
SHLIBPREFIX='',
SHLIBSUFFIX='.input',
source=plugin_sources,
LIBS=libraries,
LINKFLAGS=linkflags)
# if the plugin links to libmapnik ensure it is built first # if the plugin links to libmapnik ensure it is built first
Depends(input_plugin, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME'])) Depends(TARGET, env.subst('../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], input_plugin) env.Install(env['MAPNIK_INPUT_PLUGINS_DEST'], TARGET)
env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST']) env.Alias('install', env['MAPNIK_INPUT_PLUGINS_DEST'])
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
'LINKFLAGS': linkflags,
}
Return('plugin_obj')

View file

@ -11,21 +11,17 @@
import os import os
# Give this plugin a name
# here this happens to be the same as the directory
PLUGIN_NAME = 'hello'
# Here we pull from the SCons environment exported from the main instance # Here we pull from the SCons environment exported from the main instance
Import ('plugin_base') Import ('plugin_base')
Import ('env') Import ('env')
# Give this plugin a name
# here this happens to be the same as the directory
PLUGIN_NAME = 'hello'
# the below install details are also pulled from the # the below install details are also pulled from the
# main SConstruct file where configuration happens # main SConstruct file where configuration happens
# plugins can go anywhere, and be registered in custom locations by Mapnik
# but the standard location is '/usr/local/lib/mapnik/input'
install_dest = env['MAPNIK_INPUT_PLUGINS_DEST']
# clone the environment here # clone the environment here
# so that if we modify the env it in this file # so that if we modify the env it in this file
# those changes to not pollute other builds later on... # those changes to not pollute other builds later on...
@ -43,12 +39,20 @@ plugin_sources = Split(
# directly link to # directly link to
libraries = [ '' ] # eg 'libfoo' libraries = [ '' ] # eg 'libfoo'
libraries.append('mapnik')
libraries.append('boost_system%s' % env['BOOST_APPEND']) libraries.append('boost_system%s' % env['BOOST_APPEND'])
# link libicuuc, but ICU_LIB_NAME is used custom builds of icu can # link libicuuc, but ICU_LIB_NAME is used custom builds of icu can
# have different library names like osx which offers /usr/lib/libicucore.dylib # have different library names like osx which offers /usr/lib/libicucore.dylib
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
# this is valid if we are building an external plugin as shared library
if env['PLUGIN_LINKING'] == 'shared':
# plugins can go anywhere, and be registered in custom locations by Mapnik
# but the standard location is '/usr/local/lib/mapnik/input'
install_dest = env['MAPNIK_INPUT_PLUGINS_DEST']
# only link mapnik if we are build an external shared object
libraries.append('mapnik')
TARGET = plugin_env.SharedLibrary( TARGET = plugin_env.SharedLibrary(
# the name of the target to build, eg 'sqlite.input' # the name of the target to build, eg 'sqlite.input'
'../%s' % PLUGIN_NAME, '../%s' % PLUGIN_NAME,
@ -77,3 +81,12 @@ Depends(TARGET, env.subst('../../../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_dest, TARGET) env.Install(install_dest, TARGET)
env.Alias('install', install_dest) env.Alias('install', install_dest)
# Return the plugin building options to scons
# This is used when statically linking the plugin with mapnik)
plugin_obj = {
'LIBS': libraries,
'SOURCES': plugin_sources,
}
Return('plugin_obj')

View file

@ -81,7 +81,6 @@ lib_env['LIBS'].append('xml2')
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':
lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND']) lib_env['LIBS'].append('boost_thread%s' % env['BOOST_APPEND'])
if env['RUNTIME_LINK'] == 'static': if env['RUNTIME_LINK'] == 'static':
if 'icuuc' in env['ICU_LIB_NAME']: if 'icuuc' in env['ICU_LIB_NAME']:
lib_env['LIBS'].append('icudata') lib_env['LIBS'].append('icudata')
@ -124,6 +123,7 @@ source = Split(
box2d.cpp box2d.cpp
building_symbolizer.cpp building_symbolizer.cpp
datasource_cache.cpp datasource_cache.cpp
datasource_cache_static.cpp
debug.cpp debug.cpp
deepcopy.cpp deepcopy.cpp
expression_node.cpp expression_node.cpp
@ -207,9 +207,31 @@ source = Split(
""" """
) )
if env['PLUGIN_LINKING'] == 'static':
lib_env.Append(CPPDEFINES = '-DMAPNIK_STATIC_PLUGINS')
for plugin in env['REQUESTED_PLUGINS']:
details = env['PLUGINS'][plugin]
if details['lib'] in env['LIBS'] or not details['lib']:
lib_env.Append(CPPDEFINES = '-DMAPNIK_STATIC_PLUGIN_%s' % plugin.upper())
plugin_env = SConscript('../plugins/input/%s/build.py' % plugin)
if plugin_env.has_key('SOURCES') and plugin_env['SOURCES']:
source += ['../plugins/input/%s/%s' % (plugin, src) for src in plugin_env['SOURCES']]
if plugin_env.has_key('CPPDEFINES') and plugin_env['CPPDEFINES']:
lib_env.AppendUnique(CPPDEFINES=plugin_env['CPPDEFINES'])
if plugin_env.has_key('CXXFLAGS') and plugin_env['CXXFLAGS']:
lib_env.AppendUnique(CXXFLAGS=plugin_env['CXXFLAGS'])
if plugin_env.has_key('LINKFLAGS') and plugin_env['LINKFLAGS']:
lib_env.AppendUnique(LINKFLAGS=plugin_env['LINKFLAGS'])
if plugin_env.has_key('CPPPATH') and plugin_env['CPPPATH']:
lib_env.AppendUnique(CPPPATH=copy(plugin_env['CPPPATH']))
if plugin_env.has_key('LIBS') and plugin_env['LIBS']:
lib_env.AppendUnique(LIBS=plugin_env['LIBS'])
else:
print("Notice: dependencies not met for plugin '%s', not building..." % plugin)
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_ALL_LIBS'])
lib_env.Append(CPPDEFINES = '-DHAVE_CAIRO') lib_env.Append(CPPDEFINES = '-DHAVE_CAIRO')
libmapnik_defines.append('-DHAVE_CAIRO') libmapnik_defines.append('-DHAVE_CAIRO')
lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS'])) lib_env.AppendUnique(CPPPATH=copy(env['CAIRO_CPPPATHS']))
@ -350,13 +372,17 @@ if env['RENDERING_STATS']:
else: else:
source.insert(0,processor_cpp); source.insert(0,processor_cpp);
# clone the env one more time to isolate mapnik_lib_link_flag
lib_env_final = lib_env.Clone()
if env['CUSTOM_LDFLAGS']: if env['CUSTOM_LDFLAGS']:
linkflags = '%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag) lib_env_final.Prepend(LINKFLAGS='%s %s' % (env['CUSTOM_LDFLAGS'], mapnik_lib_link_flag))
else: else:
linkflags = mapnik_lib_link_flag lib_env_final.Prepend(LINKFLAGS=mapnik_lib_link_flag)
# 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_LINKFLAGS'] = copy(lib_env['LINKFLAGS'])
env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags env['LIBMAPNIK_CXXFLAGS'] = libmapnik_cxxflags
env['LIBMAPNIK_DEFINES'] = libmapnik_defines env['LIBMAPNIK_DEFINES'] = libmapnik_defines
@ -366,9 +392,9 @@ if env['PLATFORM'] == 'Darwin':
target_path = env['MAPNIK_LIB_BASE_DEST'] target_path = env['MAPNIK_LIB_BASE_DEST']
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
mapnik = lib_env.StaticLibrary('mapnik', source, LINKFLAGS=linkflags) mapnik = lib_env_final.StaticLibrary('mapnik', source)
else: else:
mapnik = lib_env.SharedLibrary('mapnik', source, LINKFLAGS=linkflags) mapnik = lib_env_final.SharedLibrary('mapnik', source)
result = env.Install(target_path, mapnik) result = env.Install(target_path, mapnik)
env.Alias(target='install', source=result) env.Alias(target='install', source=result)
@ -390,15 +416,14 @@ else:
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
mapnik = lib_env.StaticLibrary('mapnik', source, LINKFLAGS=linkflags) mapnik = lib_env_final.StaticLibrary('mapnik', source)
else: else:
mapnik = lib_env.SharedLibrary('mapnik', source, LINKFLAGS=linkflags) mapnik = lib_env_final.SharedLibrary('mapnik', source)
result = env.InstallAs(target=target, source=mapnik) result = env.InstallAs(target=target, source=mapnik)
env.Alias(target='install', source=result) env.Alias(target='install', source=result)
if result: if result:
env.AddPostAction(result, ldconfig) env.AddPostAction(result, ldconfig)
# Install symlinks # Install symlinks
target1 = os.path.join(env['MAPNIK_LIB_BASE_DEST'], "%s.%d.%d" % \ target1 = os.path.join(env['MAPNIK_LIB_BASE_DEST'], "%s.%d.%d" % \
(os.path.basename(env.subst(env['MAPNIK_LIB_NAME'])),int(major), int(minor))) (os.path.basename(env.subst(env['MAPNIK_LIB_NAME'])),int(major), int(minor)))

View file

@ -38,6 +38,9 @@
namespace mapnik { namespace mapnik {
extern datasource_ptr create_static_datasource(parameters const& params);
extern std::vector<std::string> get_static_datasource_names();
bool is_input_plugin(std::string const& filename) bool is_input_plugin(std::string const& filename)
{ {
return boost::algorithm::ends_with(filename,std::string(".input")); return boost::algorithm::ends_with(filename,std::string(".input"));
@ -62,11 +65,21 @@ datasource_ptr datasource_cache::create(parameters const& params)
"parameter 'type' is missing"); "parameter 'type' is missing");
} }
datasource_ptr ds;
#ifdef MAPNIK_STATIC_PLUGINS
// return if it's created, raise otherwise
ds = create_static_datasource(params);
if (ds)
{
return ds;
}
#endif
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
#endif #endif
datasource_ptr ds;
std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type); std::map<std::string,boost::shared_ptr<PluginInfo> >::iterator itr=plugins_.find(*type);
if (itr == plugins_.end()) if (itr == plugins_.end())
{ {
@ -101,7 +114,13 @@ datasource_ptr datasource_cache::create(parameters const& params)
itr->second->get_error()); itr->second->get_error());
} }
ds = datasource_ptr(create_datasource(params), datasource_deleter());
#ifdef MAPNIK_LOG #ifdef MAPNIK_LOG
MAPNIK_LOG_DEBUG(datasource_cache)
<< "datasource_cache: Datasource="
<< ds << " type=" << type;
MAPNIK_LOG_DEBUG(datasource_cache) MAPNIK_LOG_DEBUG(datasource_cache)
<< "datasource_cache: Size=" << "datasource_cache: Size="
<< params.size(); << params.size();
@ -115,12 +134,6 @@ datasource_ptr datasource_cache::create(parameters const& params)
} }
#endif #endif
ds = datasource_ptr(create_datasource(params), datasource_deleter());
MAPNIK_LOG_DEBUG(datasource_cache)
<< "datasource_cache: Datasource="
<< ds << " type=" << type;
return ds; return ds;
} }
@ -132,11 +145,17 @@ std::string datasource_cache::plugin_directories()
std::vector<std::string> datasource_cache::plugin_names() std::vector<std::string> datasource_cache::plugin_names()
{ {
std::vector<std::string> names; std::vector<std::string> names;
#ifdef MAPNIK_STATIC_PLUGINS
names = get_static_datasource_names();
#endif
std::map<std::string,boost::shared_ptr<PluginInfo> >::const_iterator itr; std::map<std::string,boost::shared_ptr<PluginInfo> >::const_iterator itr;
for (itr = plugins_.begin(); itr != plugins_.end(); ++itr) for (itr = plugins_.begin(); itr != plugins_.end(); ++itr)
{ {
names.push_back(itr->first); names.push_back(itr->first);
} }
return names; return names;
} }
@ -145,6 +164,7 @@ void datasource_cache::register_datasources(std::string const& str)
#ifdef MAPNIK_THREADSAFE #ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
#endif #endif
boost::filesystem::path path(str); boost::filesystem::path path(str);
// TODO - only push unique paths // TODO - only push unique paths
plugin_directories_.push_back(str); plugin_directories_.push_back(str);

View file

@ -52,6 +52,7 @@ if config_env['HAS_CAIRO']:
dep_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('#')])
ldflags += config_env['LIBMAPNIK_LINKFLAGS']
dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']]) dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])