From 2d846dd5f339c51831a35d591309c80164ea3992 Mon Sep 17 00:00:00 2001 From: Mathis Logemann Date: Sat, 29 Jan 2022 12:52:23 +0100 Subject: [PATCH] static plugins wip static plugins add remaining datasources wip formatting --- CMakeLists.txt | 22 +++++++- cmake/MapnikInstall.cmake | 3 + include/mapnik/config.hpp | 20 +++++-- include/mapnik/datasource.hpp | 6 +- include/mapnik/webp_io.hpp | 22 +------- plugins/input/CMakeLists.txt | 10 +++- plugins/input/base/CMakeLists.txt | 11 ++++ .../base/include/mapnik/datasource_plugin.hpp | 42 ++++++++++++++ plugins/input/csv/CMakeLists.txt | 6 +- plugins/input/csv/csv_datasource.cpp | 5 +- plugins/input/csv/csv_datasource.hpp | 5 ++ plugins/input/gdal/CMakeLists.txt | 8 ++- plugins/input/gdal/gdal_datasource.cpp | 8 +-- plugins/input/gdal/gdal_datasource.hpp | 4 +- plugins/input/geobuf/CMakeLists.txt | 8 ++- plugins/input/geobuf/geobuf_datasource.cpp | 4 +- plugins/input/geobuf/geobuf_datasource.hpp | 2 + plugins/input/geojson/CMakeLists.txt | 6 +- plugins/input/geojson/geojson_datasource.cpp | 4 +- plugins/input/geojson/geojson_datasource.hpp | 3 + plugins/input/ogr/CMakeLists.txt | 8 ++- plugins/input/ogr/ogr_datasource.cpp | 7 +-- plugins/input/ogr/ogr_datasource.hpp | 3 + plugins/input/pgraster/CMakeLists.txt | 6 +- .../input/pgraster/pgraster_datasource.cpp | 4 +- .../input/pgraster/pgraster_datasource.hpp | 2 + plugins/input/postgis/CMakeLists.txt | 6 +- plugins/input/postgis/postgis_datasource.cpp | 4 +- plugins/input/postgis/postgis_datasource.hpp | 2 + plugins/input/raster/CMakeLists.txt | 8 ++- plugins/input/raster/raster_datasource.cpp | 4 +- plugins/input/raster/raster_datasource.hpp | 2 + plugins/input/shape/CMakeLists.txt | 8 ++- plugins/input/shape/shape_datasource.cpp | 4 +- plugins/input/shape/shape_datasource.hpp | 3 + plugins/input/sqlite/CMakeLists.txt | 7 ++- plugins/input/sqlite/sqlite_datasource.cpp | 4 +- plugins/input/sqlite/sqlite_datasource.hpp | 3 + plugins/input/topojson/CMakeLists.txt | 7 ++- .../input/topojson/topojson_datasource.cpp | 4 +- .../input/topojson/topojson_datasource.hpp | 3 + src/CMakeLists.txt | 47 ++++++++++++++-- src/datasource_cache_static.cpp | 55 +++++++++++++------ src/json/CMakeLists.txt | 3 +- src/plugin.cpp | 13 +++-- src/webp_io.cpp | 24 ++++++++ src/wkt/CMakeLists.txt | 3 +- 47 files changed, 333 insertions(+), 110 deletions(-) create mode 100644 plugins/input/base/CMakeLists.txt create mode 100644 plugins/input/base/include/mapnik/datasource_plugin.hpp create mode 100644 src/webp_io.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f2dc1f02d..05a9ccc26 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,7 @@ mapnik_option(USE_LOG "enables logging output. See log severity level." OFF) set(USE_LOG_SEVERITY "1" CACHE STRING "sets the logging severity (only applies when USE_LOG is ON") mapnik_option(USE_STATS "Enable statistics reporting" OFF) +mapnik_option(STATIC_PLUGINS "statically link plugins into libmapnik" OFF) mapnik_option(USE_PLUGIN_INPUT_CSV "adds plugin input csv" ON) mapnik_option(USE_PLUGIN_INPUT_GDAL "adds plugin input gdal" ON) mapnik_option(USE_PLUGIN_INPUT_GEOBUF "adds plugin input geobuf" ON) @@ -344,6 +345,16 @@ if(NOT WIN32) list(APPEND MAPNIK_OPTIONAL_LIBS ${CMAKE_DL_LIBS}) endif() +if(MAPNIK_STATIC_PLUGINS) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_PLUGINS) +endif() + + +# when building static, this have to be public so that all depending libs know about +if(NOT BUILD_SHARED_LIBS) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE) +endif() + # force utf-8 source code processing # see https://docs.microsoft.com/de-de/cpp/build/reference/utf-8-set-source-and-executable-character-sets-to-utf-8?view=msvc-170 add_compile_options("$<$:/utf-8>") @@ -377,9 +388,18 @@ target_compile_definitions(core INTERFACE ${MAPNIK_COMPILE_DEFS}) mapnik_install(core) +# forward declaring libraries to consume them when building static plugins (circle deps between mapnik <-> plugin_target) +add_library(mapnik "") +add_library(mapnik::mapnik ALIAS mapnik) +add_library(wkt STATIC "") +add_library(mapnik::wkt ALIAS wkt) +add_library(json STATIC "") +add_library(mapnik::json ALIAS json) +# end forward declaration + add_subdirectory(deps) -add_subdirectory(src) add_subdirectory(plugins) +add_subdirectory(src) add_subdirectory(utils) add_subdirectory(demo) if(BUILD_BENCHMARK) diff --git a/cmake/MapnikInstall.cmake b/cmake/MapnikInstall.cmake index 0953c09db..7983c75e5 100644 --- a/cmake/MapnikInstall.cmake +++ b/cmake/MapnikInstall.cmake @@ -23,6 +23,9 @@ endfunction() # Install plugins # function(mapnik_install_plugin _target) + if(MAPNIK_STATIC_PLUGINS) + return() + endif() install(TARGETS ${_target} RUNTIME DESTINATION ${PLUGINS_INSTALL_DIR} COMPONENT MapnikPluginRuntime diff --git a/include/mapnik/config.hpp b/include/mapnik/config.hpp index 99f2bae3c..fa0129dc1 100644 --- a/include/mapnik/config.hpp +++ b/include/mapnik/config.hpp @@ -26,13 +26,21 @@ // Windows DLL support #ifdef _WIN32 -# define MAPNIK_EXP __declspec (dllexport) -# define MAPNIK_IMP __declspec (dllimport) -# ifdef MAPNIK_EXPORTS -# define MAPNIK_DECL __declspec (dllexport) -# else -# define MAPNIK_DECL __declspec (dllimport) +#ifdef MAPNIK_STATIC_DEFINE +# define MAPNIK_DECL +# define MAPNIK_EXP +#else +# define MAPNIK_EXP __declspec(dllexport) +# ifndef MAPNIK_DECL +# ifdef MAPNIK_EXPORTS + /* We are building this library */ +# define MAPNIK_DECL __declspec(dllexport) +# else + /* We are using this library */ +# define MAPNIK_DECL __declspec(dllimport) +# endif # endif +#endif # pragma warning( disable: 4251 ) # pragma warning( disable: 4275 ) # if (_MSC_VER >= 1400) // vc8 diff --git a/include/mapnik/datasource.hpp b/include/mapnik/datasource.hpp index 9525c1fb7..0099ce5a4 100644 --- a/include/mapnik/datasource.hpp +++ b/include/mapnik/datasource.hpp @@ -136,15 +136,15 @@ using datasource_ptr = std::shared_ptr; #define DATASOURCE_PLUGIN(classname) #else #define DATASOURCE_PLUGIN(classname) \ - extern "C" MAPNIK_EXP const char * datasource_name() \ + extern "C" MAPNIK_DECL const char * datasource_name() \ { \ return classname::name(); \ } \ - extern "C" MAPNIK_EXP datasource* create(parameters const& params) \ + extern "C" MAPNIK_DECL datasource* create(parameters const& params) \ { \ return new classname(params); \ } \ - extern "C" MAPNIK_EXP void destroy(datasource *ds) \ + extern "C" MAPNIK_DECL void destroy(datasource *ds) \ { \ delete ds; \ } diff --git a/include/mapnik/webp_io.hpp b/include/mapnik/webp_io.hpp index 06f9d6bdc..b25312747 100644 --- a/include/mapnik/webp_io.hpp +++ b/include/mapnik/webp_io.hpp @@ -24,6 +24,7 @@ #define MAPNIK_WEBP_IO_HPP // mapnik +#include #include #include @@ -51,26 +52,7 @@ int webp_stream_write(const uint8_t* data, size_t data_size, const WebPPicture* return true; } -std::string webp_encoding_error(WebPEncodingError error) -{ - std::string os; - switch (error) - { - case VP8_ENC_ERROR_OUT_OF_MEMORY: os = "memory error allocating objects"; break; - case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: os = "memory error while flushing bits"; break; - case VP8_ENC_ERROR_NULL_PARAMETER: os = "a pointer parameter is NULL"; break; - case VP8_ENC_ERROR_INVALID_CONFIGURATION: os = "configuration is invalid"; break; - case VP8_ENC_ERROR_BAD_DIMENSION: os = "picture has invalid width/height"; break; - case VP8_ENC_ERROR_PARTITION0_OVERFLOW: os = "partition is bigger than 512k"; break; - case VP8_ENC_ERROR_PARTITION_OVERFLOW: os = "partition is bigger than 16M"; break; - case VP8_ENC_ERROR_BAD_WRITE: os = "error while flushing bytes"; break; - case VP8_ENC_ERROR_FILE_TOO_BIG: os = "file is bigger than 4G"; break; - default: - mapnik::util::to_string(os,error); - os = "unknown error (" + os + ")"; break; - } - return os; -} +std::string MAPNIK_DECL webp_encoding_error(WebPEncodingError error); template inline int import_image(T2 const& im_in, diff --git a/plugins/input/CMakeLists.txt b/plugins/input/CMakeLists.txt index 5f89249ec..2849b8766 100644 --- a/plugins/input/CMakeLists.txt +++ b/plugins/input/CMakeLists.txt @@ -1,5 +1,13 @@ set(_plugin_prefix "") set(_plugin_suffix ".input") +set(_plugin_linkage MODULE) +set(_plugin_source_visibility PRIVATE) +if(MAPNIK_STATIC_PLUGINS) + set(_plugin_linkage INTERFACE) + set(_plugin_visibility INTERFACE) +endif() + +add_subdirectory(base) # add a list with all build plugins so the copy dependencies command can wait for all build events set(m_build_plugins "") @@ -51,7 +59,7 @@ endif() # # Copy all plugin dlls, so that these are in the main output dir, since cmake copies those into ${MAPNIK_OUTPUT_DIR}/plugins/input, too. # -if(WIN32) +if(NOT MAPNIK_STATIC_PLUGINS AND WIN32) list(LENGTH m_build_plugins m_number_plugins) if(m_number_plugins GREATER 0) string(CONFIGURE diff --git a/plugins/input/base/CMakeLists.txt b/plugins/input/base/CMakeLists.txt new file mode 100644 index 000000000..1dca6a808 --- /dev/null +++ b/plugins/input/base/CMakeLists.txt @@ -0,0 +1,11 @@ +add_library(datasource-base INTERFACE) +add_library(mapnik::datasource-base ALIAS datasource-base) + + +target_include_directories(datasource-base INTERFACE + $ + $ +) +target_link_libraries(datasource-base INTERFACE mapnik::core) + +mapnik_install(datasource-base) diff --git a/plugins/input/base/include/mapnik/datasource_plugin.hpp b/plugins/input/base/include/mapnik/datasource_plugin.hpp new file mode 100644 index 000000000..dad3eb3ed --- /dev/null +++ b/plugins/input/base/include/mapnik/datasource_plugin.hpp @@ -0,0 +1,42 @@ +#ifndef DATASOURCE_PLUGIN_HPP +#define DATASOURCE_PLUGIN_HPP +#include +#include +#include + + +namespace mapnik +{ + class MAPNIK_DECL datasource_plugin + { + public: + datasource_plugin() {} + virtual ~datasource_plugin() {} + virtual void init_once() const = 0; + virtual const std::string& name() const = 0; + virtual datasource_ptr create(parameters const ¶ms) const= 0; + + }; +} + +#define DATASOURCE_PLUGIN_DEF(classname, pluginname) class classname : public mapnik::datasource_plugin {\ +public:\ + static constexpr const char* kName = #pluginname;\ + void init_once() const override;\ + const std::string& name() const override;\ + mapnik::datasource_ptr create(mapnik::parameters const ¶ms) const override;\ +}; + +#define DATASOURCE_PLUGIN_IMPL(classname, pluginclassname) const std::string& classname::name() const { return kName; } \ +mapnik::datasource_ptr classname::create(mapnik::parameters const ¶ms) const { return std::make_shared(params); } + +#define DATASOURCE_PLUGIN_EMPTY_INIT(classname) void classname::init_once() const {} + +#ifndef MAPNIK_STATIC_PLUGINS +#define DATASOURCE_PLUGIN_EXPORT(classname) extern "C" MAPNIK_EXP classname plugin; \ +classname plugin; +#else +#define DATASOURCE_PLUGIN_EXPORT(classname) // export classname +#endif + +#endif diff --git a/plugins/input/csv/CMakeLists.txt b/plugins/input/csv/CMakeLists.txt index dcc966157..b5a89f0b2 100644 --- a/plugins/input/csv/CMakeLists.txt +++ b/plugins/input/csv/CMakeLists.txt @@ -1,14 +1,16 @@ -add_library(input-csv MODULE +add_library(input-csv ${_plugin_linkage}) +target_sources(input-csv ${_plugin_visibility} csv_datasource.cpp csv_featureset.cpp csv_index_featureset.cpp csv_inline_featureset.cpp csv_utils.cpp ) -target_link_libraries(input-csv PRIVATE +target_link_libraries(input-csv ${_plugin_visibility} mapnik::mapnik mapnik::wkt mapnik::json + mapnik::datasource-base ) set_target_properties(input-csv PROPERTIES OUTPUT_NAME "csv" diff --git a/plugins/input/csv/csv_datasource.cpp b/plugins/input/csv/csv_datasource.cpp index ed6bbb12d..fe0ea76cd 100644 --- a/plugins/input/csv/csv_datasource.cpp +++ b/plugins/input/csv/csv_datasource.cpp @@ -65,7 +65,10 @@ MAPNIK_DISABLE_WARNING_POP using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(csv_datasource) +DATASOURCE_PLUGIN_IMPL(csv_datasource_plugin, csv_datasource); +DATASOURCE_PLUGIN_EXPORT(csv_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(csv_datasource_plugin); + csv_datasource::csv_datasource(parameters const& params) : datasource(params), diff --git a/plugins/input/csv/csv_datasource.hpp b/plugins/input/csv/csv_datasource.hpp index a81d308e2..2d549640b 100644 --- a/plugins/input/csv/csv_datasource.hpp +++ b/plugins/input/csv/csv_datasource.hpp @@ -48,6 +48,8 @@ MAPNIK_DISABLE_WARNING_POP #include #include +#include + template struct csv_linear : boost::geometry::index::linear {}; @@ -70,6 +72,9 @@ struct options_type > }; }}}}} +DATASOURCE_PLUGIN_DEF(csv_datasource_plugin, csv); + + class csv_datasource : public mapnik::datasource, private csv_utils::csv_file_parser { diff --git a/plugins/input/gdal/CMakeLists.txt b/plugins/input/gdal/CMakeLists.txt index 746953a3c..2db11e1c9 100644 --- a/plugins/input/gdal/CMakeLists.txt +++ b/plugins/input/gdal/CMakeLists.txt @@ -1,12 +1,14 @@ find_package(GDAL REQUIRED) -add_library(input-gdal MODULE +add_library(input-gdal ${_plugin_linkage}) +target_sources(input-gdal ${_plugin_visibility} gdal_datasource.cpp gdal_featureset.cpp ) -target_include_directories(input-gdal PRIVATE ${GDAL_INCLUDE_DIRS}) -target_link_libraries(input-gdal PRIVATE +target_include_directories(input-gdal ${_plugin_visibility} ${GDAL_INCLUDE_DIRS}) +target_link_libraries(input-gdal ${_plugin_visibility} mapnik::mapnik + mapnik::datasource-base ${GDAL_LIBRARIES} ) set_target_properties(input-gdal PROPERTIES diff --git a/plugins/input/gdal/gdal_datasource.cpp b/plugins/input/gdal/gdal_datasource.cpp index ccb3da029..ac2a7a809 100644 --- a/plugins/input/gdal/gdal_datasource.cpp +++ b/plugins/input/gdal/gdal_datasource.cpp @@ -37,8 +37,6 @@ using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(gdal_datasource) - using mapnik::box2d; using mapnik::coord2d; using mapnik::query; @@ -48,9 +46,9 @@ using mapnik::datasource_exception; static std::once_flag once_flag; -extern "C" MAPNIK_EXP void on_plugin_load() -{ - // initialize gdal formats +DATASOURCE_PLUGIN_IMPL(gdal_datasource_plugin, gdal_datasource); +DATASOURCE_PLUGIN_EXPORT(gdal_datasource_plugin); +void gdal_datasource_plugin::init_once() const { std::call_once(once_flag,[](){ GDALAllRegister(); }); diff --git a/plugins/input/gdal/gdal_datasource.hpp b/plugins/input/gdal/gdal_datasource.hpp index 27e3a2104..ddd363900 100644 --- a/plugins/input/gdal/gdal_datasource.hpp +++ b/plugins/input/gdal/gdal_datasource.hpp @@ -31,7 +31,7 @@ #include #include #include - +#include // boost #include @@ -42,6 +42,8 @@ // gdal #include +DATASOURCE_PLUGIN_DEF(gdal_datasource_plugin, gdal); + class gdal_datasource : public mapnik::datasource { public: diff --git a/plugins/input/geobuf/CMakeLists.txt b/plugins/input/geobuf/CMakeLists.txt index 870b603d9..57447fbed 100644 --- a/plugins/input/geobuf/CMakeLists.txt +++ b/plugins/input/geobuf/CMakeLists.txt @@ -1,8 +1,12 @@ -add_library(input-geobuf MODULE +add_library(input-geobuf ${_plugin_linkage}) +target_sources(input-geobuf ${_plugin_visibility} geobuf_datasource.cpp geobuf_featureset.cpp ) -target_link_libraries(input-geobuf PRIVATE mapnik::mapnik) +target_link_libraries(input-geobuf ${_plugin_visibility} + mapnik::mapnik + mapnik::datasource-base +) set_target_properties(input-geobuf PROPERTIES OUTPUT_NAME "geobuf" PREFIX "${_plugin_prefix}" diff --git a/plugins/input/geobuf/geobuf_datasource.cpp b/plugins/input/geobuf/geobuf_datasource.cpp index 3dbdc93fc..7992dccda 100644 --- a/plugins/input/geobuf/geobuf_datasource.cpp +++ b/plugins/input/geobuf/geobuf_datasource.cpp @@ -48,7 +48,9 @@ using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(geobuf_datasource) +DATASOURCE_PLUGIN_IMPL(geobuf_datasource_plugin, geobuf_datasource); +DATASOURCE_PLUGIN_EXPORT(geobuf_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(geobuf_datasource_plugin); struct attr_value_converter { diff --git a/plugins/input/geobuf/geobuf_datasource.hpp b/plugins/input/geobuf/geobuf_datasource.hpp index 16dc048f0..e30202555 100644 --- a/plugins/input/geobuf/geobuf_datasource.hpp +++ b/plugins/input/geobuf/geobuf_datasource.hpp @@ -32,6 +32,7 @@ #include #include #include +#include // boost #include #include @@ -75,6 +76,7 @@ struct options_type > }}}}} +DATASOURCE_PLUGIN_DEF(geobuf_datasource_plugin, geobuf); class geobuf_datasource : public mapnik::datasource { public: diff --git a/plugins/input/geojson/CMakeLists.txt b/plugins/input/geojson/CMakeLists.txt index e32dcfcb1..967f47820 100644 --- a/plugins/input/geojson/CMakeLists.txt +++ b/plugins/input/geojson/CMakeLists.txt @@ -1,12 +1,14 @@ -add_library(input-geojson MODULE +add_library(input-geojson ${_plugin_linkage}) +target_sources(input-geojson ${_plugin_visibility} geojson_datasource.cpp geojson_featureset.cpp geojson_index_featureset.cpp geojson_memory_index_featureset.cpp ) -target_link_libraries(input-geojson PRIVATE +target_link_libraries(input-geojson ${_plugin_visibility} mapnik::mapnik mapnik::json + mapnik::datasource-base ) set_target_properties(input-geojson PROPERTIES OUTPUT_NAME "geojson" diff --git a/plugins/input/geojson/geojson_datasource.cpp b/plugins/input/geojson/geojson_datasource.cpp index 62952e9ce..dce61d0d3 100644 --- a/plugins/input/geojson/geojson_datasource.cpp +++ b/plugins/input/geojson/geojson_datasource.cpp @@ -67,7 +67,9 @@ MAPNIK_DISABLE_WARNING_POP using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(geojson_datasource) +DATASOURCE_PLUGIN_IMPL(geojson_datasource_plugin, geojson_datasource); +DATASOURCE_PLUGIN_EXPORT(geojson_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(geojson_datasource_plugin); struct attr_value_converter { diff --git a/plugins/input/geojson/geojson_datasource.hpp b/plugins/input/geojson/geojson_datasource.hpp index 4bb965f3c..2c1f11562 100644 --- a/plugins/input/geojson/geojson_datasource.hpp +++ b/plugins/input/geojson/geojson_datasource.hpp @@ -32,6 +32,7 @@ #include #include #include +#include #include MAPNIK_DISABLE_WARNING_PUSH @@ -73,6 +74,8 @@ struct options_type > }}}}} +DATASOURCE_PLUGIN_DEF(geojson_datasource_plugin, geojson); + class geojson_datasource : public mapnik::datasource { public: diff --git a/plugins/input/ogr/CMakeLists.txt b/plugins/input/ogr/CMakeLists.txt index f460eb033..f6e562181 100644 --- a/plugins/input/ogr/CMakeLists.txt +++ b/plugins/input/ogr/CMakeLists.txt @@ -1,14 +1,16 @@ find_package(GDAL REQUIRED) -add_library(input-ogr MODULE +add_library(input-ogr ${_plugin_linkage}) +target_sources(input-ogr ${_plugin_visibility} ogr_converter.cpp ogr_datasource.cpp ogr_featureset.cpp ogr_index_featureset.cpp ) -target_include_directories(input-ogr PRIVATE ${GDAL_INCLUDE_DIRS}) -target_link_libraries(input-ogr PRIVATE +target_include_directories(input-ogr ${_plugin_visibility} ${GDAL_INCLUDE_DIRS}) +target_link_libraries(input-ogr ${_plugin_visibility} mapnik::mapnik + mapnik::datasource-base ${GDAL_LIBRARIES} ) set_target_properties(input-ogr PROPERTIES diff --git a/plugins/input/ogr/ogr_datasource.cpp b/plugins/input/ogr/ogr_datasource.cpp index bf2652690..ed87a107e 100644 --- a/plugins/input/ogr/ogr_datasource.cpp +++ b/plugins/input/ogr/ogr_datasource.cpp @@ -49,8 +49,6 @@ MAPNIK_DISABLE_WARNING_POP using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(ogr_datasource) - using mapnik::box2d; using mapnik::coord2d; using mapnik::query; @@ -63,8 +61,9 @@ using mapnik::filter_at_point; static std::once_flag once_flag; -extern "C" MAPNIK_EXP void on_plugin_load() -{ +DATASOURCE_PLUGIN_IMPL(ogr_datasource_plugin, ogr_datasource); +DATASOURCE_PLUGIN_EXPORT(ogr_datasource_plugin); +void ogr_datasource_plugin::init_once() const { // initialize ogr formats // NOTE: in GDAL >= 2.0 this is the same as GDALAllRegister() std::call_once(once_flag,[](){ diff --git a/plugins/input/ogr/ogr_datasource.hpp b/plugins/input/ogr/ogr_datasource.hpp index 4523b0134..4ffdfc0e9 100644 --- a/plugins/input/ogr/ogr_datasource.hpp +++ b/plugins/input/ogr/ogr_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -47,6 +48,8 @@ MAPNIK_DISABLE_WARNING_PUSH MAPNIK_DISABLE_WARNING_POP #include "ogr_layer_ptr.hpp" +DATASOURCE_PLUGIN_DEF(ogr_datasource_plugin, ogr); + class ogr_datasource : public mapnik::datasource { public: diff --git a/plugins/input/pgraster/CMakeLists.txt b/plugins/input/pgraster/CMakeLists.txt index f7ac4ff66..4a570502d 100644 --- a/plugins/input/pgraster/CMakeLists.txt +++ b/plugins/input/pgraster/CMakeLists.txt @@ -1,12 +1,14 @@ find_package(PostgreSQL REQUIRED) -add_library(input-pgraster MODULE +add_library(input-pgraster ${_plugin_linkage}) +target_sources(input-pgraster ${_plugin_visibility} pgraster_datasource.cpp pgraster_featureset.cpp pgraster_wkb_reader.cpp ) -target_link_libraries(input-pgraster PRIVATE +target_link_libraries(input-pgraster ${_plugin_visibility} mapnik::mapnik + mapnik::datasource-base PostgreSQL::PostgreSQL ) set_target_properties(input-pgraster PROPERTIES diff --git a/plugins/input/pgraster/pgraster_datasource.cpp b/plugins/input/pgraster/pgraster_datasource.cpp index 545f80c5a..ce841deeb 100644 --- a/plugins/input/pgraster/pgraster_datasource.cpp +++ b/plugins/input/pgraster/pgraster_datasource.cpp @@ -51,7 +51,9 @@ MAPNIK_DISABLE_WARNING_POP #include #include -DATASOURCE_PLUGIN(pgraster_datasource) +DATASOURCE_PLUGIN_IMPL(pgraster_datasource_plugin, pgraster_datasource); +DATASOURCE_PLUGIN_EXPORT(pgraster_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(pgraster_datasource_plugin); const std::string pgraster_datasource::RASTER_COLUMNS = "raster_columns"; const std::string pgraster_datasource::RASTER_OVERVIEWS = "raster_overviews"; diff --git a/plugins/input/pgraster/pgraster_datasource.hpp b/plugins/input/pgraster/pgraster_datasource.hpp index 7f74bbbcf..87f858814 100644 --- a/plugins/input/pgraster/pgraster_datasource.hpp +++ b/plugins/input/pgraster/pgraster_datasource.hpp @@ -37,6 +37,7 @@ #include #include #include +#include // boost #include @@ -74,6 +75,7 @@ struct pgraster_overview }; +DATASOURCE_PLUGIN_DEF(pgraster_datasource_plugin, pgraster); class pgraster_datasource : public datasource { public: diff --git a/plugins/input/postgis/CMakeLists.txt b/plugins/input/postgis/CMakeLists.txt index 796e0c90e..7e7061b7a 100644 --- a/plugins/input/postgis/CMakeLists.txt +++ b/plugins/input/postgis/CMakeLists.txt @@ -1,11 +1,13 @@ find_package(PostgreSQL REQUIRED) -add_library(input-postgis MODULE +add_library(input-postgis ${_plugin_linkage}) +target_sources(input-postgis ${_plugin_visibility} postgis_datasource.cpp postgis_featureset.cpp ) -target_link_libraries(input-postgis PRIVATE +target_link_libraries(input-postgis ${_plugin_visibility} mapnik::mapnik + mapnik::datasource-base PostgreSQL::PostgreSQL ) set_target_properties(input-postgis PROPERTIES diff --git a/plugins/input/postgis/postgis_datasource.cpp b/plugins/input/postgis/postgis_datasource.cpp index d40caa540..4c79c9a2a 100644 --- a/plugins/input/postgis/postgis_datasource.cpp +++ b/plugins/input/postgis/postgis_datasource.cpp @@ -49,7 +49,9 @@ MAPNIK_DISABLE_WARNING_POP #include #include -DATASOURCE_PLUGIN(postgis_datasource) +DATASOURCE_PLUGIN_IMPL(postgis_datasource_plugin, postgis_datasource); +DATASOURCE_PLUGIN_EXPORT(postgis_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(postgis_datasource_plugin); const std::string postgis_datasource::GEOMETRY_COLUMNS = "geometry_columns"; const std::string postgis_datasource::SPATIAL_REF_SYS = "spatial_ref_system"; diff --git a/plugins/input/postgis/postgis_datasource.hpp b/plugins/input/postgis/postgis_datasource.hpp index 6d50f9cf0..8bb398947 100644 --- a/plugins/input/postgis/postgis_datasource.hpp +++ b/plugins/input/postgis/postgis_datasource.hpp @@ -34,6 +34,7 @@ #include #include #include +#include // boost #include @@ -62,6 +63,7 @@ using mapnik::coord2d; using CnxPool_ptr = std::shared_ptr< ConnectionManager::PoolType>; +DATASOURCE_PLUGIN_DEF(postgis_datasource_plugin, postgis); class postgis_datasource : public datasource { public: diff --git a/plugins/input/raster/CMakeLists.txt b/plugins/input/raster/CMakeLists.txt index c7426ea3a..c9f12d9e6 100644 --- a/plugins/input/raster/CMakeLists.txt +++ b/plugins/input/raster/CMakeLists.txt @@ -1,9 +1,13 @@ -add_library(input-raster MODULE +add_library(input-raster ${_plugin_linkage}) +target_sources(input-raster ${_plugin_visibility} raster_datasource.cpp raster_featureset.cpp raster_info.cpp ) -target_link_libraries(input-raster PRIVATE mapnik::mapnik) +target_link_libraries(input-raster ${_plugin_visibility} + mapnik::mapnik + mapnik::datasource-base +) set_target_properties(input-raster PROPERTIES OUTPUT_NAME "raster" PREFIX "${_plugin_prefix}" diff --git a/plugins/input/raster/raster_datasource.cpp b/plugins/input/raster/raster_datasource.cpp index 71eb0dec3..97b7cb20d 100644 --- a/plugins/input/raster/raster_datasource.cpp +++ b/plugins/input/raster/raster_datasource.cpp @@ -43,7 +43,9 @@ using mapnik::datasource; using mapnik::parameters; using mapnik::image_reader; -DATASOURCE_PLUGIN(raster_datasource) +DATASOURCE_PLUGIN_IMPL(raster_datasource_plugin, raster_datasource); +DATASOURCE_PLUGIN_EXPORT(raster_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(raster_datasource_plugin); raster_datasource::raster_datasource(parameters const& params) : datasource(params), diff --git a/plugins/input/raster/raster_datasource.hpp b/plugins/input/raster/raster_datasource.hpp index 3007ed7f7..651c5b99d 100644 --- a/plugins/input/raster/raster_datasource.hpp +++ b/plugins/input/raster/raster_datasource.hpp @@ -31,6 +31,7 @@ #include #include #include +#include // boost #include @@ -40,6 +41,7 @@ #include #include +DATASOURCE_PLUGIN_DEF(raster_datasource_plugin, raster); class raster_datasource : public mapnik::datasource { diff --git a/plugins/input/shape/CMakeLists.txt b/plugins/input/shape/CMakeLists.txt index 6d9a9a7d1..2cd86cdac 100644 --- a/plugins/input/shape/CMakeLists.txt +++ b/plugins/input/shape/CMakeLists.txt @@ -1,4 +1,5 @@ -add_library(input-shape MODULE +add_library(input-shape ${_plugin_linkage}) +target_sources(input-shape ${_plugin_visibility} dbfile.cpp dbf_test.cpp shape_datasource.cpp @@ -6,7 +7,10 @@ add_library(input-shape MODULE shape_index_featureset.cpp shape_io.cpp shape_utils.cpp ) -target_link_libraries(input-shape PRIVATE mapnik::mapnik) +target_link_libraries(input-shape ${_plugin_visibility} + mapnik::mapnik + mapnik::datasource-base +) set_target_properties(input-shape PROPERTIES OUTPUT_NAME "shape" PREFIX "${_plugin_prefix}" diff --git a/plugins/input/shape/shape_datasource.cpp b/plugins/input/shape/shape_datasource.cpp index 21a8d5867..ce0b73e5e 100644 --- a/plugins/input/shape/shape_datasource.cpp +++ b/plugins/input/shape/shape_datasource.cpp @@ -47,7 +47,9 @@ MAPNIK_DISABLE_WARNING_POP #include #include -DATASOURCE_PLUGIN(shape_datasource) +DATASOURCE_PLUGIN_IMPL(shape_datasource_plugin, shape_datasource); +DATASOURCE_PLUGIN_EXPORT(shape_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(shape_datasource_plugin); using mapnik::String; using mapnik::Double; diff --git a/plugins/input/shape/shape_datasource.hpp b/plugins/input/shape/shape_datasource.hpp index 66841bdb0..b915ea0fe 100644 --- a/plugins/input/shape/shape_datasource.hpp +++ b/plugins/input/shape/shape_datasource.hpp @@ -32,6 +32,7 @@ #include #include #include +#include // boost #include @@ -50,6 +51,8 @@ using mapnik::featureset_ptr; using mapnik::layer_descriptor; using mapnik::coord2d; +DATASOURCE_PLUGIN_DEF(shape_datasource_plugin, shape); + class shape_datasource : public datasource { public: diff --git a/plugins/input/sqlite/CMakeLists.txt b/plugins/input/sqlite/CMakeLists.txt index 984bdfd1b..d690db4fa 100644 --- a/plugins/input/sqlite/CMakeLists.txt +++ b/plugins/input/sqlite/CMakeLists.txt @@ -1,12 +1,13 @@ find_package(SQLite3 REQUIRED) -add_library(input-sqlite MODULE +add_library(input-sqlite ${_plugin_linkage}) +target_sources(input-sqlite ${_plugin_visibility} sqlite_datasource.cpp sqlite_featureset.cpp ) -add_library(mapnik::plugin::input::sqlite ALIAS input-sqlite) -target_link_libraries(input-sqlite PRIVATE +target_link_libraries(input-sqlite ${_plugin_visibility} mapnik::mapnik + mapnik::datasource-base SQLite::SQLite3 ) set_target_properties(input-sqlite PROPERTIES diff --git a/plugins/input/sqlite/sqlite_datasource.cpp b/plugins/input/sqlite/sqlite_datasource.cpp index f3811e032..4809e6164 100644 --- a/plugins/input/sqlite/sqlite_datasource.cpp +++ b/plugins/input/sqlite/sqlite_datasource.cpp @@ -50,7 +50,9 @@ using mapnik::datasource_exception; using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(sqlite_datasource) +DATASOURCE_PLUGIN_IMPL(sqlite_datasource_plugin, sqlite_datasource); +DATASOURCE_PLUGIN_EXPORT(sqlite_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(sqlite_datasource_plugin); sqlite_datasource::sqlite_datasource(parameters const& params) : datasource(params), diff --git a/plugins/input/sqlite/sqlite_datasource.hpp b/plugins/input/sqlite/sqlite_datasource.hpp index 6495e409a..5b064169c 100644 --- a/plugins/input/sqlite/sqlite_datasource.hpp +++ b/plugins/input/sqlite/sqlite_datasource.hpp @@ -33,6 +33,7 @@ #include #include #include +#include // boost #include @@ -45,6 +46,8 @@ // sqlite #include "sqlite_connection.hpp" +DATASOURCE_PLUGIN_DEF(sqlite_datasource_plugin, sqlite); + class sqlite_datasource : public mapnik::datasource { public: diff --git a/plugins/input/topojson/CMakeLists.txt b/plugins/input/topojson/CMakeLists.txt index fd2b4994b..4b8fd3153 100644 --- a/plugins/input/topojson/CMakeLists.txt +++ b/plugins/input/topojson/CMakeLists.txt @@ -1,11 +1,12 @@ -add_library(input-topojson MODULE +add_library(input-topojson ${_plugin_linkage}) +target_sources(input-topojson ${_plugin_visibility} topojson_datasource.cpp topojson_featureset.cpp ) -add_library(mapnik::plugin::input::topojson ALIAS input-topojson) -target_link_libraries(input-topojson PRIVATE +target_link_libraries(input-topojson ${_plugin_visibility} mapnik::mapnik mapnik::json + mapnik::datasource-base ) set_target_properties(input-topojson PROPERTIES OUTPUT_NAME "topojson" diff --git a/plugins/input/topojson/topojson_datasource.cpp b/plugins/input/topojson/topojson_datasource.cpp index fd0d55cf6..eabc280c2 100644 --- a/plugins/input/topojson/topojson_datasource.cpp +++ b/plugins/input/topojson/topojson_datasource.cpp @@ -42,7 +42,9 @@ using mapnik::datasource; using mapnik::parameters; -DATASOURCE_PLUGIN(topojson_datasource) +DATASOURCE_PLUGIN_IMPL(topojson_datasource_plugin, topojson_datasource); +DATASOURCE_PLUGIN_EXPORT(topojson_datasource_plugin); +DATASOURCE_PLUGIN_EMPTY_INIT(topojson_datasource_plugin); struct attr_value_converter { diff --git a/plugins/input/topojson/topojson_datasource.hpp b/plugins/input/topojson/topojson_datasource.hpp index 0c0937899..c9d605013 100644 --- a/plugins/input/topojson/topojson_datasource.hpp +++ b/plugins/input/topojson/topojson_datasource.hpp @@ -33,6 +33,7 @@ #include #include #include +#include #include MAPNIK_DISABLE_WARNING_PUSH @@ -52,6 +53,8 @@ MAPNIK_DISABLE_WARNING_POP #include #include +DATASOURCE_PLUGIN_DEF(topojson_datasource_plugin, topojson); + class topojson_datasource : public mapnik::datasource { public: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e21672ae8..2c86112cb 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,15 +1,46 @@ add_subdirectory(json) add_subdirectory(wkt) -add_library(mapnik "") -add_library(mapnik::mapnik ALIAS mapnik) - if(BUILD_SHARED_LIBS) + # private as this should only be visibile when building, to dllexport/dllimport correctly target_compile_definitions(mapnik PRIVATE MAPNIK_EXPORTS) endif() -target_link_libraries(mapnik PUBLIC mapnik::core) -target_link_libraries(mapnik PRIVATE mapnik::agg) +target_link_libraries(mapnik PUBLIC mapnik::core mapnik::datasource-base) +target_link_libraries(mapnik PRIVATE + mapnik::agg + # expr: if(MAPNIK_STATIC_PLUGINS == ON && is build) then add link target + $<$,$>:input-csv> + $<$,$>:input-gdal> + $<$,$>:input-geobuf> + $<$,$>:input-geojson> + $<$,$>:input-ogr> + $<$,$>:input-pgraster> + $<$,$>:input-postgis> + $<$,$>:input-raster> + $<$,$>:input-shape> + $<$,$>:input-sqlite> + $<$,$>:input-topojson> +) +target_compile_definitions(mapnik PRIVATE + # expr: if(MAPNIK_STATIC_PLUGINS == ON && is build) then add build definition + $<$,$>:MAPNIK_STATIC_PLUGIN_CSV> + $<$,$>:MAPNIK_STATIC_PLUGIN_GDAL> + $<$,$>:MAPNIK_STATIC_PLUGIN_GEOBUF> + $<$,$>:MAPNIK_STATIC_PLUGIN_GEOJSON> + $<$,$>:MAPNIK_STATIC_PLUGIN_OGR> + $<$,$>:MAPNIK_STATIC_PLUGIN_PGRASTER> + $<$,$>:MAPNIK_STATIC_PLUGIN_POSTGIS> + $<$,$>:MAPNIK_STATIC_PLUGIN_RASTER> + $<$,$>:MAPNIK_STATIC_PLUGIN_SHAPE> + $<$,$>:MAPNIK_STATIC_PLUGIN_SQLITE> + $<$,$>:MAPNIK_STATIC_PLUGIN_TOPOJSON> + +) + +if(MAPNIK_STATIC_PLUGINS) + target_include_directories(mapnik PRIVATE "${PROJECT_SOURCE_DIR}/plugins") +endif() set_target_properties(mapnik PROPERTIES DEBUG_POSTFIX "${MAPNIK_DEBUG_POSTFIX}" @@ -32,6 +63,7 @@ if(MSVC) target_compile_options(mapnik PUBLIC "/bigobj" "/wd4068" "/wd4661" "/wd4910") endif() + target_sources(mapnik PRIVATE cairo_io.cpp color_factory.cpp @@ -258,7 +290,10 @@ if(USE_TIFF) endif() if(USE_WEBP) - target_sources(mapnik PRIVATE webp_reader.cpp) + target_sources(mapnik PRIVATE + webp_reader.cpp + webp_io.cpp + ) endif() if(USE_GRID_RENDERER) diff --git a/src/datasource_cache_static.cpp b/src/datasource_cache_static.cpp index 7bbc58566..7af94fa4f 100644 --- a/src/datasource_cache_static.cpp +++ b/src/datasource_cache_static.cpp @@ -26,15 +26,16 @@ #ifdef MAPNIK_STATIC_PLUGINS #include - -// boost -#include +#include #endif // stl #include #include + +#define REGISTER_STATIC_DATASOURCE_PLUGIN(classname) {std::string{classname::kName}, std::make_shared()} + // static plugin linkage #ifdef MAPNIK_STATIC_PLUGINS #if defined(MAPNIK_STATIC_PLUGIN_CSV) @@ -43,6 +44,9 @@ #if defined(MAPNIK_STATIC_PLUGIN_GDAL) #include "input/gdal/gdal_datasource.hpp" #endif + #if defined(MAPNIK_STATIC_PLUGIN_GEOBUF) + #include "input/geobuf/geobuf_datasource.hpp" + #endif #if defined(MAPNIK_STATIC_PLUGIN_GEOJSON) #include "input/geojson/geojson_datasource.hpp" #endif @@ -58,6 +62,9 @@ #if defined(MAPNIK_STATIC_PLUGIN_OGR) #include "input/ogr/ogr_datasource.hpp" #endif + #if defined(MAPNIK_STATIC_PLUGIN_PGRASTER) + #include "input/pgraster/pgraster_datasource.hpp" + #endif #if defined(MAPNIK_STATIC_PLUGIN_OSM) #include "input/osm/osm_datasource.hpp" #endif @@ -76,6 +83,9 @@ #if defined(MAPNIK_STATIC_PLUGIN_SQLITE) #include "input/sqlite/sqlite_datasource.hpp" #endif + #if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON) + #include "input/topojson/topojson_datasource.hpp" + #endif #endif namespace mapnik { @@ -88,43 +98,52 @@ datasource_ptr ds_generator(parameters const& params) } typedef datasource_ptr (*ds_generator_ptr)(parameters const& params); -using datasource_map = std::unordered_map; +using datasource_map = std::unordered_map>; -static datasource_map ds_map = boost::assign::map_list_of +static datasource_map ds_map{ #if defined(MAPNIK_STATIC_PLUGIN_CSV) - (std::string("csv"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(csv_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_GDAL) - (std::string("gdal"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(gdal_datasource_plugin), + #endif + #if defined(MAPNIK_STATIC_PLUGIN_GEOBUF) + REGISTER_STATIC_DATASOURCE_PLUGIN(geobuf_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_GEOJSON) - (std::string("geojson"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(geojson_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_OCCI) - (std::string("occi"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(occi_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_OGR) - (std::string("ogr"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(ogr_datasource_plugin), + #endif + #if defined(MAPNIK_STATIC_PLUGIN_PGRASTER) + REGISTER_STATIC_DATASOURCE_PLUGIN(pgraster_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_OSM) - (std::string("osm"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(osm_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_POSTGIS) - (std::string("postgis"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(postgis_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_RASTER) - (std::string("raster"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(raster_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_RASTERLITE) - (std::string("rasterlite"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(rasterlite_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_SHAPE) - (std::string("shape"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(shape_datasource_plugin), #endif #if defined(MAPNIK_STATIC_PLUGIN_SQLITE) - (std::string("sqlite"), &ds_generator) + REGISTER_STATIC_DATASOURCE_PLUGIN(sqlite_datasource_plugin), #endif -; + #if defined(MAPNIK_STATIC_PLUGIN_TOPOJSON) + REGISTER_STATIC_DATASOURCE_PLUGIN(topojson_datasource_plugin), + #endif +}; #endif #ifdef MAPNIK_STATIC_PLUGINS @@ -135,7 +154,7 @@ datasource_ptr create_static_datasource(parameters const& params) datasource_map::iterator it = ds_map.find(*type); if (it != ds_map.end()) { - ds = it->second(params); + ds = it->second->create(params); } return ds; } diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index b35e0183a..bdda4a042 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(json STATIC +target_sources(json PRIVATE extract_bounding_boxes_x3.cpp feature_from_geojson.cpp feature_grammar_x3.cpp @@ -13,7 +13,6 @@ add_library(json STATIC topojson_grammar_x3.cpp unicode_string_grammar_x3.cpp ) -add_library(mapnik::json ALIAS json) target_include_directories(json PRIVATE ${JPEG_INCLUDE_DIR} diff --git a/src/plugin.cpp b/src/plugin.cpp index 281bc02f8..3540da2ea 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -23,6 +23,8 @@ #include #include +#include + #ifdef _WIN32 #define NOMINMAX #include @@ -58,12 +60,11 @@ PluginInfo::PluginInfo(std::string const& filename, if (module_) module_->dl = LoadLibraryA(filename.c_str()); if (module_ && module_->dl) { - callable_returning_string name_call = reinterpret_cast(dlsym(module_->dl, library_name.c_str())); - if (name_call) name_ = name_call(); - callable_returning_void init_once = reinterpret_cast(dlsym(module_->dl, "on_plugin_load")); - if (init_once) { - init_once(); - } + datasource_plugin* plugin = reinterpret_cast(dlsym(module_->dl, "plugin")); + if(!plugin) + throw std::runtime_error("plugin has a false interface"); //! todo: better error text + name_ = plugin->name(); + plugin->init_once(); } #else #ifdef MAPNIK_HAS_DLCFN diff --git a/src/webp_io.cpp b/src/webp_io.cpp new file mode 100644 index 000000000..2f2e7ab1f --- /dev/null +++ b/src/webp_io.cpp @@ -0,0 +1,24 @@ +#include + +namespace mapnik { + std::string MAPNIK_DECL webp_encoding_error(WebPEncodingError error) { + std::string os; + switch (error) + { + case VP8_ENC_ERROR_OUT_OF_MEMORY: os = "memory error allocating objects"; break; + case VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY: os = "memory error while flushing bits"; break; + case VP8_ENC_ERROR_NULL_PARAMETER: os = "a pointer parameter is NULL"; break; + case VP8_ENC_ERROR_INVALID_CONFIGURATION: os = "configuration is invalid"; break; + case VP8_ENC_ERROR_BAD_DIMENSION: os = "picture has invalid width/height"; break; + case VP8_ENC_ERROR_PARTITION0_OVERFLOW: os = "partition is bigger than 512k"; break; + case VP8_ENC_ERROR_PARTITION_OVERFLOW: os = "partition is bigger than 16M"; break; + case VP8_ENC_ERROR_BAD_WRITE: os = "error while flushing bytes"; break; + case VP8_ENC_ERROR_FILE_TOO_BIG: os = "file is bigger than 4G"; break; + default: + mapnik::util::to_string(os,error); + os = "unknown error (" + os + ")"; break; + } + return os; +} + +} diff --git a/src/wkt/CMakeLists.txt b/src/wkt/CMakeLists.txt index 8e42bef69..7cb0db1fd 100644 --- a/src/wkt/CMakeLists.txt +++ b/src/wkt/CMakeLists.txt @@ -1,10 +1,9 @@ -add_library(wkt STATIC +target_sources(wkt PRIVATE geometry_to_wkt.cpp mapnik_wkt_generator_grammar.cpp wkt_factory.cpp wkt_grammar_x3.cpp ) -add_library(mapnik::wkt ALIAS wkt) target_include_directories(wkt PRIVATE ${MAPNIK_INCLUDE_PATH}