diff --git a/.github/actions/run_tests/action.yml b/.github/actions/run_tests/action.yml index 44db0d99b..14b7fe91e 100644 --- a/.github/actions/run_tests/action.yml +++ b/.github/actions/run_tests/action.yml @@ -27,14 +27,14 @@ runs: - name: Test visuals (windows) continue-on-error: true - working-directory: build/${{ inputs.cmake-preset }}/out + working-directory: build/out shell: "pwsh" if: runner.os == 'Windows' run: OpenCppCoverage --modules *libmapnik* --modules mapnik*.exe --modules *.input --sources ${{ github.workspace }} --export_type binary --input_coverage=${{ github.workspace }}/ctest.cov --cover_children -- .\mapnik-test-visual.exe -j (Get-CimInstance -ClassName Win32_ComputerSystem).NumberOfLogicalProcessors --output-dir ./visual-test-result - name: Test visuals (linux & mac) continue-on-error: true - working-directory: build/${{ inputs.cmake-preset }}/out + working-directory: build/out shell: "bash" if: runner.os != 'Windows' run: | @@ -45,7 +45,7 @@ runs: fi - name: Pack visual test results - working-directory: build/${{ inputs.cmake-preset }}/out + working-directory: build/out shell: "pwsh" run: tar cfvz visual-test-results.tar.gz ./visual-test-result @@ -60,16 +60,16 @@ runs: uses: actions/upload-artifact@v3 with: name: ${{ inputs.cmake-preset }}-visual-tests-${{ steps.run-guid.outputs.GUID }} - path: build/${{ inputs.cmake-preset }}/out/visual-test-results.tar.gz + path: build/out/visual-test-results.tar.gz - name: Run Benchmarks - working-directory: build/${{ inputs.cmake-preset }}/out + working-directory: build/out if: runner.os != 'Windows' shell: "pwsh" run: ./run_benchmarks - name: Collect coverage (linux & macos) - working-directory: build/${{ inputs.cmake-preset }} + working-directory: build if: runner.os != 'Windows' shell: "bash" run: | @@ -81,10 +81,10 @@ runs: if: runner.os != 'Windows' uses: codecov/codecov-action@v3 with: - files: build/${{ inputs.cmake-preset }}/coverage.info + files: build/coverage.info - name: Upload coverage to Codecov (windows) if: runner.os == 'Windows' uses: codecov/codecov-action@v3 with: - files: build/${{ inputs.cmake-preset }}/out/mapnik-test-visual.cov + files: build/out/mapnik-test-visual.cov diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 8fda668c2..8186fbfbb 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -32,6 +32,7 @@ jobs: matrix: os: [macos-latest, windows-latest, ubuntu-latest] memory-mapped: ["OFF", "ON"] + static-build: ["OFF", "ON"] include: - os: ubuntu-latest mono: mono @@ -82,7 +83,7 @@ jobs: echo "PRESET=${{ steps.lc_platform.outputs.lowercase }}-ci" >>${GITHUB_ENV} - name: Configure CMake - run: cmake -DUSE_MEMORY_MAPPED_FILE=${{ matrix.memory-mapped }} --preset ${{ env.PRESET }} + run: cmake -DUSE_MEMORY_MAPPED_FILE=${{ matrix.memory-mapped }} -DBUILD_SHARED_LIBS=${{ matrix.static-build }} --preset ${{ env.PRESET }} - name: Build run: cmake --build --preset ${{ env.PRESET }} diff --git a/CHANGELOG.md b/CHANGELOG.md index 3475adb4a..f9a8f330f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,7 @@ For a complete change history, see the git log. #### Breaking Changes - Reworked datasource plugin system. Plugins now need to implement a class with the macros in `datasource_plugin.hpp` ([#4291](https://github.com/mapnik/mapnik/pull/4291)) -- mapnik now has a global `mapnik::setup()` method which have to be called before any other functions of mapnik. Defined in `mapnik.hpp`. Note: In order not to insert this change into every code base, it is currently still called during the dynamic initialisation time. However, if mapnik is compiled statically, this function must be called. ([#4291](https://github.com/mapnik/mapnik/pull/4291)) +- mapnik now has a global `mapnik::setup()` method which have to be called before any other functions of mapnik. Defined in `mapnik.hpp`. Currently there is a auto setup functionality. It can be disabled using the cmake option `DISABLE_MAPNIK_AUTOSETUP=ON`. Note: In order not to insert this change into every code base, it is currently still called during the dynamic initialisation time. However, if mapnik is compiled statically, this function must be called. ([#4291](https://github.com/mapnik/mapnik/pull/4291)) #### Core diff --git a/CMakeLists.txt b/CMakeLists.txt index f21e36748..31510c913 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ 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(DISABLE_MAPNIK_AUTOSETUP "disables the autosetup. Need to call mapnik::setup() then" 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) @@ -361,6 +363,10 @@ if(NOT BUILD_SHARED_LIBS) list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_STATIC_DEFINE) endif() +if(DISABLE_MAPNIK_AUTOSETUP) + list(APPEND MAPNIK_COMPILE_DEFS MAPNIK_DISABLE_AUTOSETUP) +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( diff --git a/CMakePresets.json b/CMakePresets.json index f0bbb21a6..bc5a7c995 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -17,7 +17,7 @@ { "name": "default-build-dir", "hidden": true, - "binaryDir": "${sourceDir}/build/${presetName}" + "binaryDir": "${sourceDir}/build" }, { "name": "debug-build", @@ -180,8 +180,9 @@ "cacheVariables": { "BUILD_TESTING": "ON", "BUILD_DEMO_VIEWER": "OFF", - "CMAKE_TOOLCHAIN_FILE": "vcpkg/scripts/buildsystems/vcpkg.cmake" - } + "DISABLE_MAPNIK_AUTOSETUP": "ON" + }, + "toolchainFile": "vcpkg/scripts/buildsystems/vcpkg.cmake" }, { "name": "windows-ci", @@ -192,10 +193,10 @@ ], "cacheVariables": { "INSTALL_DEPENDENCIES": "ON", - "ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/bin" + "ADDITIONAL_LIBARIES_PATHS": "${sourceDir}/build/vcpkg_installed/x64-windows/bin" }, "environment": { - "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-windows/share/proj" + "PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-windows/share/proj" } }, { @@ -210,7 +211,7 @@ "CMAKE_CXX_FLAGS": "--coverage" }, "environment": { - "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-linux/share/proj" + "PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-linux/share/proj" } }, { @@ -239,7 +240,7 @@ "CMAKE_CXX_FLAGS": "-fprofile-arcs -ftest-coverage" }, "environment": { - "PROJ_LIB": "${sourceDir}/build/${presetName}/vcpkg_installed/x64-osx/share/proj" + "PROJ_LIB": "${sourceDir}/build/vcpkg_installed/x64-osx/share/proj" } } ], diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt index 2aa5a4359..822fe56a7 100644 --- a/benchmark/CMakeLists.txt +++ b/benchmark/CMakeLists.txt @@ -31,7 +31,11 @@ function(mapnik_create_benchmark) set(TARGET_NAME "mapnik-benchmark-${BENCHNAME}") add_executable(${TARGET_NAME} ${ARGV0}) target_include_directories(${TARGET_NAME} PRIVATE include) - target_link_libraries(${TARGET_NAME} PRIVATE mapnik::agg mapnik::mapnik) + target_link_libraries(${TARGET_NAME} PRIVATE + mapnik::agg + mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) + ) set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "${BENCHNAME}" ) diff --git a/benchmark/src/test_png_encoding2.cpp b/benchmark/src/test_png_encoding2.cpp index 19897d180..5791b139c 100644 --- a/benchmark/src/test_png_encoding2.cpp +++ b/benchmark/src/test_png_encoding2.cpp @@ -1,5 +1,6 @@ #include "bench_framework.hpp" #include "compare_images.hpp" +#include class test : public benchmark::test_case { diff --git a/demo/c++/CMakeLists.txt b/demo/c++/CMakeLists.txt index 7d3095ed9..25bfd356d 100644 --- a/demo/c++/CMakeLists.txt +++ b/demo/c++/CMakeLists.txt @@ -1,2 +1,6 @@ add_executable(mapnik-demo rundemo.cpp) -target_link_libraries(mapnik-demo PRIVATE mapnik::agg mapnik::mapnik) +target_link_libraries(mapnik-demo PRIVATE + mapnik::agg + mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) +) diff --git a/demo/viewer/CMakeLists.txt b/demo/viewer/CMakeLists.txt index 6b0812ad5..89c0865cb 100644 --- a/demo/viewer/CMakeLists.txt +++ b/demo/viewer/CMakeLists.txt @@ -46,6 +46,7 @@ target_link_libraries(mapnik-viewer PRIVATE Qt${QT_VERSION_MAJOR}::Widgets mapnik::agg mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/viewer.ini diff --git a/include/mapnik/css/css_color_grammar_x3_def.hpp b/include/mapnik/css/css_color_grammar_x3_def.hpp index 2b07f0dea..eec9abae3 100644 --- a/include/mapnik/css/css_color_grammar_x3_def.hpp +++ b/include/mapnik/css/css_color_grammar_x3_def.hpp @@ -48,11 +48,9 @@ namespace css_color_grammar { using x3::attr; using x3::double_; -using x3::hex; using x3::lit; using x3::no_case; using x3::no_skip; -using x3::omit; using x3::symbols; using x3::uint_parser; @@ -214,11 +212,11 @@ struct named_colors_ : x3::symbols ; // clang-format on } -} named_colors; +} const named_colors; -x3::uint_parser hex2; -x3::uint_parser hex1; -x3::uint_parser dec3; +const x3::uint_parser hex2; +const x3::uint_parser hex1; +const x3::uint_parser dec3; // rules x3::rule const hex2_color("hex2_color"); @@ -245,67 +243,67 @@ struct percent_converter static std::uint8_t call(double val) { return safe_cast(std::lround((255.0 * val) / 100.0)); } }; -auto dec_red = [](auto& ctx) { +const auto dec_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx); }; -auto dec_green = [](auto& ctx) { +const auto dec_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx); }; -auto dec_blue = [](auto& ctx) { +const auto dec_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx); }; -auto opacity = [](auto& ctx) { +const auto opacity = [](auto& ctx) { _val(ctx).alpha_ = uint8_t((255.0 * clip_opacity::call(_attr(ctx))) + 0.5); }; -auto percent_red = [](auto& ctx) { +const auto percent_red = [](auto& ctx) { _val(ctx).red_ = percent_converter::call(_attr(ctx)); }; -auto percent_green = [](auto& ctx) { +const auto percent_green = [](auto& ctx) { _val(ctx).green_ = percent_converter::call(_attr(ctx)); }; -auto percent_blue = [](auto& ctx) { +const auto percent_blue = [](auto& ctx) { _val(ctx).blue_ = percent_converter::call(_attr(ctx)); }; -auto hex1_red = [](auto& ctx) { +const auto hex1_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_green = [](auto& ctx) { +const auto hex1_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_blue = [](auto& ctx) { +const auto hex1_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex1_opacity = [](auto& ctx) { +const auto hex1_opacity = [](auto& ctx) { _val(ctx).alpha_ = _attr(ctx) | _attr(ctx) << 4; }; -auto hex2_red = [](auto& ctx) { +const auto hex2_red = [](auto& ctx) { _val(ctx).red_ = _attr(ctx); }; -auto hex2_green = [](auto& ctx) { +const auto hex2_green = [](auto& ctx) { _val(ctx).green_ = _attr(ctx); }; -auto hex2_blue = [](auto& ctx) { +const auto hex2_blue = [](auto& ctx) { _val(ctx).blue_ = _attr(ctx); }; -auto hex2_opacity = [](auto& ctx) { +const auto hex2_opacity = [](auto& ctx) { _val(ctx).alpha_ = _attr(ctx); }; -auto hsl_to_rgba = [](auto& ctx) { +const auto hsl_to_rgba = [](auto& ctx) { double h = std::get<0>(_attr(ctx)); double s = std::get<1>(_attr(ctx)); double l = std::get<2>(_attr(ctx)); @@ -325,10 +323,10 @@ auto hsl_to_rgba = [](auto& ctx) { } m1 = l * 2 - m2; - double r = hue_to_rgb(m1, m2, h + 1.0 / 3.0); - double g = hue_to_rgb(m1, m2, h); - double b = hue_to_rgb(m1, m2, h - 1.0 / 3.0); - uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5); + const double r = hue_to_rgb(m1, m2, h + 1.0 / 3.0); + const double g = hue_to_rgb(m1, m2, h); + const double b = hue_to_rgb(m1, m2, h - 1.0 / 3.0); + const uint8_t alpha = uint8_t((255.0 * clip_opacity::call(std::get<3>(_attr(ctx)))) + 0.5); _val(ctx) = color(safe_cast(std::lround(255.0 * r)), safe_cast(std::lround(255.0 * g)), safe_cast(std::lround(255.0 * b)), diff --git a/include/mapnik/css/css_grammar_x3_def.hpp b/include/mapnik/css/css_grammar_x3_def.hpp index a4f533c47..2e18c9fb7 100644 --- a/include/mapnik/css/css_grammar_x3_def.hpp +++ b/include/mapnik/css/css_grammar_x3_def.hpp @@ -150,32 +150,27 @@ namespace css_grammar { using x3::alnum; using x3::alpha; -using x3::attr; using x3::char_; using x3::lexeme; using x3::lit; -using x3::no_case; -using x3::no_skip; using x3::raw; using x3::standard::space; // import unicode string rule -namespace { -auto const& css_string = mapnik::json::grammar::unicode_string; -} +const auto css_string = mapnik::json::grammar::unicode_string; -auto assign_def = [](auto const& ctx) { +const auto assign_def = [](auto const& ctx) { for (auto const& k : std::get<0>(_attr(ctx))) { _val(ctx).emplace(k, std::get<1>(_attr(ctx))); } }; -auto assign_key = [](auto const& ctx) { +const auto assign_key = [](auto const& ctx) { _val(ctx).first = std::move(_attr(ctx)); }; -auto assign_value = [](auto const& ctx) { +const auto assign_value = [](auto const& ctx) { _val(ctx).second = std::move(_attr(ctx)); }; diff --git a/include/mapnik/csv/csv_grammar_x3_def.hpp b/include/mapnik/csv/csv_grammar_x3_def.hpp index 8b0f4adbe..1d9a20135 100644 --- a/include/mapnik/csv/csv_grammar_x3_def.hpp +++ b/include/mapnik/csv/csv_grammar_x3_def.hpp @@ -56,7 +56,7 @@ struct unesc_char_csv_ : x3::symbols ("\"\"", '\"') // double quote ; } -} unesc_char_csv; +} const unesc_char_csv; template struct literal : x3::parser> diff --git a/include/mapnik/expression_grammar_x3_def.hpp b/include/mapnik/expression_grammar_x3_def.hpp index 9b6d28f74..56ab3e348 100644 --- a/include/mapnik/expression_grammar_x3_def.hpp +++ b/include/mapnik/expression_grammar_x3_def.hpp @@ -51,23 +51,17 @@ namespace grammar { namespace x3 = boost::spirit::x3; namespace ascii = boost::spirit::x3::ascii; using ascii::char_; -using ascii::string; using x3::_attr; using x3::_val; using x3::alnum; using x3::alpha; -using x3::bool_; -using x3::double_; -using x3::int_; using x3::lexeme; using x3::lit; using x3::no_case; using x3::no_skip; x3::uint_parser const hex2{}; -namespace { -auto const& escaped_unicode = json::grammar::escaped_unicode; -} +const auto escaped_unicode = json::grammar::escaped_unicode; template inline mapnik::transcoder const& extract_transcoder(Context const& ctx) @@ -75,19 +69,19 @@ inline mapnik::transcoder const& extract_transcoder(Context const& ctx) return x3::get(ctx); } -auto append = [](auto const& ctx) { +const auto append = [](auto const& ctx) { _val(ctx) += _attr(ctx); }; -auto do_assign = [](auto const& ctx) { +const auto do_assign = [](auto const& ctx) { _val(ctx) = std::move(_attr(ctx)); }; -auto do_negate = [](auto const& ctx) { +const auto do_negate = [](auto const& ctx) { _val(ctx) = std::move(unary_node(_attr(ctx))); }; -auto do_attribute = [](auto const& ctx) { +const auto do_attribute = [](auto const& ctx) { auto const& attr = _attr(ctx); if (attr == "mapnik::geometry_type") { @@ -99,84 +93,84 @@ auto do_attribute = [](auto const& ctx) { } }; -auto do_global_attribute = [](auto const& ctx) { +const auto do_global_attribute = [](auto const& ctx) { _val(ctx) = std::move(global_attribute(_attr(ctx))); }; -auto do_add = [](auto const& ctx) { +const auto do_add = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_subt = [](auto const& ctx) { +const auto do_subt = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_mult = [](auto const& ctx) { +const auto do_mult = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_div = [](auto const& ctx) { +const auto do_div = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_mod = [](auto const& ctx) { +const auto do_mod = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_unicode = [](auto const& ctx) { +const auto do_unicode = [](auto const& ctx) { auto const& tr = extract_transcoder(ctx); _val(ctx) = std::move(tr.transcode(_attr(ctx).c_str())); }; -auto do_null = [](auto const& ctx) { +const auto do_null = [](auto const& ctx) { _val(ctx) = std::move(mapnik::value_null()); }; -auto do_not = [](auto const& ctx) { +const auto do_not = [](auto const& ctx) { mapnik::unary_node node(_attr(ctx)); _val(ctx) = std::move(node); }; -auto do_and = [](auto const& ctx) { +const auto do_and = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_or = [](auto const& ctx) { +const auto do_or = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_equal = [](auto const& ctx) { +const auto do_equal = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_not_equal = [](auto const& ctx) { +const auto do_not_equal = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_less = [](auto const& ctx) { +const auto do_less = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_less_equal = [](auto const& ctx) { +const auto do_less_equal = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_greater = [](auto const& ctx) { +const auto do_greater = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_greater_equal = [](auto const& ctx) { +const auto do_greater_equal = [](auto const& ctx) { _val(ctx) = std::move(mapnik::binary_node(std::move(_val(ctx)), std::move(_attr(ctx)))); }; // regex -auto do_regex_match = [](auto const& ctx) { +const auto do_regex_match = [](auto const& ctx) { auto const& tr = extract_transcoder(ctx); _val(ctx) = std::move(mapnik::regex_match_node(tr, std::move(_val(ctx)), std::move(_attr(ctx)))); }; -auto do_regex_replace = [](auto const& ctx) { +const auto do_regex_replace = [](auto const& ctx) { auto const& tr = extract_transcoder(ctx); auto const& pair = _attr(ctx); auto const& pattern = std::get<0>(pair); @@ -197,7 +191,7 @@ struct boolean_ : x3::symbols ("false", false) // ; } -} boolean; +} const boolean; struct floating_point_constants : x3::symbols { @@ -208,7 +202,7 @@ struct floating_point_constants : x3::symbols ("rad_to_deg", 57.295779513082320876798154814105) // ; } -} float_const; +} const float_const; // unary functions struct unary_function_types_ : x3::symbols @@ -225,7 +219,7 @@ struct unary_function_types_ : x3::symbols ("length", length_impl()) // ; } -} unary_func_types; +} const unary_func_types; // binary functions @@ -238,7 +232,7 @@ struct binary_function_types_ : x3::symbols ("pow", binary_function_impl(pow_impl)) // ; } -} binary_func_types; +} const binary_func_types; // geometry types struct geometry_types_ : x3::symbols @@ -251,7 +245,7 @@ struct geometry_types_ : x3::symbols ("collection", 4) // ; } -} geometry_type; +} const geometry_type; struct unesc_chars_ : x3::symbols { @@ -269,7 +263,7 @@ struct unesc_chars_ : x3::symbols ("\\\"", '\"') // ; } -} unesc_char; +} const unesc_char; // rules x3::rule const logical_expression("logical expression"); diff --git a/include/mapnik/image_filter_grammar_x3_def.hpp b/include/mapnik/image_filter_grammar_x3_def.hpp index b51a40801..ecbf9826f 100644 --- a/include/mapnik/image_filter_grammar_x3_def.hpp +++ b/include/mapnik/image_filter_grammar_x3_def.hpp @@ -57,41 +57,35 @@ namespace x3 = boost::spirit::x3; namespace image_filter { -using x3::attr; -using x3::char_; using x3::double_; -using x3::hex; using x3::lit; -using x3::no_case; -using x3::no_skip; -using x3::omit; using x3::symbols; using x3::uint_parser; -auto push_back = [](auto& ctx) { +const auto push_back = [](auto& ctx) { _val(ctx).push_back(_attr(ctx)); }; -auto set_rx_ry = [](auto& ctx) { +const auto set_rx_ry = [](auto& ctx) { _val(ctx).rx = _val(ctx).ry = _attr(ctx); }; -auto set_ry = [](auto& ctx) { +const auto set_ry = [](auto& ctx) { _val(ctx).ry = _attr(ctx); }; -auto offset_value = [](auto& ctx) { +const auto offset_value = [](auto& ctx) { _val(ctx) = _attr(ctx); }; -auto percent = [](auto& ctx) { +const auto percent = [](auto& ctx) { double val = std::abs(_val(ctx) / 100.0); if (val > 1.0) val = 1.0; _val(ctx) = val; }; -x3::uint_parser radius; +const x3::uint_parser radius; // Import the expression rule namespace { diff --git a/include/mapnik/json/feature_grammar_x3_def.hpp b/include/mapnik/json/feature_grammar_x3_def.hpp index ac5ad68fe..a3b518928 100644 --- a/include/mapnik/json/feature_grammar_x3_def.hpp +++ b/include/mapnik/json/feature_grammar_x3_def.hpp @@ -154,14 +154,14 @@ struct geometry_type_ : x3::symbols ("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) // ; } -} geometry_type_symbols; +} const geometry_type_symbols; namespace { -auto assign_name = [](auto const& ctx) { +const auto assign_name = [](auto const& ctx) { std::get<0>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_value = [](auto const& ctx) { +const auto assign_value = [](auto const& ctx) { std::get<1>(_val(ctx)) = std::move(_attr(ctx)); }; @@ -207,7 +207,7 @@ auto const assign_collection = [](auto const& ctx) { std::get<2>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_property = [](auto const& ctx) { +const auto assign_property = [](auto const& ctx) { mapnik::feature_impl& feature = x3::get(ctx); mapnik::transcoder const& tr = x3::get(ctx); feature.put_new(std::get<0>(_attr(ctx)), diff --git a/include/mapnik/json/generic_json_grammar_x3_def.hpp b/include/mapnik/json/generic_json_grammar_x3_def.hpp index dcd1cd9be..ca7801b86 100644 --- a/include/mapnik/json/generic_json_grammar_x3_def.hpp +++ b/include/mapnik/json/generic_json_grammar_x3_def.hpp @@ -35,39 +35,36 @@ namespace x3 = boost::spirit::x3; namespace { -auto make_null = [](auto const& ctx) { +const auto make_null = [](auto const& ctx) { _val(ctx) = mapnik::value_null{}; }; -auto make_true = [](auto const& ctx) { +const auto make_true = [](auto const& ctx) { _val(ctx) = true; }; -auto make_false = [](auto const& ctx) { +const auto make_false = [](auto const& ctx) { _val(ctx) = false; }; -auto assign = [](auto const& ctx) { +const auto assign = [](auto const& ctx) { _val(ctx) = std::move(_attr(ctx)); }; -auto assign_key = [](auto const& ctx) { +const auto assign_key = [](auto const& ctx) { std::get<0>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_value = [](auto const& ctx) { +const auto assign_value = [](auto const& ctx) { std::get<1>(_val(ctx)) = std::move(_attr(ctx)); }; } // namespace using x3::lit; -using x3::string; // import unicode string rule -namespace { -auto const& json_string = mapnik::json::grammar::unicode_string; -} +const auto json_string = mapnik::json::grammar::unicode_string; // rules x3::rule const object("JSON Object"); diff --git a/include/mapnik/json/geojson_grammar_x3_def.hpp b/include/mapnik/json/geojson_grammar_x3_def.hpp index 2fab6b902..db3257a48 100644 --- a/include/mapnik/json/geojson_grammar_x3_def.hpp +++ b/include/mapnik/json/geojson_grammar_x3_def.hpp @@ -35,30 +35,30 @@ namespace grammar { namespace x3 = boost::spirit::x3; -auto make_null = [](auto const& ctx) { +const auto make_null = [](auto const& ctx) { _val(ctx) = mapnik::value_null{}; }; -auto make_true = [](auto const& ctx) { +const auto make_true = [](auto const& ctx) { _val(ctx) = true; }; -auto make_false = [](auto const& ctx) { +const auto make_false = [](auto const& ctx) { _val(ctx) = false; }; -auto assign = [](auto const& ctx) { +const auto assign = [](auto const& ctx) { _val(ctx) = std::move(_attr(ctx)); }; -auto assign_key = [](auto const& ctx) { +const auto assign_key = [](auto const& ctx) { std::string const& name = _attr(ctx); keys_map& keys = x3::get(ctx); auto result = keys.insert(keys_map::value_type(name, keys.size() + 1)); std::get<0>(_val(ctx)) = result.first->right; }; -auto assign_value = [](auto const& ctx) { +const auto assign_value = [](auto const& ctx) { std::get<1>(_val(ctx)) = std::move(_attr(ctx)); }; @@ -81,7 +81,7 @@ struct geometry_type_ : x3::symbols ("\"GeometryCollection\"", mapnik::geometry::geometry_types::GeometryCollection) // ; } -} geometry_type_sym; +} const geometry_type_sym; // rules x3::rule const object("JSON Object"); @@ -95,13 +95,9 @@ auto const geojson_double = x3::real_parser(); // import unicode string rule -namespace { -auto const& geojson_string = unicode_string; -} +const auto geojson_string = unicode_string; // import positions rule -namespace { -auto const& positions_rule = positions; -} +const auto positions_rule = positions; // GeoJSON types // clang-format off diff --git a/include/mapnik/json/positions_grammar_x3_def.hpp b/include/mapnik/json/positions_grammar_x3_def.hpp index da9ab75d5..e4399d759 100644 --- a/include/mapnik/json/positions_grammar_x3_def.hpp +++ b/include/mapnik/json/positions_grammar_x3_def.hpp @@ -33,14 +33,11 @@ namespace grammar { namespace x3 = boost::spirit::x3; using x3::double_; using x3::lit; -using x3::no_case; using x3::omit; -namespace { -auto assign_helper = [](auto const& ctx) { +const auto assign_helper = [](auto const& ctx) { _val(ctx) = std::move(_attr(ctx)); }; -} // namespace // rules x3::rule const point("Position"); diff --git a/include/mapnik/json/topojson_grammar_x3_def.hpp b/include/mapnik/json/topojson_grammar_x3_def.hpp index 6a4d02026..40b083915 100644 --- a/include/mapnik/json/topojson_grammar_x3_def.hpp +++ b/include/mapnik/json/topojson_grammar_x3_def.hpp @@ -169,7 +169,7 @@ struct create_multi_polygon } }; -auto create_geometry = [](auto const& ctx) { +const auto create_geometry = [](auto const& ctx) { auto const geom_type = std::get<0>(_attr(ctx)); auto const& coord = std::get<1>(_attr(ctx)); auto const& arcs = std::get<2>(_attr(ctx)); @@ -199,27 +199,27 @@ auto create_geometry = [](auto const& ctx) { _val(ctx) = std::move(geom); }; -auto assign_bbox = [](auto const& ctx) { +const auto assign_bbox = [](auto const& ctx) { _val(ctx).bbox = std::move(_attr(ctx)); }; -auto assign_transform = [](auto const& ctx) { +const auto assign_transform = [](auto const& ctx) { _val(ctx).tr = std::move(_attr(ctx)); }; -auto assign_arcs = [](auto const& ctx) { +const auto assign_arcs = [](auto const& ctx) { _val(ctx).arcs = std::move(_attr(ctx)); }; -auto assign_objects = [](auto const& ctx) { +const auto assign_objects = [](auto const& ctx) { _val(ctx).geometries = std::move(_attr(ctx)); }; -auto push_geometry = [](auto const& ctx) { +const auto push_geometry = [](auto const& ctx) { _val(ctx).push_back(std::move(_attr(ctx))); }; -auto push_collection = [](auto const& ctx) { +const auto push_collection = [](auto const& ctx) { auto& dest = _val(ctx); auto& src = _attr(ctx); if (dest.empty()) @@ -231,27 +231,27 @@ auto push_collection = [](auto const& ctx) { } }; -auto assign_geometry_type = [](auto const& ctx) { +const auto assign_geometry_type = [](auto const& ctx) { std::get<0>(_val(ctx)) = _attr(ctx); }; -auto assign_coordinates = [](auto const& ctx) { +const auto assign_coordinates = [](auto const& ctx) { std::get<1>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_rings = [](auto const& ctx) { +const auto assign_rings = [](auto const& ctx) { std::get<2>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_properties = [](auto const& ctx) { +const auto assign_properties = [](auto const& ctx) { std::get<3>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_prop_name = [](auto const& ctx) { +const auto assign_prop_name = [](auto const& ctx) { std::get<0>(_val(ctx)) = std::move(_attr(ctx)); }; -auto assign_prop_value = [](auto const& ctx) { +const auto assign_prop_value = [](auto const& ctx) { std::get<1>(_val(ctx)) = std::move(_attr(ctx)); }; @@ -262,12 +262,10 @@ using x3::int_; using x3::lit; using x3::omit; -namespace { // import unicode string rule -auto const& json_string = json::grammar::unicode_string; +const auto json_string = json::grammar::unicode_string; // json value -auto const& json_value = json::grammar::value; -} // namespace +const auto json_value = json::grammar::value; using coordinates_type = util::variant>; using arcs_type = util::variant, @@ -287,7 +285,7 @@ struct topojson_geometry_type_ : x3::symbols ("\"MultiPolygon\"", 6) // ; } -} topojson_geometry_type; +} const topojson_geometry_type; // rules x3::rule const transform = "Transform"; diff --git a/include/mapnik/json/unicode_string_grammar_x3_def.hpp b/include/mapnik/json/unicode_string_grammar_x3_def.hpp index 6a8c77eb1..cbd854532 100644 --- a/include/mapnik/json/unicode_string_grammar_x3_def.hpp +++ b/include/mapnik/json/unicode_string_grammar_x3_def.hpp @@ -35,7 +35,7 @@ namespace x3 = boost::spirit::x3; using uchar = std::uint32_t; // a unicode code point -auto append = [](auto const& ctx) { +const auto append = [](auto const& ctx) { _val(ctx) += _attr(ctx); }; @@ -50,15 +50,15 @@ static inline void push_utf8_impl(std::string& str, uchar code_point) } } // namespace detail -auto push_char = [](auto const& ctx) { +const auto push_char = [](auto const& ctx) { _val(ctx).push_back(_attr(ctx)); }; -auto push_utf8 = [](auto const& ctx) { +const auto push_utf8 = [](auto const& ctx) { detail::push_utf8_impl(_val(ctx), _attr(ctx)); }; -auto push_utf16 = [](auto const& ctx) { +const auto push_utf16 = [](auto const& ctx) { using iterator_type = std::vector::const_iterator; auto const& utf16 = _attr(ctx); try @@ -76,7 +76,7 @@ auto push_utf16 = [](auto const& ctx) { } }; -auto push_esc = [](auto const& ctx) { +const auto push_esc = [](auto const& ctx) { std::string& utf8 = _val(ctx); char c = _attr(ctx); switch (c) diff --git a/include/mapnik/path_expression_grammar_x3_def.hpp b/include/mapnik/path_expression_grammar_x3_def.hpp index f137868f3..3600fa986 100644 --- a/include/mapnik/path_expression_grammar_x3_def.hpp +++ b/include/mapnik/path_expression_grammar_x3_def.hpp @@ -32,10 +32,10 @@ namespace grammar { namespace x3 = boost::spirit::x3; using x3::lexeme; using x3::standard_wide::char_; -auto create_string = [](auto& ctx) { +const auto create_string = [](auto& ctx) { _val(ctx).push_back(_attr(ctx)); }; -auto create_attribute = [](auto& ctx) { +const auto create_attribute = [](auto& ctx) { _val(ctx).push_back(mapnik::attribute(_attr(ctx))); }; // rules diff --git a/include/mapnik/wkt/wkt_grammar_x3_def.hpp b/include/mapnik/wkt/wkt_grammar_x3_def.hpp index 40302fb7f..3af4dcbd4 100644 --- a/include/mapnik/wkt/wkt_grammar_x3_def.hpp +++ b/include/mapnik/wkt/wkt_grammar_x3_def.hpp @@ -47,17 +47,16 @@ namespace mapnik { namespace grammar { namespace x3 = boost::spirit::x3; -namespace ascii = boost::spirit::x3::ascii; using x3::double_; using x3::lit; using x3::no_case; // functors -auto make_empty = [](auto const& ctx) { +const auto make_empty = [](auto const& ctx) { _val(ctx) = geometry::geometry_empty(); }; -auto add_ring = [](auto const& ctx) { +const auto add_ring = [](auto const& ctx) { auto& ring = reinterpret_cast&>(_attr(ctx)); _val(ctx).push_back(std::move(ring)); }; diff --git a/src/mapnik.cpp b/src/mapnik.cpp index c36c083e4..11406cd69 100644 --- a/src/mapnik.cpp +++ b/src/mapnik.cpp @@ -40,7 +40,8 @@ void register_image_readers() } } // namespace mapnik -#if !defined(MAPNIK_STATIC_PLUGINS) || !defined(_WIN32) +// only on other systems then windows and in shared builds +#if !defined(MAPNIK_DISABLE_AUTOSETUP) && MAPNIK_STATIC_PLUGINS == 0 && !defined(_WIN32) namespace { class AutoSetup final { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 2e817e9fe..f275df53f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -108,6 +108,7 @@ target_link_libraries(mapnik-test-unit PUBLIC mapnik::json mapnik::wkt PostgreSQL::PostgreSQL + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) # workaround since the "offical" include dir would be file(COPY catch_ext.hpp DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") @@ -120,6 +121,7 @@ target_link_libraries(agg_rasterizer_integer_overflow_test PUBLIC mapnik::mapnik mapnik::agg mapnik::json + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) target_include_directories(agg_rasterizer_integer_overflow_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}") @@ -128,6 +130,7 @@ target_link_libraries(datasource_registration_test PUBLIC Catch2::Catch2 mapnik::mapnik mapnik::agg + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) target_include_directories(datasource_registration_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}") @@ -137,6 +140,7 @@ target_link_libraries(font_registration_test PUBLIC mapnik::mapnik mapnik::agg mapnik::json + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) target_include_directories(font_registration_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}") @@ -146,6 +150,7 @@ target_link_libraries(map_xml_test PUBLIC mapnik::mapnik mapnik::agg mapnik::json + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) target_include_directories(map_xml_test PRIVATE "${Catch2_SOURCE_DIR}/single_include/catch2" "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/test/standalone/map_xml_test.cpp b/test/standalone/map_xml_test.cpp index d0ce7cb11..71c37cc76 100644 --- a/test/standalone/map_xml_test.cpp +++ b/test/standalone/map_xml_test.cpp @@ -138,15 +138,17 @@ void load_map(mapnik::Map& m, bfs::path const& path) } } // anonymous namespace - +#ifndef MAPNIK_STATIC_PLUGINS const bool registered = mapnik::datasource_cache::instance().register_datasources((bfs::path("plugins") / "input").generic_string()); - +#endif TEST_CASE("map xml I/O") { mapnik::setup(); +#ifndef MAPNIK_STATIC_PLUGINS // make sure plugins are loaded REQUIRE(registered); +#endif // make the tests silent since we intentially test error conditions that are noisy auto const severity = mapnik::logger::instance().get_severity(); diff --git a/test/visual/CMakeLists.txt b/test/visual/CMakeLists.txt index ee299bdfc..0c0c306fc 100644 --- a/test/visual/CMakeLists.txt +++ b/test/visual/CMakeLists.txt @@ -10,6 +10,7 @@ target_link_libraries(mapnik-test-visual PRIVATE Boost::filesystem mapnik::mapnik mapnik::agg + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) # needed for cleanup.hpp target_include_directories(mapnik-test-visual PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..") diff --git a/utils/geometry_to_wkb/CMakeLists.txt b/utils/geometry_to_wkb/CMakeLists.txt index b2bf944ec..96d888178 100644 --- a/utils/geometry_to_wkb/CMakeLists.txt +++ b/utils/geometry_to_wkb/CMakeLists.txt @@ -1,5 +1,8 @@ add_executable(geometry_to_wkb main.cpp) -target_link_libraries(geometry_to_wkb PRIVATE mapnik::mapnik) +target_link_libraries(geometry_to_wkb PRIVATE + mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) +) mapnik_install_utility(geometry_to_wkb) diff --git a/utils/mapnik-index/CMakeLists.txt b/utils/mapnik-index/CMakeLists.txt index ab466247a..111ac934e 100644 --- a/utils/mapnik-index/CMakeLists.txt +++ b/utils/mapnik-index/CMakeLists.txt @@ -11,6 +11,7 @@ target_link_libraries(mapnik-index PRIVATE mapnik::json mapnik::wkt Boost::program_options + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) mapnik_install_utility(mapnik-index) diff --git a/utils/mapnik-render/CMakeLists.txt b/utils/mapnik-render/CMakeLists.txt index 5f5544b9c..d148e36e5 100644 --- a/utils/mapnik-render/CMakeLists.txt +++ b/utils/mapnik-render/CMakeLists.txt @@ -5,6 +5,7 @@ add_executable(mapnik-render mapnik-render.cpp) target_link_libraries(mapnik-render PRIVATE mapnik::mapnik Boost::program_options + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) mapnik_install_utility(mapnik-render) diff --git a/utils/ogrindex/CMakeLists.txt b/utils/ogrindex/CMakeLists.txt index 92bc07350..fe9593137 100644 --- a/utils/ogrindex/CMakeLists.txt +++ b/utils/ogrindex/CMakeLists.txt @@ -1,5 +1,8 @@ add_executable(ogrindex ogrindex.cpp) -target_link_libraries(ogrindex PRIVATE mapnik::mapnik) +target_link_libraries(ogrindex PRIVATE + mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) +) mapnik_install_utility(ogrindex) diff --git a/utils/pgsql2sqlite/CMakeLists.txt b/utils/pgsql2sqlite/CMakeLists.txt index 4f5185a6f..3657b31ae 100644 --- a/utils/pgsql2sqlite/CMakeLists.txt +++ b/utils/pgsql2sqlite/CMakeLists.txt @@ -13,6 +13,7 @@ target_link_libraries(pgsql2sqlite PRIVATE PostgreSQL::PostgreSQL Boost::program_options mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) mapnik_install_utility(pgsql2sqlite) diff --git a/utils/shapeindex/CMakeLists.txt b/utils/shapeindex/CMakeLists.txt index 59187d5b0..e0e1d93d9 100644 --- a/utils/shapeindex/CMakeLists.txt +++ b/utils/shapeindex/CMakeLists.txt @@ -8,6 +8,7 @@ target_include_directories(shapeindex PRIVATE ../../plugins/input/shape) target_link_libraries(shapeindex PRIVATE Boost::program_options mapnik::mapnik + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) mapnik_install_utility(shapeindex) diff --git a/utils/svg2png/CMakeLists.txt b/utils/svg2png/CMakeLists.txt index 29cae3bf4..e2afca177 100644 --- a/utils/svg2png/CMakeLists.txt +++ b/utils/svg2png/CMakeLists.txt @@ -8,6 +8,7 @@ target_link_libraries(svg2png PRIVATE Boost::program_options mapnik::mapnik mapnik::agg + ICU::data ICU::i18n ICU::uc # needed for the static build (TODO: why isn't this correctly propagated from mapnik::mapnik?) ) mapnik_install_utility(svg2png)