From 0e5dcbd81035bf7a59de7f5b4cadc8058517472f Mon Sep 17 00:00:00 2001 From: kunitoki Date: Thu, 24 May 2012 00:02:43 +0200 Subject: [PATCH] - fixed unwanted behaviour with default log severity in SConstruct #937 --- SConstruct | 276 ++++++++++++++++++++++++++--------------------------- 1 file changed, 138 insertions(+), 138 deletions(-) diff --git a/SConstruct b/SConstruct index d7c15f752..0b793578a 100644 --- a/SConstruct +++ b/SConstruct @@ -81,7 +81,7 @@ pretty_dep_names = { 'sqlite_rtree':'The SQLite plugin requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)', 'pgsql2sqlite_rtree':'The pgsql2sqlite program requires libsqlite3 built with RTREE support (-DSQLITE_ENABLE_RTREE=1)' } - + # Core plugin build configuration # opts.AddVariables still hardcoded however... PLUGINS = { # plugins with external dependencies @@ -94,7 +94,7 @@ PLUGINS = { # plugins with external dependencies 'occi': {'default':False,'path':'OCCI','inc':'occi.h','lib':'ociei','lang':'C++'}, 'sqlite': {'default':True,'path':'SQLITE','inc':'sqlite3.h','lib':'sqlite3','lang':'C'}, 'rasterlite': {'default':False,'path':'RASTERLITE','inc':['sqlite3.h','rasterlite.h'],'lib':'rasterlite','lang':'C'}, - + # todo: osm plugin does also depend on libxml2 (but there is a separate check for that) 'osm': {'default':True,'path':None,'inc':'curl/curl.h','lib':'curl','lang':'C'}, @@ -156,7 +156,7 @@ def create_uninstall_target(env, path, is_glob=False): Delete("$SOURCE"), ]) env.Alias("uninstall", "uninstall-"+path) - + def shortest_name(libs): name = '-'*200 for lib in libs: @@ -168,20 +168,20 @@ def shortest_name(libs): def sort_paths(items,priority): """Sort paths such that compiling and linking will globally prefer custom or local libs over system libraries by fixing up the order libs are passed to gcc and the linker. - + Ideally preference could be by-target instead of global, but our SCons implementation is not currently utilizing different SCons build env()'s as we should. - + Overally the current approach within these scripts is to prepend paths of preference and append all others, but this does not give enough control (particularly due to the approach of assuming /usr/LIBSCHEMA and letting paths be parsed and added by pkg-config). - + In effect /usr/lib is likely to come before /usr/local/lib which makes linking against custom built icu or boost impossible when those libraries are available in both places. - + Sorting using a priority list allows this to be controlled, and fine tuned. """ - + new = [] path_types = {'internal':[],'other':[],'frameworks':[],'user':[],'system':[]} # parse types of paths into logical/meaningful groups @@ -235,7 +235,7 @@ def sort_paths(items,priority): if platform.dist()[0] in ('Ubuntu','debian'): LIBDIR_SCHEMA='lib' elif platform.uname()[4] == 'x86_64' and platform.system() == 'Linux': - LIBDIR_SCHEMA='lib64' + LIBDIR_SCHEMA='lib64' elif platform.uname()[4] == 'ppc64': LIBDIR_SCHEMA='lib64' else: @@ -274,7 +274,7 @@ opts.AddVariables( BoolVariable('DEBUG_UNDEFINED', 'Compile a version of Mapnik using clang/llvm undefined behavior asserts', 'False'), ListVariable('INPUT_PLUGINS','Input drivers to include',DEFAULT_PLUGINS,PLUGINS.keys()), ('WARNING_CXXFLAGS', 'Compiler flags you can set to reduce warning levels which are placed after -Wall.', ''), - + # SCons build behavior options ('CONFIG', "The path to the python file in which to save user configuration options. Currently : '%s'" % SCONS_LOCAL_CONFIG,SCONS_LOCAL_CONFIG), BoolVariable('USE_CONFIG', "Use SCons user '%s' file (will also write variables after successful configuration)", 'True'), @@ -282,8 +282,8 @@ opts.AddVariables( # http://stackoverflow.com/questions/1318863/how-to-optimize-an-scons-script BoolVariable('FAST', "Make SCons faster at the cost of less precise dependency tracking", 'False'), BoolVariable('PRIORITIZE_LINKING', 'Sort list of lib and inc directories to ensure preferential compiling and linking (useful when duplicate libs)', 'True'), - ('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)), - + ('LINK_PRIORITY','Priority list in which to sort library and include paths (default order is internal, other, frameworks, user, then system - see source of `sort_paths` function for more detail)',','.join(DEFAULT_LINK_PRIORITY)), + # Install Variables ('PREFIX', 'The install path "prefix"', '/usr/local'), ('PYTHON_PREFIX','Custom install path "prefix" for python bindings (default of no prefix)',''), @@ -291,7 +291,7 @@ opts.AddVariables( ('PATH', 'A custom path (or multiple paths divided by ":") to append to the $PATH env to prioritize usage of command line programs (if multiple are present on the system)', ''), ('PATH_REMOVE', 'A path prefix to exclude from all known command and compile paths', ''), ('PATH_REPLACE', 'Two path prefixes (divided with a :) to search/replace from all known command and compile paths', ''), - + # Boost variables # default is '/usr/include', see FindBoost method below ('BOOST_INCLUDES', 'Search path for boost include files', '',False), @@ -301,7 +301,7 @@ opts.AddVariables( ('BOOST_ABI', 'Specify boost ABI, e.g., d.','',False), ('BOOST_VERSION','Specify boost version, e.g., 1_35.','',False), ('BOOST_PYTHON_LIB','Specify library name to specific Boost Python lib (e.g. "boost_python-py26")',''), - + # Variables for required dependencies ('FREETYPE_CONFIG', 'The path to the freetype-config executable.', 'freetype-config'), ('XML2_CONFIG', 'The path to the xml2-config executable.', 'xml2-config'), @@ -310,7 +310,7 @@ opts.AddVariables( ('ICU_LIB_NAME', 'The library name for icu (such as icuuc, sicuuc, or icucore)', 'icuuc'), PathVariable('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include', PathVariable.PathAccept), PathVariable('PNG_LIBS','Search path for libpng include files','/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), - BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'), + BoolVariable('JPEG', 'Build Mapnik with JPEG read and write support', 'True'), PathVariable('JPEG_INCLUDES', 'Search path for libjpeg include files', '/usr/include', PathVariable.PathAccept), PathVariable('JPEG_LIBS', 'Search path for libjpeg library files', '/usr/' + LIBDIR_SCHEMA, PathVariable.PathAccept), PathVariable('TIFF_INCLUDES', 'Search path for libtiff include files', '/usr/include', PathVariable.PathAccept), @@ -318,15 +318,15 @@ opts.AddVariables( PathVariable('PROJ_INCLUDES', 'Search path for PROJ.4 include files', '/usr/local/include', PathVariable.PathAccept), PathVariable('PROJ_LIBS', 'Search path for PROJ.4 library files', '/usr/local/' + LIBDIR_SCHEMA, PathVariable.PathAccept), ('PKG_CONFIG_PATH', 'Use this path to point pkg-config to .pc files instead of the PKG_CONFIG_PATH environment setting',''), - + # Variables affecting rendering back-ends - + BoolVariable('RENDERING_STATS', 'Output rendering statistics during style processing', 'False'), BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'), BoolVariable('SVG_RENDERER', 'build support for native svg renderer', 'False'), - + # Variables for optional dependencies ('GEOS_CONFIG', 'The path to the geos-config executable.', 'geos-config'), # Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config @@ -447,7 +447,7 @@ HELP_REQUESTED = False if ('-h' in command_line_args) or ('--help' in command_line_args): HELP_REQUESTED = True - + if 'configure' in command_line_args and not HELP_REQUESTED: force_configure = True @@ -482,10 +482,10 @@ for opt in pickle_store: # if custom arguments are supplied make sure to accept them if opts.args: - # since we have custom arguments update environment with all opts to + # since we have custom arguments update environment with all opts to # make sure to absorb the custom ones opts.Update(env) - # now since we've got custom arguments we'll disregard any + # now since we've got custom arguments we'll disregard any # pickled environment and force another configuration preconfigured = False @@ -504,7 +504,7 @@ color_print(4,'\nWelcome to Mapnik...\n') #### Custom Configure Checks ### -def prioritize_paths(context,silent=True): +def prioritize_paths(context,silent=True): env = context.env prefs = env['LINK_PRIORITY'].split(',') if not silent: @@ -572,7 +572,7 @@ def parse_config(context, config, checks='--libs --cflags'): env['SKIPPED_DEPS'].append(tool) conf.rollback_option(config) else: # freetype and libxml2, not optional - env['MISSING_DEPS'].append(tool) + env['MISSING_DEPS'].append(tool) context.Result( ret ) return ret @@ -637,18 +637,18 @@ def rollback_option(context,variable): def FindBoost(context, prefixes, thread_flag): """Routine to auto-find boost header dir, lib dir, and library naming structure. - + """ context.Message( 'Searching for boost libs and headers... ' ) env = context.env - + BOOST_LIB_DIR = None BOOST_INCLUDE_DIR = None BOOST_APPEND = None env['BOOST_APPEND'] = str() - + if env['THREADING'] == 'multi': - search_lib = 'libboost_thread' + search_lib = 'libboost_thread' else: search_lib = 'libboost_filesystem' @@ -669,23 +669,23 @@ def FindBoost(context, prefixes, thread_flag): if hasattr(match,'groups'): BOOST_APPEND = match.groups()[0] break - + msg = str() - + if BOOST_LIB_DIR: msg += '\n *libs found: %s' % BOOST_LIB_DIR env['BOOST_LIBS'] = BOOST_LIB_DIR else: env['BOOST_LIBS'] = '/usr/' + LIBDIR_SCHEMA msg += '\n *using default boost lib dir: %s' % env['BOOST_LIBS'] - + if BOOST_INCLUDE_DIR: msg += '\n *headers found: %s' % BOOST_INCLUDE_DIR env['BOOST_INCLUDES'] = BOOST_INCLUDE_DIR else: env['BOOST_INCLUDES'] = '/usr/include' - msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES'] - + msg += '\n *using default boost include dir: %s' % env['BOOST_INCLUDES'] + if not env['BOOST_TOOLKIT'] and not env['BOOST_ABI'] and not env['BOOST_VERSION']: if BOOST_APPEND: msg += '\n *lib naming extension found: %s' % BOOST_APPEND @@ -704,12 +704,12 @@ def FindBoost(context, prefixes, thread_flag): # Constructing the BOOST_APPEND setting that will be used to find the # Boost libraries. - if len(append_params) > 1: + if len(append_params) > 1: env['BOOST_APPEND'] = '-'.join(append_params) msg += '\n *using boost lib naming: %s' % env['BOOST_APPEND'] env.AppendUnique(CPPPATH = os.path.realpath(env['BOOST_INCLUDES'])) - env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS'])) + env.AppendUnique(LIBPATH = os.path.realpath(env['BOOST_LIBS'])) if env['COLOR_PRINT']: msg = "\033[94m%s\033[0m" % (msg) ret = context.Result(msg) @@ -725,14 +725,14 @@ def CheckBoost(context, version, silent=False): version_n += int(v_arr[1])*100 if len(v_arr) > 2: version_n += int(v_arr[2]) - + if not silent: context.Message('Checking for Boost version >= %s... ' % (version)) ret = context.TryRun(""" #include -int main() +int main() { return BOOST_VERSION >= %d ? 0 : 1; } @@ -749,7 +749,7 @@ def GetBoostLibVersion(context): #include #include -int main() +int main() { std::cout << BOOST_LIB_VERSION << std::endl; @@ -768,7 +768,7 @@ def GetMapnikLibVersion(context): #include #include -int main() +int main() { std::cout << MAPNIK_VERSION_STRING << std::endl; return 0; @@ -788,7 +788,7 @@ def icu_at_least_four_two(context): #include #include -int main() +int main() { std::cout << U_ICU_VERSION_MAJOR_NUM << "." << U_ICU_VERSION_MINOR_NUM << std::endl; return 0; @@ -802,12 +802,12 @@ int main() if not result: context.Result('error, could not get major and minor version from unicode/uversion.h') return False - + major, minor = map(int,result.split('.')) if major >= 4 and minor >= 0: color_print(4,'found: icu %s' % result) return True - + color_print(1,'\nFound insufficient icu version... %s' % result) return False @@ -820,10 +820,10 @@ def boost_regex_has_icu(context): #include #include -int main() +int main() { UnicodeString ustr; - try { + try { boost::u32regex pattern = boost::make_u32regex(ustr); } // an exception is fine, still indicates support is @@ -843,17 +843,17 @@ int main() def sqlite_has_rtree(context): """ check an sqlite3 install has rtree support. - + PRAGMA compile_options; http://www.sqlite.org/c3ref/compileoption_get.html """ - + ret = context.TryRun(""" #include #include -int main() +int main() { sqlite3* db; int rc; @@ -873,7 +873,7 @@ int main() printf("yes, has rtree!\\n"); return 0; } - + return -1; } @@ -883,7 +883,7 @@ int main() if ret[0]: return True return False - + conf_tests = { 'prioritize_paths' : prioritize_paths, 'CheckPKGConfig' : CheckPKGConfig, 'CheckPKG' : CheckPKG, @@ -909,7 +909,7 @@ if not preconfigured: if not env['FAST']: SetCacheMode('force') - + if env['USE_CONFIG']: if not env['CONFIG'].endswith('.py'): color_print(1,'SCons CONFIG file specified is not a python file, will not be read...') @@ -924,7 +924,7 @@ if not preconfigured: optfile = file(conf) #print optfile.read().replace("\n", " ").replace("'","").replace(" = ","=") optfile.close() - + elif not conf == SCONS_LOCAL_CONFIG: # if default missing, no worries # but if the default is overridden and the file is not found, give warning @@ -933,18 +933,18 @@ if not preconfigured: env = Environment(ENV=os.environ,options=opts) env['USE_CONFIG'] = True 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...') conf = Configure(env, custom_tests = conf_tests) - + if env['DEBUG']: mode = 'debug mode' else: mode = 'release mode' - + env['PLATFORM'] = platform.uname()[0] color_print(4,"Configuring on %s in *%s*..." % (env['PLATFORM'],mode)) - + env['MISSING_DEPS'] = [] env['SKIPPED_DEPS'] = [] env['HAS_CAIRO'] = False @@ -964,7 +964,7 @@ if not preconfigured: # now strip it to ensure expected behavior if env['LIB_DIR_NAME'].startswith(os.path.sep): env['LIB_DIR_NAME'] = strip_first(env['LIB_DIR_NAME'],os.path.sep) - + # base install location env['MAPNIK_LIB_BASE'] = os.path.join(env['PREFIX'],env['LIBDIR_SCHEMA']) # directory for plugins and fonts @@ -976,8 +976,8 @@ if not preconfigured: env['MAPNIK_FONTS'] = os.path.normpath(env['SYSTEM_FONTS']) else: env['MAPNIK_FONTS'] = os.path.join(env['MAPNIK_LIB_DIR'],'fonts') - - # install prefix is a pre-pended base location to + + # install prefix is a pre-pended base location to # re-route the install and only intended for package building # we normalize to ensure no trailing slash and proper pre-pending to the absolute prefix install_prefix = os.path.normpath(os.path.realpath(env['DESTDIR'])) + os.path.realpath(env['PREFIX']) @@ -991,12 +991,12 @@ if not preconfigured: env['MAPNIK_FONTS_DEST'] = os.path.normpath(env['SYSTEM_FONTS']) else: env['MAPNIK_FONTS_DEST'] = os.path.join(env['MAPNIK_LIB_DIR_DEST'],'fonts') - + if env['LINKING'] == 'static': env['MAPNIK_LIB_NAME'] = '${LIBPREFIX}mapnik${LIBSUFFIX}' else: env['MAPNIK_LIB_NAME'] = '${SHLIBPREFIX}mapnik${SHLIBSUFFIX}' - + if env['PKG_CONFIG_PATH']: env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) # otherwise this variable == os.environ["PKG_CONFIG_PATH"] @@ -1008,11 +1008,11 @@ if not preconfigured: if not os.path.isdir(env['SYSTEM_FONTS']): color_print(1,'Warning: Directory specified for SYSTEM_FONTS does not exist!') #### Libraries and headers dependency checks #### - + # Set up for libraries and headers dependency checks env['CPPPATH'] = ['#include', '#'] env['LIBPATH'] = ['#src'] - + # set any custom cxxflags to come first env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS']) @@ -1027,7 +1027,7 @@ if not preconfigured: # set if the `CXX` option begins with `CC`) SOLARIS = env['PLATFORM'] == 'SunOS' env['SUNCC'] = SOLARIS and env['CXX'].startswith('CC') - + # If the Sun Studio C++ compiler (`CC`) is used instead of GCC. if env['SUNCC']: env['CC'] = 'cc' @@ -1050,7 +1050,7 @@ if not preconfigured: if os.path.exists(env['ICU_LIB_NAME']): #-sICU_LINK=" -L/usr/lib -licucore env['ICU_LIB_NAME'] = os.path.basename(env['ICU_LIB_NAME']).replace('.dylib','').replace('lib','') - + # Adding the required prerequisite library directories to the include path for # compiling and the library path for linking, respectively. for required in ('PNG', 'JPEG', 'TIFF','PROJ','ICU', 'SQLITE'): @@ -1094,8 +1094,8 @@ if not preconfigured: # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests if env['PRIORITIZE_LINKING']: - conf.prioritize_paths(silent=False) - + conf.prioritize_paths(silent=False) + for libname, headers, required, lang in LIBSHEADERS: if not conf.CheckLibWithHeader(libname, headers, lang): if required: @@ -1109,16 +1109,16 @@ if not preconfigured: if not conf.icu_at_least_four_two(): # expression_string.cpp and map.cpp use fromUTF* function only available in >= ICU 4.2 env['MISSING_DEPS'].append(env['ICU_LIB_NAME']) - + if env['THREADING'] == 'multi': thread_flag = thread_suffix else: thread_flag = '' - + conf.FindBoost(BOOST_SEARCH_PREFIXES,thread_flag) - + env['BOOST_LIB_VERSION_FROM_HEADER'] = conf.GetBoostLibVersion() - + # The other required boost headers. BOOST_LIBSHEADERS = [ ['system', 'boost/system/system_error.hpp', True], @@ -1126,11 +1126,11 @@ if not preconfigured: ['regex', 'boost/regex.hpp', True], ['program_options', 'boost/program_options.hpp', False] ] - + if env['THREADING'] == 'multi': BOOST_LIBSHEADERS.append(['thread', 'boost/thread/mutex.hpp', True]) # on solaris the configure checks for boost_thread - # require the -pthreads flag to be able to check for + # require the -pthreads flag to be able to check for # threading support, so we add as a global library instead # of attaching to cxxflags after configure if env['PLATFORM'] == 'SunOS': @@ -1138,17 +1138,17 @@ if not preconfigured: # if requested, sort LIBPATH and CPPPATH before running CheckLibWithHeader tests if env['PRIORITIZE_LINKING']: - conf.prioritize_paths() - + conf.prioritize_paths() + # if the user is not setting custom boost configuration # enforce boost version greater than or equal to BOOST_MIN_VERSION if not conf.CheckBoost(BOOST_MIN_VERSION): - color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION) + color_print(1,'Boost version %s or greater is required' % BOOST_MIN_VERSION) if not env['BOOST_VERSION']: env['MISSING_DEPS'].append('boost version >=%s' % BOOST_MIN_VERSION) else: color_print(4,'Found boost lib version... %s' % env.get('BOOST_LIB_VERSION_FROM_HEADER') ) - + for count, libinfo in enumerate(BOOST_LIBSHEADERS): if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0],env['BOOST_APPEND']), libinfo[1], 'C++'): if libinfo[2]: @@ -1167,7 +1167,7 @@ if not preconfigured: env['SKIPPED_DEPS'].append('boost_regex_icu') env['REQUESTED_PLUGINS'] = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])] - + if len(env['REQUESTED_PLUGINS']): color_print(4,'Checking for requested plugins dependencies...') for plugin in env['REQUESTED_PLUGINS']: @@ -1232,7 +1232,7 @@ if not preconfigured: elif details['lib'] and details['inc']: if not conf.CheckLibWithHeader(details['lib'], details['inc'], details['lang']): env['SKIPPED_DEPS'].append(details['lib']) - + # re-append the local paths for mapnik sources to the beginning of the list # to make sure they come before any plugins that were 'prepended' env.PrependUnique(CPPPATH = '#include', delete_existing=True) @@ -1247,7 +1247,7 @@ if not preconfigured: # Decide which libagg to use # if we are using internal agg, then prepend to make sure # we link locally - + if env['INTERNAL_LIBAGG']: env.Prepend(CPPPATH = '#deps/agg/include') env.Prepend(LIBPATH = '#deps/agg') @@ -1260,7 +1260,7 @@ if not preconfigured: if env['CAIRO_LIBS']: env["CAIROMM_LIBPATHS"].append(os.path.realpath(env['CAIRO_LIBS'])) if not env['CAIRO_INCLUDES']: - c_inc = env['CAIRO_LIBS'].replace('lib','',1) + c_inc = env['CAIRO_LIBS'].replace('lib','',1) if c_inc: c_inc = os.path.normpath(os.path.realpath(env['CAIRO_INCLUDES'])) if c_inc.endswith('include'): @@ -1323,17 +1323,17 @@ if not preconfigured: env['SKIPPED_DEPS'].append('cairo') env['SKIPPED_DEPS'].append('cairomm') color_print(1,'pkg-config reported: %s' % e) - + else: color_print(4,'Not building with cairo support, pass CAIRO=True to enable') - + if 'python' in env['BINDINGS']: # checklibwithheader does not work for boost_python since we can't feed it # multiple header files, so we fall back on a simple check for boost_python headers if not conf.CheckHeader(header='boost/python/detail/config.hpp',language='C++'): color_print(1,'Could not find required header files for boost python') env['MISSING_DEPS'].append('boost python') - + if env['CAIRO']: if conf.CheckPKGConfig('0.15.0') and conf.CheckPKG('pycairo'): env['HAS_PYCAIRO'] = True @@ -1341,10 +1341,10 @@ if not preconfigured: env['SKIPPED_DEPS'].extend(['pycairo']) else: color_print(4,'Not building with pycairo support, pass CAIRO=True to enable') - - + + #### End Config Stage for Required Dependencies #### - + if env['MISSING_DEPS']: # if required dependencies are missing, print warnings and then let SCons finish without building or saving local config color_print(1,'\nExiting... the following required dependencies were not found:\n - %s' % '\n - '.join([pretty_dep(dep) for dep in env['MISSING_DEPS']])) @@ -1367,7 +1367,7 @@ if not preconfigured: if env['USE_CONFIG']: if os.path.exists(SCONS_LOCAL_CONFIG): action = 'Overwriting and re-saving' - os.unlink(SCONS_LOCAL_CONFIG) + os.unlink(SCONS_LOCAL_CONFIG) else: action = 'Saving new' color_print(4,"%s file '%s'..." % (action,SCONS_LOCAL_CONFIG)) @@ -1409,25 +1409,25 @@ if not preconfigured: # common_cxx_flags += '-DOSX_LEOPARD ' else: pthread = '-pthread' - + # Common debugging flags. # http://lists.fedoraproject.org/pipermail/devel/2010-November/144952.html debug_flags = '-g -fno-omit-frame-pointer -DDEBUG -DMAPNIK_DEBUG' ndebug_flags = '-DNDEBUG' # Enable logging in debug mode (always) and release mode (when specified) + severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none'] if env['DEFAULT_LOG_SEVERITY']: - severities = ['info', 'debug', 'warn', 'error', 'fatal', 'none'] if env['DEFAULT_LOG_SEVERITY'] not in severities: - color_print(1,"Cannot set default logger severity to '%s', available options are 'info', 'debug', 'warn', 'error', 'fatal', 'none'." % env['DEFAULT_LOG_SEVERITY']) + severities_list = ', '.join(["'%s'" % s for s in severities]) + color_print(1,"Cannot set default logger severity to '%s', available options are %s." % (env['DEFAULT_LOG_SEVERITY'], severities_list)) Exit(1) else: log_severity = severities.index(env['DEFAULT_LOG_SEVERITY']) else: - if env['DEBUG']: - log_severity = 1 # debug - else: - log_severity = 3 # error + severities_list = ', '.join(["'%s'" % s for s in severities]) + color_print(1,"No logger severity specified, available options are %s." % severities_list) + Exit(1) log_enabled = ' -DMAPNIK_LOG -DMAPNIK_DEFAULT_LOG_SEVERITY=%d' % log_severity @@ -1447,7 +1447,7 @@ if not preconfigured: if env['PLATFORM'] != 'Darwin' and env['CXX'] == 'g++': env.MergeFlags('-rdynamic') - # Customizing the C++ compiler flags depending on: + # Customizing the C++ compiler flags depending on: # (1) the C++ compiler used; and # (2) whether debug binaries are requested. if env['SUNCC']: @@ -1457,10 +1457,10 @@ if not preconfigured: env.Append(CXXFLAGS = common_cxx_flags + '-O %s' % ndebug_flags) else: # Common flags for GCC. - gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags) + gcc_cxx_flags = '-ansi -Wall %s %s -ftemplate-depth-300 %s' % (env['WARNING_CXXFLAGS'], pthread, common_cxx_flags) if env['DEBUG']: env.Append(CXXFLAGS = gcc_cxx_flags + '-O0 -fno-inline %s' % debug_flags) - else: + else: env.Append(CXXFLAGS = gcc_cxx_flags + '-O%s -finline-functions -Wno-inline -Wno-parentheses -Wno-char-subscripts %s' % (env['OPTIMIZATION'],ndebug_flags)) if env['DEBUG_UNDEFINED']: @@ -1470,44 +1470,44 @@ if not preconfigured: if not os.access(env['PYTHON'], os.X_OK): color_print(1,"Cannot run python interpreter at '%s', make sure that you have the permissions to execute it." % env['PYTHON']) Exit(1) - + py3 = 'True' in os.popen('''%s -c "import sys as s;s.stdout.write(str(s.version_info[0] == 3))"''' % env['PYTHON']).read().strip() if py3: sys_prefix = '''%s -c "import sys; print(sys.prefix)"''' % env['PYTHON'] else: - sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] + sys_prefix = '''%s -c "import sys; print sys.prefix"''' % env['PYTHON'] env['PYTHON_SYS_PREFIX'] = call(sys_prefix) - - if HAS_DISTUTILS: + + if HAS_DISTUTILS: if py3: sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print(get_python_version())"''' % env['PYTHON'] else: - sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] + sys_version = '''%s -c "from distutils.sysconfig import get_python_version; print get_python_version()"''' % env['PYTHON'] env['PYTHON_VERSION'] = call(sys_version) - + if py3: - py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON'] + py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"''' % env['PYTHON'] else: py_includes = '''%s -c "from distutils.sysconfig import get_python_inc; print get_python_inc()"''' % env['PYTHON'] env['PYTHON_INCLUDES'] = call(py_includes) - + # Note: we use the plat_specific argument here to make sure to respect the arch-specific site-packages location if py3: site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(plat_specific=True))"''' % env['PYTHON'] else: - site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] + site_packages = '''%s -c "from distutils.sysconfig import get_python_lib; print get_python_lib(plat_specific=True)"''' % env['PYTHON'] env['PYTHON_SITE_PACKAGES'] = call(site_packages) else: env['PYTHON_SYS_PREFIX'] = os.popen('''%s -c "import sys; print sys.prefix"''' % env['PYTHON']).read().strip() env['PYTHON_VERSION'] = os.popen('''%s -c "import sys; print sys.version"''' % env['PYTHON']).read()[0:3] env['PYTHON_INCLUDES'] = env['PYTHON_SYS_PREFIX'] + '/include/python' + env['PYTHON_VERSION'] env['PYTHON_SITE_PACKAGES'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SYS_PREFIX'] + os.path.sep + env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' - - # if user-requested custom prefix fall back to manual concatenation for building subdirectories + + # if user-requested custom prefix fall back to manual concatenation for building subdirectories if env['PYTHON_PREFIX']: - py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' - env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install + py_relative_install = env['LIBDIR_SCHEMA'] + '/python' + env['PYTHON_VERSION'] + '/site-packages/' + env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_PREFIX'] + os.path.sep + py_relative_install else: env['PYTHON_INSTALL_LOCATION'] = env['DESTDIR'] + os.path.sep + env['PYTHON_SITE_PACKAGES'] @@ -1515,27 +1515,27 @@ if not preconfigured: is_64_bit = '''%s -c "import sys; print(sys.maxsize == 9223372036854775807)"''' % env['PYTHON'] else: is_64_bit = '''%s -c "import sys; print sys.maxint == 9223372036854775807"''' % env['PYTHON'] - + if is_64_bit: env['PYTHON_IS_64BIT'] = True else: - env['PYTHON_IS_64BIT'] = False - + env['PYTHON_IS_64BIT'] = False + majver, minver = env['PYTHON_VERSION'].split('.') - + # we don't want the includes it in the main environment... # as they are later set in the python build.py # ugly hack needed until we have env specific conf backup = env.Clone().Dictionary() env.AppendUnique(CPPPATH = os.path.realpath(env['PYTHON_INCLUDES'])) - + if not conf.CheckHeader(header='Python.h',language='C'): color_print(1,'Could not find required header files for the Python language (version %s)' % env['PYTHON_VERSION']) env.Replace(**backup) Exit(1) else: env.Replace(**backup) - + if (int(majver), int(minver)) < (2, 2): color_print(1,"Python version 2.2 or greater required") Exit(1) @@ -1557,7 +1557,7 @@ if not preconfigured: # if requested, sort LIBPATH and CPPPATH one last time before saving... if env['PRIORITIZE_LINKING']: conf.prioritize_paths() - + # finish config stage and pickle results env = conf.Finish() env_cache = open(SCONS_CONFIGURE_CACHE, 'w') @@ -1606,7 +1606,7 @@ if not HELP_REQUESTED: if env['PKG_CONFIG_PATH']: env['ENV']['PKG_CONFIG_PATH'] = os.path.realpath(env['PKG_CONFIG_PATH']) # otherwise this variable == os.environ["PKG_CONFIG_PATH"] - + if env['PATH']: env['ENV']['PATH'] = os.path.realpath(env['PATH']) + ':' + env['ENV']['PATH'] @@ -1640,10 +1640,10 @@ if not HELP_REQUESTED: replace_path('CXXFLAGS',search,replace) replace_path('CAIROMM_LIBPATHS',search,replace) replace_path('CAIROMM_CPPPATHS',search,replace) - + # export env so it is available in build.py files Export('env') - + plugin_base = env.Clone() # for this to work you need: # if __GNUC__ >= 4 @@ -1659,7 +1659,7 @@ if not HELP_REQUESTED: env['_CPPDEFFLAGS'] = None plugin_base['_CPPDEFFLAGS'] = None - + if env['FAST']: # caching is 'auto' by default in SCons # But let's also cache implicit deps... @@ -1667,22 +1667,22 @@ if not HELP_REQUESTED: SetOption('implicit_cache', 1) env.Decider('MD5-timestamp') SetOption('max_drift', 1) - + else: # Set the cache mode to 'force' unless requested, avoiding hidden caching of Scons 'opts' in '.sconsign.dblite' # This allows for a SCONS_LOCAL_CONFIG, if present, to be used as the primary means of storing paths to successful build dependencies SetCacheMode('force') - + if env['JOBS'] > 1: - SetOption("num_jobs", env['JOBS']) - + SetOption("num_jobs", env['JOBS']) + # Build agg first, doesn't need anything special if env['RUNTIME_LINK'] == 'shared' and env['INTERNAL_LIBAGG']: SConscript('deps/agg/build.py') - + # Build the core library SConscript('src/build.py') - + # Build the requested and able-to-be-compiled input plug-ins GDAL_BUILT = False OGR_BUILT = False @@ -1702,7 +1702,7 @@ if not HELP_REQUESTED: SConscript('plugins/input/%s/build.py' % plugin) else: color_print(1,"Notice: dependencies not met for plugin '%s', not building..." % plugin) - + create_uninstall_target(env, env['MAPNIK_LIB_DIR_DEST'], False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) create_uninstall_target(env, env['MAPNIK_INPUT_PLUGINS_DEST'] , False) @@ -1716,43 +1716,43 @@ if not HELP_REQUESTED: if os.path.exists(plugin_path): color_print(1,"Notice: removing out of date plugin: '%s'" % plugin_path) os.unlink(plugin_path) - + # Build the c++ rundemo app if requested if env['DEMO']: SConscript('demo/c++/build.py') - + # Build the pgsql2psqlite app if requested if env['PGSQL2SQLITE']: SConscript('utils/pgsql2sqlite/build.py') - + # Build shapeindex and remove its dependency from the LIBS if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']: SConscript('utils/shapeindex/build.py') - - # devtools not ready for public + + # devtools not ready for public #SConscript('utils/ogrindex/build.py') SConscript('utils/svg2png/build.py') env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND']) else : color_print(1,"WARNING: Cannot find boost_program_options. 'shapeindex' won't be available") - + # Build the Python bindings if 'python' in env['BINDINGS']: SConscript('bindings/python/build.py') - + # Install the python speed testing scripts if python bindings will be available SConscript('utils/performance/build.py') # Install the mapnik upgrade script SConscript('utils/upgrade_map_xml/build.py') - + # Configure fonts and if requested install the bundled DejaVu fonts SConscript('fonts/build.py') - + # build C++ tests # not ready for release SConscript('tests/cpp_tests/build.py') - + # not ready for release #if env['SVG_RENDERER']: # SConscript('tests/cpp_tests/svg_renderer_tests/build.py') @@ -1762,7 +1762,7 @@ if not HELP_REQUESTED: # write the viewer.ini file SConscript('demo/viewer/build.py') - + # if requested, build the sample input plugins if env['SAMPLE_INPUT_PLUGINS']: SConscript('plugins/input/templates/helloworld/build.py')