add ability to uninstall all tracked scons targets using an 'uninstall' argument like 'scons uninstall' - closes #311

This commit is contained in:
Dane Springmeyer 2010-07-18 20:39:05 +00:00
parent 200e9096e9
commit 267b48de49
17 changed files with 130 additions and 47 deletions

View file

@ -61,6 +61,24 @@ def call(cmd, silent=False):
elif not silent: elif not silent:
color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr) color_print(1,'Problem encounted with SCons scripts, please post bug report to: http://trac.mapnik.org\nError was: %s' % stderr)
# http://www.scons.org/wiki/InstallTargets
def create_uninstall_target(env, path, is_glob=False):
if is_glob:
all_files = Glob(path,strings=True)
for filei in all_files:
env.Command( "uninstall-"+filei, filei,
[
Delete("$SOURCE"),
])
env.Alias("uninstall", "uninstall-"+filei)
else:
if os.path.exists(path):
env.Command( "uninstall-"+path, path,
[
Delete("$SOURCE"),
])
env.Alias("uninstall", "uninstall-"+path)
def shortest_name(libs): def shortest_name(libs):
name = '-'*200 name = '-'*200
for lib in libs: for lib in libs:
@ -1155,9 +1173,17 @@ Help(opts.GenerateHelpText(env))
#### Builds #### #### Builds ####
if not HELP_REQUESTED: if not HELP_REQUESTED:
if 'uninstall' in COMMAND_LINE_TARGETS:
# dummy action in case there is nothing to uninstall, to avoid phony error..
env.Alias("uninstall", "")
env['create_uninstall_target'] = create_uninstall_target
# export env so it is available in Sconscript files # export env so it is available in Sconscript files
Export('env') Export('env')
# clear the '_CPPDEFFLAGS' variable # clear the '_CPPDEFFLAGS' variable
# for unknown reasons this variable puts -DNone # for unknown reasons this variable puts -DNone
# in the g++ args prompting unnecessary recompiles # in the g++ args prompting unnecessary recompiles
@ -1205,6 +1231,13 @@ if not HELP_REQUESTED:
# build internal shape and raster plugins # build internal shape and raster plugins
SConscript('plugins/input/%s/SConscript' % plugin) SConscript('plugins/input/%s/SConscript' % plugin)
# todo - generalize this path construction, also used in plugin SConscript...
plugin_dir = os.path.normpath(env['DESTDIR'] + '/' + env['PREFIX'] + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'])
create_uninstall_target(env, plugin_dir + '/input' , False)
create_uninstall_target(env, plugin_dir + '/fonts' , False)
create_uninstall_target(env, plugin_dir, False)
# Build the c++ rundemo app if requested # Build the c++ rundemo app if requested
if env['DEMO']: if env['DEMO']:
SConscript('demo/c++/SConscript') SConscript('demo/c++/SConscript')

View file

@ -26,7 +26,7 @@ import os
Import('env') Import('env')
prefix = env['PREFIX'] prefix = env['PREFIX']
install_prefix = env['DESTDIR'] + '/' + prefix target_path = env['PYTHON_INSTALL_LOCATION'] + '/mapnik2'
linkflags = '' linkflags = ''
libraries = ['mapnik2','png','jpeg'] libraries = ['mapnik2','png','jpeg']
@ -130,12 +130,12 @@ except: pass
# 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')
init_module = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik2', init_files) init_module = env.Install(target_path, init_files)
env.Alias(target='install', source=init_module) env.Alias(target='install', source=init_module)
# install the ogcserver module code # install the ogcserver module code
ogcserver_files = glob.glob('mapnik/ogcserver/*.py') ogcserver_files = glob.glob('mapnik/ogcserver/*.py')
ogcserver_module = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik2/ogcserver', ogcserver_files) ogcserver_module = env.Install(target_path + '/ogcserver', ogcserver_files)
env.Alias(target='install', source=ogcserver_module) env.Alias(target='install', source=ogcserver_module)
@ -177,5 +177,8 @@ if env['HAS_CAIRO'] or env['HAS_PYCAIRO']:
_mapnik = py_env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags) _mapnik = py_env.LoadableModule('mapnik/_mapnik2', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
pymapniklib = env.Install(env['PYTHON_INSTALL_LOCATION'] + '/mapnik2',_mapnik) if 'uninstall' not in COMMAND_LINE_TARGETS:
pymapniklib = env.Install(target_path,_mapnik)
py_env.Alias(target='install',source=pymapniklib) py_env.Alias(target='install',source=pymapniklib)
env['create_uninstall_target'](env, target_path)

View file

@ -38,5 +38,6 @@ if env['PLATFORM'] == 'Darwin':
gdal_inputdriver = env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) gdal_inputdriver = env.SharedLibrary('../gdal', source=gdal_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', gdal_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', gdal_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -39,5 +39,6 @@ if env['PLATFORM'] == 'Darwin':
kismet_inputdriver = env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) kismet_inputdriver = env.SharedLibrary('../kismet', source=kismet_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', kismet_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', kismet_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -41,5 +41,6 @@ if env['PLATFORM'] == 'Darwin':
occi_inputdriver = env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) occi_inputdriver = env.SharedLibrary('../occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', occi_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', occi_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -45,5 +45,6 @@ if env['PLATFORM'] == 'Darwin':
ogr_inputdriver = env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) ogr_inputdriver = env.SharedLibrary('../ogr', source=ogr_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', ogr_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', ogr_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -43,5 +43,6 @@ if env['PLATFORM'] == 'Darwin':
osm_inputdriver = env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) osm_inputdriver = env.SharedLibrary('../osm', source=osm_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', osm_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', osm_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -41,5 +41,6 @@ if env['PLATFORM'] == 'Darwin':
postgis_inputdriver = env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) postgis_inputdriver = env.SharedLibrary('../postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', postgis_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', postgis_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -41,5 +41,6 @@ if env['PLATFORM'] == 'Darwin':
raster_inputdriver = env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) raster_inputdriver = env.SharedLibrary('../raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', raster_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', raster_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -38,5 +38,6 @@ if env['PLATFORM'] == 'Darwin':
rasterlite_inputdriver = env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) rasterlite_inputdriver = env.SharedLibrary('../rasterlite', source=rasterlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', rasterlite_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', rasterlite_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -50,5 +50,6 @@ if env['SHAPE_MEMORY_MAPPED_FILE']:
shape_inputdriver = env2.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries) shape_inputdriver = env2.SharedLibrary('../shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', shape_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', shape_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -69,6 +69,11 @@ shape_datasource::shape_datasource(const parameters &params)
throw datasource_exception("shapefile '" + shape_name_ + ".shp' does not exist"); throw datasource_exception("shapefile '" + shape_name_ + ".shp' does not exist");
} }
if (boost::filesystem::is_directory(shape_name_ + ".shp"))
{
throw datasource_exception("shapefile '" + shape_name_ + ".shp' appears to be a directory not a file");
}
try try
{ {
shape_io shape(shape_name_); shape_io shape(shape_name_);

View file

@ -40,5 +40,6 @@ if env['PLATFORM'] == 'Darwin':
sqlite_inputdriver = env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries) sqlite_inputdriver = env.SharedLibrary('../sqlite', source=sqlite_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', sqlite_inputdriver) env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input', sqlite_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input') env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + env['LIB_DIR_NAME'] + '/input')

View file

@ -60,16 +60,23 @@ else:
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
if env['FULL_LIB_PATH']: mapnik_libname = 'libmapnik2.dylib'
lib_path = '%s/libmapnik2.dylib' % lib_dir elif env['PLATFORM'] == 'SunOS' and env['CXX'].startswith('CC'):
mapnik_libname = 'libmapnik2.so'
else: else:
lib_path = 'libmapnik2.dylib' mapnik_libname = 'libmapnik2.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1]))
if env['PLATFORM'] == 'Darwin':
if env['FULL_LIB_PATH']:
lib_path = '%s/%s' % (lib_dir,mapnik_libname)
else:
lib_path = mapnik_libname
linkflags = '-Wl,-install_name,%s' % lib_path linkflags = '-Wl,-install_name,%s' % lib_path
linkflags += ' -current_version 0.8.0 -compatibility_version 0.8.0' linkflags += ' -current_version 0.8.0 -compatibility_version 0.8.0'
elif env['PLATFORM'] == 'SunOS' and env['CXX'].startswith('CC'): elif env['PLATFORM'] == 'SunOS' and env['CXX'].startswith('CC'):
linkflags = '-R. -h libmapnik.so' linkflags = '-R. -h %s' % mapnik_libname
else: # Linux and others else: # Linux and others
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik2.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1])) linkflags = '-Wl,-rpath-link,. -Wl,-soname,%s' % mapnik_libname
source = Split( source = Split(
""" """
@ -179,6 +186,7 @@ elif env['XMLPARSER'] == 'libxml2' and env['HAS_LIBXML2']:
source.insert(0,env2.SharedObject(cpp)) source.insert(0,env2.SharedObject(cpp))
mapnik = env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags) mapnik = env.SharedLibrary('mapnik2', source, LIBS=libraries, LINKFLAGS=linkflags)
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
def symlink(env, target, source): def symlink(env, target, source):
@ -193,17 +201,35 @@ if env['PLATFORM'] != 'Darwin':
soFile = "%s.%d.%d.%d" % (os.path.basename(str(mapnik[0])), major, minor, micro) soFile = "%s.%d.%d.%d" % (os.path.basename(str(mapnik[0])), major, minor, micro)
libDir = install_prefix + '/' + env['LIBDIR_SCHEMA'] libDir = install_prefix + '/' + env['LIBDIR_SCHEMA']
env.Alias(target='install', source=env.InstallAs(target=os.path.join(libDir, soFile), source=mapnik)) target = os.path.join(libDir, soFile)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Alias(target='install', source=env.InstallAs(target=target, source=mapnik))
# Install symlinks # Install symlinks
link1 = env.Command(os.path.join(libDir, "%s.%d.%d" % (os.path.basename(str(mapnik[0])),major, minor)), target1 = os.path.join(libDir, "%s.%d.%d" % (os.path.basename(str(mapnik[0])),major, minor))
os.path.join(libDir, soFile), symlink) target2 = os.path.join(libDir, os.path.basename(str(mapnik[0])))
if 'uninstall' not in COMMAND_LINE_TARGETS:
if 'install' in COMMAND_LINE_TARGETS:
link1 = env.Command(target1, target, symlink)
env.Alias(target='install', source=link1) env.Alias(target='install', source=link1)
link2 = env.Command(os.path.join(libDir, os.path.basename(str(mapnik[0]))), if 'install' in COMMAND_LINE_TARGETS:
os.path.join(libDir, "%s.%d.%d" % (os.path.basename(str(mapnik[0])),major, minor)), symlink) link2 = env.Command(target2, target1, symlink)
env.Alias(target='install', source=link2) env.Alias(target='install', source=link2)
# delete in reverse order..
env['create_uninstall_target'](env, target2)
env['create_uninstall_target'](env, target1)
env['create_uninstall_target'](env, target)
else: else:
env.Alias(target='install', source=env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'], mapnik)) target_path = os.path.normpath(install_prefix + '/' + env['LIBDIR_SCHEMA'])
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Alias(target='install', source=env.Install(target_path, mapnik))
env['create_uninstall_target'](env, os.path.join(target_path,mapnik_libname))
includes = glob.glob('../include/mapnik/*.hpp') includes = glob.glob('../include/mapnik/*.hpp')
env.Alias(target='install', source=env.Install(install_prefix+'/include/mapnik', includes)) inc_target = os.path.normpath(install_prefix+'/include/mapnik')
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Alias(target='install', source=env.Install(inc_target, includes))
env['create_uninstall_target'](env, inc_target)

View file

@ -50,5 +50,6 @@ if env['PLATFORM'] == 'Darwin':
ogrindex = env.Program('ogrindex', source, CPPPATH=headers, LIBS=libraries) ogrindex = env.Program('ogrindex', source, CPPPATH=headers, LIBS=libraries)
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/bin', ogrindex) env.Install(install_prefix + '/bin', ogrindex)
env.Alias('install', install_prefix + '/bin') env.Alias('install', install_prefix + '/bin')

View file

@ -41,7 +41,9 @@ libraries = [boost_program_options,boost_thread,'sqlite3','pq','mapnik2']
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
libraries.append(env['ICU_LIB_NAME']) libraries.append(env['ICU_LIB_NAME'])
if 'uninstall' not in COMMAND_LINE_TARGETS:
pgsql2sqlite = env.Program('pgsql2sqlite', source, CPPPATH=headers, LIBS=libraries) pgsql2sqlite = env.Program('pgsql2sqlite', source, CPPPATH=headers, LIBS=libraries)
env.Install(install_prefix + '/bin', pgsql2sqlite) env.Install(install_prefix + '/bin', pgsql2sqlite)
env.Alias('install', install_prefix + '/bin') env.Alias('install', install_prefix + '/bin')
env['create_uninstall_target'](env, install_prefix + '/bin/' + 'pgsql2sqlite')

View file

@ -24,5 +24,8 @@ Import ('env')
prefix = env['PREFIX'] prefix = env['PREFIX']
install_prefix = env['DESTDIR'] + '/' + prefix install_prefix = env['DESTDIR'] + '/' + prefix
if 'uninstall' not in COMMAND_LINE_TARGETS:
env.Install(install_prefix + '/bin', "upgrade_map_xml.py") env.Install(install_prefix + '/bin', "upgrade_map_xml.py")
env.Alias('install', install_prefix + '/bin') env.Alias('install', install_prefix + '/bin')
env['create_uninstall_target'](env, install_prefix + '/bin/' + 'upgrade_map_xml.py')