diff --git a/Makefile b/Makefile index 9084ec4d..ec14c4db 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,15 @@ PREFIX ?= /usr/local MANDIR ?= $(PREFIX)/share/man/man1/ BUILDTYPE ?= Release +BUILD_INFO ?= SHELL = /bin/sh # inherit from env if set CC := $(CC) CXX := $(CXX) -CFLAGS := $(CFLAGS) -fPIE -CXXFLAGS := $(CXXFLAGS) -std=c++17 -fPIE +CFLAGS := $(CFLAGS) -fPIE -DBUILD_INFO=$(BUILD_INFO) +CXXFLAGS := $(CXXFLAGS) -std=c++17 -fPIE -DBUILD_INFO=$(BUILD_INFO) LDFLAGS := $(LDFLAGS) WARNING_FLAGS := -Wall -Wshadow -Wsign-compare -Wextra -Wunreachable-code -Wuninitialized -Wshadow RELEASE_FLAGS := -O3 -DNDEBUG diff --git a/main.cpp b/main.cpp index dad6a05d..54595bc6 100644 --- a/main.cpp +++ b/main.cpp @@ -49,7 +49,6 @@ #include "tile.hpp" #include "pool.hpp" #include "projection.hpp" -#include "version.hpp" #include "memfile.hpp" #include "main.hpp" #include "geojson.hpp" @@ -3608,7 +3607,7 @@ int main(int argc, char **argv) { } case 'v': - fprintf(stderr, "tippecanoe %s\n", VERSION); + fprintf(stderr, "tippecanoe %s\n", version_str().c_str()); exit(EXIT_SUCCESS); case 'P': diff --git a/mbtiles.cpp b/mbtiles.cpp index 8dcc0e33..a489e7da 100644 --- a/mbtiles.cpp +++ b/mbtiles.cpp @@ -654,6 +654,17 @@ static double sixdig(double val) { return std::round(val * 1e6) / 1e6; } +#define str(x) #x +#define xstr(x) str(x) +std::string version_str() { + std::string s = VERSION; + std::string build_info = xstr(BUILD_INFO); + if (build_info.size() > 0) { + s += " " + build_info; + } + return s; +} + metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minlat, double minlon, double maxlat, double maxlon, double minlat2, double minlon2, double maxlat2, double maxlon2, double midlat, double midlon, const char *attribution, std::map const &layermap, bool vector, const char *description, bool do_tilestats, std::map const &attribute_descriptions, std::string const &program, std::string const &commandline, std::vector const &strategies, int basezoom, double droprate, int retain_points_multiplier) { metadata m; @@ -684,7 +695,7 @@ metadata make_metadata(const char *fname, int minzoom, int maxzoom, double minla m.attribution = attribution; } - m.generator = program + " " + VERSION; + m.generator = program + " " + version_str(); m.generator_options = commandline; m.strategies_json = stringify_strategies(strategies); diff --git a/mbtiles.hpp b/mbtiles.hpp index 8863df60..661f5a65 100644 --- a/mbtiles.hpp +++ b/mbtiles.hpp @@ -77,5 +77,6 @@ std::map merge_layermaps(std::vector merge_layermaps(std::vector > const &maps, bool trunc); void add_to_tilestats(std::map &tilestats, std::string const &layername, serial_val const &val); +std::string version_str(); #endif