scons: add a SYSTEM_FONTS variable to avoid installation of bundled dejavu fonts and instead point Python bindings at given value - also print SCONS_LOCAL_CONFIG values for user during configure
This commit is contained in:
parent
83c0a7883b
commit
42be8116e1
2 changed files with 44 additions and 24 deletions
47
SConstruct
47
SConstruct
|
@ -88,6 +88,12 @@ else:
|
||||||
|
|
||||||
SCONS_LOCAL_CONFIG = 'config.py'
|
SCONS_LOCAL_CONFIG = 'config.py'
|
||||||
|
|
||||||
|
# Warn user of current set of build options.
|
||||||
|
if os.path.exists(SCONS_LOCAL_CONFIG):
|
||||||
|
optfile = file(SCONS_LOCAL_CONFIG)
|
||||||
|
print "Saved options:", optfile.read().replace("\n", ", ")[:-2]
|
||||||
|
optfile.close()
|
||||||
|
|
||||||
# Core plugin build configuration
|
# Core plugin build configuration
|
||||||
# opts.Add still hardcoded however...
|
# opts.Add still hardcoded however...
|
||||||
PLUGINS = { # plugins with external dependencies
|
PLUGINS = { # plugins with external dependencies
|
||||||
|
@ -118,19 +124,19 @@ opts.Add('CXX', 'The C++ compiler to use (defaults to g++).', 'g++')
|
||||||
opts.Add(EnumVariable('OPTIMIZATION','Set g++ optimization level','2', ['0','1','2','3']))
|
opts.Add(EnumVariable('OPTIMIZATION','Set g++ optimization level','2', ['0','1','2','3']))
|
||||||
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
|
# Note: setting DEBUG=True will override any custom OPTIMIZATION level
|
||||||
opts.Add(BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'))
|
opts.Add(BoolVariable('DEBUG', 'Compile a debug version of Mapnik', 'False'))
|
||||||
|
opts.Add(ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()))
|
||||||
|
|
||||||
|
# SCons build behavior options
|
||||||
|
opts.Add('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG)
|
||||||
|
opts.Add(BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'))
|
||||||
|
opts.Add(BoolVariable('SCONS_CACHE', 'Use SCons dependency caching to speed build process', 'False'))
|
||||||
|
opts.Add(BoolVariable('USE_USER_ENV', 'Allow the SCons build environment to inherit from the current user environment', 'True'))
|
||||||
|
|
||||||
# Install Variables
|
# Install Variables
|
||||||
opts.Add('PREFIX', 'The install path "prefix"', '/usr/local')
|
opts.Add('PREFIX', 'The install path "prefix"', '/usr/local')
|
||||||
opts.Add('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)','')
|
opts.Add('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)','')
|
||||||
opts.Add('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/')
|
opts.Add('DESTDIR', 'The root directory to install into. Useful mainly for binary package building', '/')
|
||||||
|
|
||||||
|
|
||||||
# SCons build behavior options
|
|
||||||
opts.Add('CONFIG', "The file and path of a SCons user '%s' file" % SCONS_LOCAL_CONFIG, SCONS_LOCAL_CONFIG)
|
|
||||||
opts.Add(BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'))
|
|
||||||
opts.Add(BoolVariable('SCONS_CACHE', 'Use SCons dependency caching to speed build process', 'False'))
|
|
||||||
opts.Add(BoolVariable('USE_USER_ENV', 'Allow the SCons build env to inherit from the current user environment', 'True'))
|
|
||||||
|
|
||||||
# Boost variables
|
# Boost variables
|
||||||
opts.Add(PathVariable('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include', PathVariable.PathAccept))
|
opts.Add(PathVariable('BOOST_INCLUDES', 'Search path for boost include files', '/usr/include', PathVariable.PathAccept))
|
||||||
opts.Add(PathVariable('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
opts.Add(PathVariable('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
||||||
|
@ -159,7 +165,6 @@ opts.Add(BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'))
|
||||||
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
|
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
|
||||||
# Therefore, we use a single boolean for whether to attempt to build cairo support.
|
# Therefore, we use a single boolean for whether to attempt to build cairo support.
|
||||||
opts.Add(BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'))
|
opts.Add(BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'))
|
||||||
opts.Add(ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()))
|
|
||||||
opts.Add(PathVariable('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include/postgresql', PathVariable.PathAccept))
|
opts.Add(PathVariable('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include/postgresql', PathVariable.PathAccept))
|
||||||
opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
||||||
opts.Add(PathVariable('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include', PathVariable.PathAccept))
|
opts.Add(PathVariable('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include', PathVariable.PathAccept))
|
||||||
|
@ -172,6 +177,7 @@ opts.Add(PathVariable('SQLITE_INCLUDES', 'Search path for SQLITE include files',
|
||||||
opts.Add(PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
opts.Add(PathVariable('SQLITE_LIBS', 'Search path for SQLITE library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept))
|
||||||
|
|
||||||
# Other variables
|
# Other variables
|
||||||
|
opts.Add('SYSTEM_FONTS','Provide location for python bindings to register fonts (if given aborts installation of bundled DejaVu fonts)','')
|
||||||
opts.Add(PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable))
|
opts.Add(PathVariable('PYTHON','Full path to Python executable used to build bindings', sys.executable))
|
||||||
opts.Add(ListVariable('BINDINGS','Language bindings to build','all',['python']))
|
opts.Add(ListVariable('BINDINGS','Language bindings to build','all',['python']))
|
||||||
opts.Add(EnumVariable('THREADING','Set threading support','multi', ['multi','single']))
|
opts.Add(EnumVariable('THREADING','Set threading support','multi', ['multi','single']))
|
||||||
|
@ -227,6 +233,7 @@ if env['USE_CONFIG']:
|
||||||
else:
|
else:
|
||||||
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
|
color_print(4,'SCons USE_CONFIG specified as false, will not inherit variables python config file...')
|
||||||
|
|
||||||
|
|
||||||
env['MISSING_DEPS'] = []
|
env['MISSING_DEPS'] = []
|
||||||
env['SKIPPED_DEPS'] = []
|
env['SKIPPED_DEPS'] = []
|
||||||
|
|
||||||
|
@ -245,6 +252,9 @@ if env['SCONS_CACHE']:
|
||||||
# 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...
|
||||||
SetOption('implicit_cache', 1)
|
SetOption('implicit_cache', 1)
|
||||||
|
# uncomment for more speed improvements
|
||||||
|
#env.Decider('MD5-timestamp')
|
||||||
|
#SetOption('max_drift', 1)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite'
|
# Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite'
|
||||||
|
@ -380,17 +390,6 @@ else:
|
||||||
for required in ('BOOST', 'PNG', 'JPEG', 'TIFF','PROJ'):
|
for required in ('BOOST', 'PNG', 'JPEG', 'TIFF','PROJ'):
|
||||||
add_paths(required)
|
add_paths(required)
|
||||||
|
|
||||||
|
|
||||||
# fetch the mapnik version header in order to set the
|
|
||||||
# ABI version used to build libmapnik.so on linux in src/SConscript
|
|
||||||
abi = conf.GetMapnikLibVersion()
|
|
||||||
abi_fallback = [0,6,0]
|
|
||||||
if not abi:
|
|
||||||
color_print(1,'Problem encountered parsing mapnik version (please post bug report to trac.mapnik.org), falling back to %s' % abi_fallback)
|
|
||||||
env['ABI_VERSION'] = abi_fallback
|
|
||||||
else:
|
|
||||||
env['ABI_VERSION'] = abi
|
|
||||||
|
|
||||||
requested_plugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
|
requested_plugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
|
||||||
|
|
||||||
# Adding the required prerequisite library directories for the plugins...
|
# Adding the required prerequisite library directories for the plugins...
|
||||||
|
@ -557,6 +556,16 @@ if 'python' in env['BINDINGS']:
|
||||||
color_print(1,'Could not find required header files for boost python')
|
color_print(1,'Could not find required header files for boost python')
|
||||||
env['MISSING_DEPS'].append('boost python')
|
env['MISSING_DEPS'].append('boost python')
|
||||||
|
|
||||||
|
# fetch the mapnik version header in order to set the
|
||||||
|
# ABI version used to build libmapnik.so on linux in src/SConscript
|
||||||
|
abi = conf.GetMapnikLibVersion()
|
||||||
|
abi_fallback = [0,6,0]
|
||||||
|
if not abi:
|
||||||
|
color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback)
|
||||||
|
env['ABI_VERSION'] = abi_fallback
|
||||||
|
else:
|
||||||
|
env['ABI_VERSION'] = abi
|
||||||
|
|
||||||
#### End Config Stage ####
|
#### End Config Stage ####
|
||||||
|
|
||||||
if env['MISSING_DEPS']:
|
if env['MISSING_DEPS']:
|
||||||
|
|
|
@ -26,6 +26,9 @@ import os
|
||||||
Import('env')
|
Import('env')
|
||||||
Import('conf')
|
Import('conf')
|
||||||
|
|
||||||
|
prefix = env['PREFIX']
|
||||||
|
install_prefix = env['DESTDIR'] + '/' + prefix
|
||||||
|
|
||||||
if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
|
if env['CAIRO'] and conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'):
|
||||||
env.ParseConfig('pkg-config --cflags pycairo')
|
env.ParseConfig('pkg-config --cflags pycairo')
|
||||||
env.Append(CXXFLAGS = '-DHAVE_PYCAIRO');
|
env.Append(CXXFLAGS = '-DHAVE_PYCAIRO');
|
||||||
|
@ -48,15 +51,23 @@ headers = [env['PYTHON_INCLUDES']] + env['CPPPATH']
|
||||||
|
|
||||||
paths = """
|
paths = """
|
||||||
mapniklibpath = '%s'
|
mapniklibpath = '%s'
|
||||||
inputpluginspath = mapniklibpath + '/input'
|
|
||||||
fontscollectionpath = mapniklibpath + '/fonts'
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
paths += "inputpluginspath = mapniklibpath + '/input'\n"
|
||||||
|
|
||||||
|
if env['SYSTEM_FONTS']:
|
||||||
|
paths += "fontscollectionpath = '%s'" % env['SYSTEM_FONTS']
|
||||||
|
else:
|
||||||
|
paths += "fontscollectionpath = mapniklibpath + '/fonts'"
|
||||||
|
|
||||||
|
|
||||||
# write out the location of the 'mapniklibpath' into a python file
|
# write out the location of the 'mapniklibpath' into a python file
|
||||||
# so that the python module can located it at runtime
|
# so that the python module can locate it at runtime
|
||||||
exp = r"%s{2,}" % os.sep
|
exp = r"%s{2,}" % os.sep
|
||||||
mapnik_plugins_dir = re.sub(exp,os.sep, env['PREFIX'] + '/'+env['LIBDIR_SCHEMA']+'/mapnik')
|
# Note: we use prefix here not install_prefix since install_prefix is for package building
|
||||||
file('mapnik/paths.py','w').write(paths % (mapnik_plugins_dir,))
|
# and we intend for python to look to the standard prefix location to find the fonts and plugins
|
||||||
|
mapnik_lib_path = re.sub(exp,os.sep, prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik')
|
||||||
|
file('mapnik/paths.py','w').write(paths % (mapnik_lib_path))
|
||||||
|
|
||||||
# install the core mapnik python files, including '__init__.py' and 'paths.py'
|
# install the core mapnik python files, including '__init__.py' and 'paths.py'
|
||||||
init_files = glob.glob('mapnik/*.py')
|
init_files = glob.glob('mapnik/*.py')
|
||||||
|
|
Loading…
Reference in a new issue