2010-10-24 10:04:16 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
# Mapnik uses the build tool SCons.
|
|
|
|
|
|
|
|
# This python file is run to compile a plugin
|
|
|
|
# It must be called from the main 'SConstruct' file like:
|
|
|
|
|
|
|
|
# SConscript('path/to/this/file.py')
|
|
|
|
|
|
|
|
# see docs at: http://www.scons.org/wiki/SConscript()
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
# Here we pull from the SCons environment exported from the main instance
|
2011-11-12 02:03:21 +01:00
|
|
|
Import ('plugin_base')
|
2010-10-24 10:04:16 +02:00
|
|
|
Import ('env')
|
|
|
|
|
2013-05-16 20:33:23 +02:00
|
|
|
# Give this plugin a name
|
|
|
|
# here this happens to be the same as the directory
|
|
|
|
PLUGIN_NAME = 'hello'
|
|
|
|
|
2010-10-24 10:04:16 +02:00
|
|
|
# the below install details are also pulled from the
|
|
|
|
# main SConstruct file where configuration happens
|
|
|
|
|
|
|
|
# clone the environment here
|
|
|
|
# so that if we modify the env it in this file
|
|
|
|
# those changes to not pollute other builds later on...
|
2011-11-12 02:03:21 +01:00
|
|
|
plugin_env = plugin_base.Clone()
|
2010-10-24 10:04:16 +02:00
|
|
|
|
|
|
|
# Add the cpp files that need to be compiled
|
|
|
|
plugin_sources = Split(
|
2011-04-02 05:45:50 +02:00
|
|
|
"""
|
|
|
|
%(PLUGIN_NAME)s_datasource.cpp
|
2013-05-16 20:33:23 +02:00
|
|
|
%(PLUGIN_NAME)s_featureset.cpp
|
2011-04-02 05:45:50 +02:00
|
|
|
""" % locals()
|
2010-10-24 10:04:16 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# Add any external libraries this plugin should
|
|
|
|
# directly link to
|
|
|
|
libraries = [ '' ] # eg 'libfoo'
|
|
|
|
|
2012-02-10 01:00:39 +01:00
|
|
|
libraries.append('boost_system%s' % env['BOOST_APPEND'])
|
2011-08-12 23:31:28 +02:00
|
|
|
# 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
|
|
|
|
libraries.append(env['ICU_LIB_NAME'])
|
2013-05-16 20:33:23 +02:00
|
|
|
|
|
|
|
# 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
|
2014-06-09 22:55:56 +02:00
|
|
|
libraries.append(env['MAPNIK_NAME'])
|
2013-05-16 20:33:23 +02:00
|
|
|
|
|
|
|
TARGET = plugin_env.SharedLibrary(
|
|
|
|
# the name of the target to build, eg 'sqlite.input'
|
|
|
|
'../%s' % PLUGIN_NAME,
|
|
|
|
# prefix - normally none used
|
|
|
|
SHLIBPREFIX='',
|
|
|
|
# extension, mapnik expects '.input'
|
|
|
|
SHLIBSUFFIX='.input',
|
|
|
|
# list of source files to compile
|
|
|
|
source=plugin_sources,
|
|
|
|
# libraries to link to
|
2013-10-22 22:35:46 +02:00
|
|
|
LIBS=libraries
|
2013-05-16 20:33:23 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
# if the plugin links to libmapnik ensure it is built first
|
|
|
|
Depends(TARGET, env.subst('../../../../src/%s' % env['MAPNIK_LIB_NAME']))
|
|
|
|
|
|
|
|
# if 'uninstall' is not passed on the command line
|
|
|
|
# then we actually create the install targets that
|
|
|
|
# scons will install if 'install' is passed as an arg
|
|
|
|
if 'uninstall' not in COMMAND_LINE_TARGETS:
|
|
|
|
env.Install(install_dest, TARGET)
|
|
|
|
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')
|