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

This commit is contained in:
Dane Springmeyer 2012-03-14 17:26:50 -07:00
parent 74452f8ed7
commit 2abe02bd96
5 changed files with 37 additions and 21 deletions

View file

@ -768,7 +768,7 @@ def GetMapnikLibVersion(context):
int main() int main()
{ {
std::cout << MAPNIK_VERSION << std::endl; std::cout << MAPNIK_VERSION_STRING << std::endl;
return 0; return 0;
} }
@ -778,11 +778,7 @@ int main()
context.Result(ret[0]) context.Result(ret[0])
if not ret[1]: if not ret[1]:
return [] return []
version = int(ret[1].strip()) return ret[1].strip()
patch_level = version % 100
minor_version = version / 100 % 1000
major_version = version / 100000
return [major_version,minor_version,patch_level]
def icu_at_least_four_two(context): def icu_at_least_four_two(context):
ret = context.TryRun(""" ret = context.TryRun("""
@ -1382,14 +1378,13 @@ if not preconfigured:
# fetch the mapnik version header in order to set the # fetch the mapnik version header in order to set the
# ABI version used to build libmapnik.so on linux in src/build.py # ABI version used to build libmapnik.so on linux in src/build.py
abi = conf.GetMapnikLibVersion() abi = conf.GetMapnikLibVersion()
abi_fallback = [2,0,0] abi_fallback = "2.0.1-pre"
if not abi: if not abi:
color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback) color_print(1,'Problem encountered parsing mapnik version, falling back to %s' % abi_fallback)
env['ABI_VERSION'] = abi_fallback abi = abi_fallback
else:
env['ABI_VERSION'] = abi
env['MAPNIK_VERSION_STRING'] = '.'.join(['%d' % i for i in env['ABI_VERSION']])
env['ABI_VERSION'] = abi.replace('-pre','').split('.')
env['MAPNIK_VERSION_STRING'] = abi
# Common C++ flags. # Common C++ flags.
if env['THREADING'] == 'multi': if env['THREADING'] == 'multi':

View file

@ -572,13 +572,6 @@ def Geos(**keywords):
keywords['type'] = 'geos' keywords['type'] = 'geos'
return CreateDatasource(keywords) 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): def mapnik_version_from_string(version_string):
"""Return the Mapnik version from a string.""" """Return the Mapnik version from a string."""
n = version_string.split('.') n = version_string.split('.')

View file

@ -279,6 +279,11 @@ unsigned mapnik_version()
return MAPNIK_VERSION; return MAPNIK_VERSION;
} }
std::string mapnik_version_string()
{
return MAPNIK_VERSION_STRING;
}
// indicator for jpeg read/write support within libmapnik // indicator for jpeg read/write support within libmapnik
bool has_jpeg() bool has_jpeg()
{ {
@ -573,6 +578,7 @@ BOOST_PYTHON_MODULE(_mapnik)
def("save_map_to_string", &save_map_to_string, save_map_to_string_overloads()); 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", &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_jpeg", &has_jpeg, "Get jpeg read/write support status");
def("has_cairo", &has_cairo, "Get cairo library status"); def("has_cairo", &has_cairo, "Get cairo library status");
def("has_pycairo", &has_pycairo, "Get pycairo module status"); def("has_pycairo", &has_pycairo, "Get pycairo module status");

View file

@ -23,6 +23,28 @@
#ifndef MAPNIK_VERSION_HPP #ifndef MAPNIK_VERSION_HPP
#define MAPNIK_VERSION_HPP #define MAPNIK_VERSION_HPP
#define MAPNIK_VERSION 200000 #define MAPNIK_VERSION_IS_RELEASE 0
#define MAPNIK_MAJOR_VERSION 2
#define MAPNIK_MINOR_VERSION 1
#define MAPNIK_PATCH_VERSION 0
#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 #endif // MAPNIK_VERSION_HPP

View file

@ -83,7 +83,7 @@ else:
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
mapnik_libname = 'libmapnik.dylib' mapnik_libname = 'libmapnik.dylib'
else: else:
mapnik_libname = 'libmapnik.so.' + ("%d.%d" % (ABI_VERSION[0],ABI_VERSION[1])) mapnik_libname = 'libmapnik.so.' + ("%d.%d" % (int(ABI_VERSION[0]),int(ABI_VERSION[1])))
if env['PLATFORM'] == 'Darwin': if env['PLATFORM'] == 'Darwin':
if env['FULL_LIB_PATH']: if env['FULL_LIB_PATH']:
@ -91,7 +91,7 @@ if env['PLATFORM'] == 'Darwin':
else: else:
lib_path = mapnik_libname lib_path = mapnik_libname
mapnik_lib_link_flag += ' -Wl,-install_name,%s' % lib_path 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 mapnik_lib_link_flag += ' -current_version %(version)s -compatibility_version %(version)s' % _d
elif env['PLATFORM'] == 'SunOS': elif env['PLATFORM'] == 'SunOS':
if env['CXX'].startswith('CC'): if env['CXX'].startswith('CC'):