From 1912362b46cea6cb4e48abbbca2eecf187e718a5 Mon Sep 17 00:00:00 2001 From: Dane Springmeyer Date: Wed, 14 Mar 2012 17:26:50 -0700 Subject: [PATCH] make available MAPNIK_VERSION_STRING in c++ header (not just in python) and add MAPNIK_VERSION_IS_RELEASE define that indicates if the code is released --- SConstruct | 17 ++++++----------- bindings/python/mapnik/__init__.py | 7 ------- bindings/python/mapnik_python.cpp | 6 ++++++ include/mapnik/version.hpp | 26 ++++++++++++++++++++++++-- src/build.py | 2 +- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/SConstruct b/SConstruct index fe33b333d..ee3b9e9f7 100644 --- a/SConstruct +++ b/SConstruct @@ -793,7 +793,7 @@ def GetMapnikLibVersion(context): int main() { - std::cout << MAPNIK_VERSION << std::endl; + std::cout << MAPNIK_VERSION_STRING << std::endl; return 0; } @@ -803,11 +803,7 @@ int main() context.Result(ret[0]) if not ret[1]: return [] - version = int(ret[1].strip()) - patch_level = version % 100 - minor_version = version / 100 % 1000 - major_version = version / 100000 - return [major_version,minor_version,patch_level] + return ret[1].strip() def icu_at_least_four_two(context): ret = context.TryRun(""" @@ -1372,14 +1368,13 @@ if not preconfigured: # fetch the mapnik version header in order to set the # ABI version used to build libmapnik.so on linux in src/build.py abi = conf.GetMapnikLibVersion() - abi_fallback = [2,0,0] + abi_fallback = "2.0.1-pre" 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 - env['MAPNIK_VERSION_STRING'] = '.'.join(['%d' % i for i in env['ABI_VERSION']]) + abi = abi_fallback + env['ABI_VERSION'] = abi.replace('-pre','').split('.') + env['MAPNIK_VERSION_STRING'] = abi # Common C++ flags. if env['THREADING'] == 'multi': diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index 4364f7b45..8b38afea8 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -605,13 +605,6 @@ def Geos(**keywords): keywords['type'] = 'geos' return CreateDatasource(keywords) -def mapnik_version_string(version=mapnik_version()): - """Return the Mapnik version as a string.""" - patch_level = version % 100 - minor_version = version / 100 % 1000 - major_version = version / 100000 - return '%s.%s.%s' % ( major_version, minor_version,patch_level) - def mapnik_version_from_string(version_string): """Return the Mapnik version from a string.""" n = version_string.split('.') diff --git a/bindings/python/mapnik_python.cpp b/bindings/python/mapnik_python.cpp index dc76aef54..60405fe59 100644 --- a/bindings/python/mapnik_python.cpp +++ b/bindings/python/mapnik_python.cpp @@ -319,6 +319,11 @@ unsigned mapnik_version() return MAPNIK_VERSION; } +std::string mapnik_version_string() +{ + return MAPNIK_VERSION_STRING; +} + // indicator for jpeg read/write support within libmapnik bool has_jpeg() { @@ -597,6 +602,7 @@ BOOST_PYTHON_MODULE(_mapnik) def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads()); def("mapnik_version", &mapnik_version,"Get the Mapnik version number"); + def("mapnik_version_string", &mapnik_version_string,"Get the Mapnik version string"); def("has_jpeg", &has_jpeg, "Get jpeg read/write support status"); def("has_cairo", &has_cairo, "Get cairo library status"); def("has_pycairo", &has_pycairo, "Get pycairo module status"); diff --git a/include/mapnik/version.hpp b/include/mapnik/version.hpp index defeb9da1..6b9d4a15c 100644 --- a/include/mapnik/version.hpp +++ b/include/mapnik/version.hpp @@ -24,9 +24,31 @@ #ifndef MAPNIK_VERSION_HPP #define MAPNIK_VERSION_HPP -#define MAPNIK_VERSION 200000 +#define MAPNIK_VERSION_IS_RELEASE 0 -#endif //MAPNIK_VERSION_HPP +#define MAPNIK_MAJOR_VERSION 2 +#define MAPNIK_MINOR_VERSION 0 +#define MAPNIK_PATCH_VERSION 1 + +#define MAPNIK_VERSION (MAPNIK_MAJOR_VERSION*100000) + (MAPNIK_MINOR_VERSION*100) + (MAPNIK_PATCH_VERSION) + +#ifndef MAPNIK_STRINGIFY +#define MAPNIK_STRINGIFY(n) MAPNIK_STRINGIFY_HELPER(n) +#define MAPNIK_STRINGIFY_HELPER(n) #n +#endif + +#if MAPNIK_VERSION_IS_RELEASE +# define MAPNIK_VERSION_STRING MAPNIK_STRINGIFY(MAPNIK_MAJOR_VERSION) "." \ + MAPNIK_STRINGIFY(MAPNIK_MINOR_VERSION) "." \ + MAPNIK_STRINGIFY(MAPNIK_PATCH_VERSION) + +#else +# define MAPNIK_VERSION_STRING MAPNIK_STRINGIFY(MAPNIK_MAJOR_VERSION) "." \ + MAPNIK_STRINGIFY(MAPNIK_MINOR_VERSION) "." \ + MAPNIK_STRINGIFY(MAPNIK_PATCH_VERSION) "-pre" +#endif + +#endif // MAPNIK_VERSION_HPP diff --git a/src/build.py b/src/build.py index 78f26594d..a0cc448f3 100644 --- a/src/build.py +++ b/src/build.py @@ -89,7 +89,7 @@ if env['PLATFORM'] == 'Darwin': else: lib_path = mapnik_libname mapnik_lib_link_flag += ' -Wl,-install_name,%s' % lib_path - _d = {'version':env['MAPNIK_VERSION_STRING']} + _d = {'version':env['MAPNIK_VERSION_STRING'].replace('-pre','')} mapnik_lib_link_flag += ' -current_version %(version)s -compatibility_version %(version)s' % _d elif env['PLATFORM'] == 'SunOS': if env['CXX'].startswith('CC'):