scons: better propagation of libmapnik build flags to command line utilities and mapnik-config - also remove conditional flags on specific cairo rendering .cpp files as this was not working right - closes #837

This commit is contained in:
Dane Springmeyer 2011-08-29 21:12:22 +00:00
parent 22f6c9f01a
commit 6cb31bd109
7 changed files with 57 additions and 74 deletions

View file

@ -32,13 +32,16 @@ source = Split(
demo_env = env.Clone() demo_env = env.Clone()
headers = env['CPPPATH'] demo_env['CXXFLAGS'] = copy(env['LIBMAPNIK_CXXFLAGS'])
demo_env.PrependUnique(CPPPATH=copy(env['CAIROMM_CPPPATHS']))
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']
libraries.extend([boost_program_options,'mapnik2']) libraries.extend([boost_program_options,'mapnik2'])
rundemo = demo_env.Program('rundemo', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"]) rundemo = demo_env.Program('rundemo', source, LIBS=libraries, LINKFLAGS=env["CUSTOM_LDFLAGS"])
Depends(rundemo, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
# we don't install this app because the datasource paths are relative # we don't install this app because the datasource paths are relative
# and we're not going to install the sample data. # and we're not going to install the sample data.

View file

@ -43,7 +43,7 @@ int main ( int argc , char** argv)
{ {
if (argc != 2) if (argc != 2)
{ {
std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik\n"; std::cout << "usage: ./rundemo <mapnik_install_dir>\nUsually /usr/local/lib/mapnik2\n";
std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n"; std::cout << "Warning: ./rundemo looks for data in ../data/,\nTherefore must be run from within the demo/c++ folder.\n";
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }

View file

@ -40,11 +40,11 @@ def call(cmd, silent=True):
def ldconfig(*args,**kwargs): def ldconfig(*args,**kwargs):
call('ldconfig') call('ldconfig')
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
lib_env.Append(CXXFLAGS="-fPIC") lib_env.Append(CXXFLAGS="-fPIC")
mapnik_lib_link_flag = '' mapnik_lib_link_flag = ''
libmapnik_cxxflags = copy(lib_env['CXXFLAGS'])
ABI_VERSION = env['ABI_VERSION'] ABI_VERSION = env['ABI_VERSION']
@ -54,10 +54,8 @@ regex = 'boost_regex%s' % env['BOOST_APPEND']
# clear out and re-set libs for this env # clear out and re-set libs for this env
lib_env['LIBS'] = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex] lib_env['LIBS'] = ['freetype','ltdl','png','tiff','z','jpeg','proj',env['ICU_LIB_NAME'],filesystem,regex]
if env['HAS_CAIRO']: if len(env['EXTRA_FREETYPE_LIBS']):
# add cairo and cairomm-1.0 to libs lib_env['LIBS'].extend(copy(env['EXTRA_FREETYPE_LIBS']))
lib_env['LIBS'].append('cairomm-1.0')
lib_env['LIBS'].append('cairo')
if env['XMLPARSER'] == 'libxml2': if env['XMLPARSER'] == 'libxml2':
lib_env['LIBS'].append('xml2') lib_env['LIBS'].append('xml2')
@ -156,6 +154,7 @@ source = Split(
if env['LIBTOOL_SUPPORTS_ADVISE']: if env['LIBTOOL_SUPPORTS_ADVISE']:
env3 = lib_env.Clone() env3 = lib_env.Clone()
env3.Append(CXXFLAGS='-DLIBTOOL_SUPPORTS_ADVISE') env3.Append(CXXFLAGS='-DLIBTOOL_SUPPORTS_ADVISE')
libmapnik_cxxflags.append('-DLIBTOOL_SUPPORTS_ADVISE')
cpp = 'datasource_cache.cpp' cpp = 'datasource_cache.cpp'
if env['LINKING'] == 'static': if env['LINKING'] == 'static':
source.insert(0,env3.StaticObject(cpp)) source.insert(0,env3.StaticObject(cpp))
@ -190,7 +189,6 @@ source += Split(
if env['RUNTIME_LINK'] == "static": if env['RUNTIME_LINK'] == "static":
source += glob.glob('../agg/src/' + '*.cpp') source += glob.glob('../agg/src/' + '*.cpp')
#source.append(File('../agg/libagg.a'))
# grid backend # grid backend
source += Split( source += Split(
@ -229,29 +227,28 @@ if env['SVG_RENDERER']: # svg backend
svg/process_text_symbolizer.cpp svg/process_text_symbolizer.cpp
""") """)
lib_env.Append(CXXFLAGS = '-DSVG_RENDERER') lib_env.Append(CXXFLAGS = '-DSVG_RENDERER')
libmapnik_cxxflags.append('-DSVG_RENDERER')
if env['HAS_CAIRO']: if env['HAS_CAIRO']:
# attach libs to library linking environment lib_env.PrependUnique(LIBPATH=env['CAIROMM_LIBPATHS'])
try: lib_env.Append(LIBS=env['CAIROMM_LINKFLAGS'])
cmd = 'pkg-config --libs cairomm-1.0' lib_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
if lib_env['RUNTIME_LINK'] == 'static': libmapnik_cxxflags.append('-DHAVE_CAIRO')
cmd += ' --static' lib_env.PrependUnique(CPPPATH=copy(env['CAIROMM_CPPPATHS']))
lib_env.ParseConfig(cmd) source.insert(0,'cairo_renderer.cpp')
env2 = lib_env.Clone() #cairo_env.PrependUnique(CPPPATH=env['CAIROMM_CPPPATHS'])
env2.Append(CXXFLAGS = '-DHAVE_CAIRO') # not safe, to much depends on graphics.hpp
# attach cflags to specific compile environment #cairo_env = lib_env.Clone()
env2.ParseConfig('pkg-config --cflags cairomm-1.0') #cairo_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
fixup = ['cairo_renderer.cpp','graphics.cpp','image_util.cpp'] #fixup = ['feature_type_style.cpp','load_map.cpp','cairo_renderer.cpp','graphics.cpp','image_util.cpp']
for cpp in fixup: #for cpp in fixup:
if cpp in source: # if cpp in source:
source.remove(cpp) # source.remove(cpp)
if env['LINKING'] == 'static': # if env['LINKING'] == 'static':
source.insert(0,env2.StaticObject(cpp)) # source.insert(0,cairo_env.StaticObject(cpp))
else: # else:
source.insert(0,env2.SharedObject(cpp)) # source.insert(0,cairo_env.SharedObject(cpp))
except OSError, e:
print '\nFailed to detect cairo/cairomm configuration, please re-run "python scons/scons.py configure"'
sys.exit(1)
if env['XMLPARSER'] == 'tinyxml': if env['XMLPARSER'] == 'tinyxml':
source += Split( source += Split(
@ -268,6 +265,7 @@ elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
""") """)
env2 = lib_env.Clone() env2 = lib_env.Clone()
env2.Append(CXXFLAGS = '-DHAVE_LIBXML2') env2.Append(CXXFLAGS = '-DHAVE_LIBXML2')
libmapnik_cxxflags.append('-DHAVE_LIBXML2')
fixup = ['load_map.cpp','libxml2_loader.cpp'] fixup = ['load_map.cpp','libxml2_loader.cpp']
for cpp in fixup: for cpp in fixup:
if cpp in source: if cpp in source:
@ -287,8 +285,9 @@ if env['LINKING'] == 'static':
else: else:
mapnik = lib_env.SharedLibrary('mapnik2', source, LINKFLAGS=linkflags) mapnik = lib_env.SharedLibrary('mapnik2', source, LINKFLAGS=linkflags)
# cache libraries value 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
if env['PLATFORM'] != 'Darwin': if env['PLATFORM'] != 'Darwin':
# Symlink command, only works if both files are in same directory # Symlink command, only works if both files are in same directory

View file

@ -2,6 +2,7 @@
import re import re
import os import os
import sys import sys
from copy import copy
Import('env') Import('env')
@ -51,31 +52,10 @@ def write_config(configuration,template,config_file):
except: pass except: pass
# recreate a few dynamic path additions
if config_env['HAS_CAIRO']:
# attach libs to library linking environment
try:
config_env.ParseConfig('pkg-config --libs cairomm-1.0')
config_env.Append(CXXFLAGS = '-DHAVE_CAIRO')
config_env.ParseConfig('pkg-config --cflags cairomm-1.0')
except OSError, e:
print '\nFailed to detect cairo/cairomm configuration, please re-run "python scons/scons.py configure"'
sys.exit(1)
# todo - refine this list # todo - refine this list
# todo - custom_cxxflags are being duplicated somewhere
cpp_paths = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')]) cpp_paths = ''.join([' -I%s' % i for i in config_env['CPPPATH'] if not i.startswith('#')])
other_includes = config_env['CUSTOM_CXXFLAGS'] + config_env['CXXFLAGS'] + cpp_paths
if config_env['XMLPARSER'] == 'libxml2' and config_env['HAS_LIBXML2']: other_includes = config_env['LIBMAPNIK_CXXFLAGS'] + cpp_paths
other_includes.append('-DHAVE_LIBXML2')
if config_env['SVG_RENDERER']:
other_includes.append('-DSVG_RENDERER')
if config_env['LIBTOOL_SUPPORTS_ADVISE']:
other_includes.append('-DLIBTOOL_SUPPORTS_ADVISE')
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('#')])
@ -83,7 +63,6 @@ dep_libs = ''.join([' -l%s' % i for i in env['LIBMAPNIK_LIBS']])
if env['INTERNAL_LIBAGG']: if env['INTERNAL_LIBAGG']:
dep_libs = dep_libs.replace('-lagg','') dep_libs = dep_libs.replace('-lagg','')
configuration = { configuration = {
"prefix": config_env['PREFIX'], "prefix": config_env['PREFIX'],
@ -106,11 +85,13 @@ write_config(configuration,template,config_file)
target_path = os.path.normpath(os.path.join(config_env['INSTALL_PREFIX'],'bin')) target_path = os.path.normpath(os.path.join(config_env['INSTALL_PREFIX'],'bin'))
full_target = os.path.join(target_path,config_file) full_target = os.path.join(target_path,config_file)
Depends(full_target, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'install' in COMMAND_LINE_TARGETS: if 'install' in COMMAND_LINE_TARGETS:
# we must add 'install' catch here because otherwise # we must add 'install' catch here because otherwise
# custom command will be run when not installing # custom command will be run when not installing
env.Alias('install',full_target) env.Alias('install',full_target)
#Depends(t, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
env.Command(full_target, config_file, env.Command(full_target, config_file,
[ [
Copy("$TARGET","$SOURCE"), Copy("$TARGET","$SOURCE"),
@ -118,9 +99,3 @@ if 'install' in COMMAND_LINE_TARGETS:
]) ])
config_env['create_uninstall_target'](env,os.path.join(target_path,config_file)) config_env['create_uninstall_target'](env,os.path.join(target_path,config_file))

View file

@ -34,19 +34,22 @@ source = Split(
headers = ['#plugins/input/ogr'] + env['CPPPATH'] headers = ['#plugins/input/ogr'] + env['CPPPATH']
boost_program_options = 'boost_program_options%s' % env['BOOST_APPEND'] program_env['LIBS'] = [env['PLUGINS']['ogr']['lib']]
boost_filesystem = 'boost_filesystem%s' % env['BOOST_APPEND']
libraries = [boost_program_options,boost_filesystem,env['PLUGINS']['ogr']['lib'],'mapnik2']
boost_system = 'boost_system%s' % env['BOOST_APPEND'] # Link Library to Dependencies
program_env['LIBS'].append('mapnik2')
program_env['LIBS'].append(env['ICU_LIB_NAME'])
program_env['LIBS'].append('boost_system%s' % env['BOOST_APPEND'])
program_env['LIBS'].append('boost_filesystem%s' % env['BOOST_APPEND'])
program_env['LIBS'].append('boost_program_options%s' % env['BOOST_APPEND'])
if env['HAS_BOOST_SYSTEM']: if env['RUNTIME_LINK'] == 'static':
libraries.append(boost_system) cmd = 'gdal-config --dep-libs'
program_env.ParseConfig(cmd)
if env['PLATFORM'] == 'Darwin':
libraries.append(env['ICU_LIB_NAME'])
ogrindex = program_env.Program('ogrindex', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) ogrindex = program_env.Program('ogrindex', source, CPPPATH=headers, LINKFLAGS=env['CUSTOM_LDFLAGS'])
Depends(ogrindex, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), ogrindex) env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), ogrindex)

View file

@ -42,9 +42,10 @@ 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']
libraries.extend([boost_program_options,'sqlite3','pq','mapnik2']) libraries.extend([boost_program_options,'sqlite3','pq','mapnik2'])
pgsql2sqlite = program_env.Program('pgsql2sqlite', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
Depends(pgsql2sqlite, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
pgsql2sqlite = program_env.Program('pgsql2sqlite', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
Depends(pgsql2sqlite, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), pgsql2sqlite) env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), pgsql2sqlite)
env.Alias('install', os.path.join(env['INSTALL_PREFIX'],'bin')) env.Alias('install', os.path.join(env['INSTALL_PREFIX'],'bin'))

View file

@ -47,6 +47,8 @@ if env['HAS_BOOST_SYSTEM']:
shapeindex = program_env.Program('shapeindex', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS']) shapeindex = program_env.Program('shapeindex', source, CPPPATH=headers, LIBS=libraries, LINKFLAGS=env['CUSTOM_LDFLAGS'])
Depends(shapeindex, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))
if 'uninstall' not in COMMAND_LINE_TARGETS: if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), shapeindex) env.Install(os.path.join(env['INSTALL_PREFIX'],'bin'), shapeindex)
env.Alias('install', os.path.join(env['INSTALL_PREFIX'],'bin')) env.Alias('install', os.path.join(env['INSTALL_PREFIX'],'bin'))