From 34a2097bddc53eb134d71097f52fe6fd6e37d81f Mon Sep 17 00:00:00 2001 From: Bart Louwers Date: Wed, 27 Sep 2023 12:02:15 +0200 Subject: [PATCH] Update Boost to 1.83, replace Boost Locale with deprecated codecvt STL (#1660) Co-authored-by: mwilsnd --- .github/actionlint.yaml | 8 +++++ .github/workflows/android-ci.yml | 3 +- .github/workflows/linux-ci.yml | 3 +- .gitmodules | 6 ++-- BUILD.bazel | 36 +++++++++++----------- include/mbgl/gfx/renderer_backend.hpp | 2 +- include/mbgl/map/mode.hpp | 10 +++--- include/mbgl/util/bitmask_operations.hpp | 8 ++--- include/mbgl/util/convert.hpp | 4 +-- include/mbgl/util/util.hpp | 7 ----- platform/default/src/mbgl/util/utf.cpp | 16 ++++++++-- scripts/update-boost.sh | 21 ++----------- scripts/vendor/icu.sh | 25 +++------------ src/mbgl/annotation/annotation_manager.cpp | 2 +- src/mbgl/text/language_tag.cpp | 4 +-- src/mbgl/util/http_header.cpp | 4 +-- vendor/BUILD.bazel | 5 ++- vendor/boost | 2 +- 18 files changed, 72 insertions(+), 94 deletions(-) create mode 100644 .github/actionlint.yaml diff --git a/.github/actionlint.yaml b/.github/actionlint.yaml new file mode 100644 index 000000000..2ef1c46f4 --- /dev/null +++ b/.github/actionlint.yaml @@ -0,0 +1,8 @@ +self-hosted-runner: + # Labels of self-hosted runner in array of strings. + labels: + - MapLibre_Native_Linux_16_core +# Configuration variables in array of strings defined in your repository or +# organization. `null` means disabling configuration variables check. +# Empty array means no configuration variable is allowed. +config-variables: null diff --git a/.github/workflows/android-ci.yml b/.github/workflows/android-ci.yml index 83ee3c198..a9e03feca 100644 --- a/.github/workflows/android-ci.yml +++ b/.github/workflows/android-ci.yml @@ -44,8 +44,7 @@ jobs: "!**/*.md"] android-build: - runs-on: - group: maplibre-native + runs-on: MapLibre_Native_Linux_16_core needs: - pre_job if: needs.pre_job.outputs.should_skip != 'true' diff --git a/.github/workflows/linux-ci.yml b/.github/workflows/linux-ci.yml index 457e5a54f..7e136b531 100644 --- a/.github/workflows/linux-ci.yml +++ b/.github/workflows/linux-ci.yml @@ -46,8 +46,7 @@ jobs: fail-fast: false matrix: renderer: [legacy, drawable] - runs-on: - group: maplibre-native + runs-on: MapLibre_Native_Linux_16_core steps: - uses: actions/checkout@v4 with: diff --git a/.gitmodules b/.gitmodules index 9cf14d70e..c6895bebd 100644 --- a/.gitmodules +++ b/.gitmodules @@ -16,9 +16,6 @@ [submodule "vendor/unique_resource"] path = vendor/unique_resource url = https://github.com/okdshin/unique_resource.git -[submodule "vendor/boost"] - path = vendor/boost - url = https://github.com/maplibre/maplibre-gl-native-boost.git [submodule "vendor/benchmark"] path = vendor/benchmark url = https://github.com/google/benchmark.git @@ -49,3 +46,6 @@ [submodule "platform/windows/vendor/vcpkg"] path = platform/windows/vendor/vcpkg url = https://github.com/microsoft/vcpkg.git +[submodule "vendor/boost"] + path = vendor/boost + url = https://github.com/maplibre/maplibre-gl-native-boost.git diff --git a/BUILD.bazel b/BUILD.bazel index 383030a5d..5fed687fb 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -3,14 +3,14 @@ load( "//bazel:core.bzl", "MLN_CORE_HEADERS", "MLN_CORE_SOURCE", - "MLN_DRAWABLES_HEADERS", - "MLN_DRAWABLES_SOURCE", "MLN_DRAWABLES_GL_HEADERS", "MLN_DRAWABLES_GL_SOURCE", + "MLN_DRAWABLES_HEADERS", "MLN_DRAWABLES_MTL_HEADERS", "MLN_DRAWABLES_MTL_SOURCE", - "MLN_GENERATED_SHADER_HEADERS", + "MLN_DRAWABLES_SOURCE", "MLN_GENERATED_OPENGL_SHADER_HEADERS", + "MLN_GENERATED_SHADER_HEADERS", "MLN_GENERATED_STYLE_SOURCE", "MLN_OPENGL_HEADERS", "MLN_OPENGL_SOURCE", @@ -90,17 +90,17 @@ cc_library( name = "mbgl-core", srcs = MLN_CORE_SOURCE + MLN_GENERATED_STYLE_SOURCE + select({ - ":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE, - ":legacy_renderer": MLN_OPENGL_SOURCE, - ":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE, - "//conditions:default": [], - }), + ":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE, + ":legacy_renderer": MLN_OPENGL_SOURCE, + ":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE, + "//conditions:default": [], + }), hdrs = MLN_CORE_HEADERS + select({ - ":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS, - ":legacy_renderer": MLN_OPENGL_HEADERS, - ":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS, - "//conditions:default": [], - }), + ":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS, + ":legacy_renderer": MLN_OPENGL_HEADERS, + ":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS, + "//conditions:default": [], + }), copts = CPP_FLAGS + MAPLIBRE_FLAGS, defines = select({ ":legacy_renderer": [ @@ -209,11 +209,11 @@ config_setting( string_flag( name = "renderer", build_setting_default = "legacy", - values=[ + values = [ "legacy", "drawable", - "metal" - ] + "metal", + ], ) config_setting( @@ -233,8 +233,8 @@ config_setting( config_setting( name = "metal_renderer", flag_values = { - ":renderer": "metal" - } + ":renderer": "metal", + }, ) exports_files( diff --git a/include/mbgl/gfx/renderer_backend.hpp b/include/mbgl/gfx/renderer_backend.hpp index 9530d9069..5d8b74f00 100644 --- a/include/mbgl/gfx/renderer_backend.hpp +++ b/include/mbgl/gfx/renderer_backend.hpp @@ -74,7 +74,7 @@ protected: friend class BackendScope; }; -MBGL_CONSTEXPR bool operator==(const RendererBackend& a, const RendererBackend& b) { +constexpr bool operator==(const RendererBackend& a, const RendererBackend& b) { return &a == &b; } diff --git a/include/mbgl/map/mode.hpp b/include/mbgl/map/mode.hpp index b16026bd1..5835cf8df 100644 --- a/include/mbgl/map/mode.hpp +++ b/include/mbgl/map/mode.hpp @@ -45,23 +45,23 @@ enum class MapDebugOptions : EnumType { DepthBuffer = 1 << 7, }; -MBGL_CONSTEXPR MapDebugOptions operator|(MapDebugOptions lhs, MapDebugOptions rhs) { +constexpr MapDebugOptions operator|(MapDebugOptions lhs, MapDebugOptions rhs) { return MapDebugOptions(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs)); } -MBGL_CONSTEXPR MapDebugOptions& operator|=(MapDebugOptions& lhs, MapDebugOptions rhs) { +constexpr MapDebugOptions& operator|=(MapDebugOptions& lhs, MapDebugOptions rhs) { return (lhs = MapDebugOptions(mbgl::underlying_type(lhs) | mbgl::underlying_type(rhs))); } -MBGL_CONSTEXPR bool operator&(MapDebugOptions lhs, MapDebugOptions rhs) { +constexpr bool operator&(MapDebugOptions lhs, MapDebugOptions rhs) { return mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs); } -MBGL_CONSTEXPR MapDebugOptions& operator&=(MapDebugOptions& lhs, MapDebugOptions rhs) { +constexpr MapDebugOptions& operator&=(MapDebugOptions& lhs, MapDebugOptions rhs) { return (lhs = MapDebugOptions(mbgl::underlying_type(lhs) & mbgl::underlying_type(rhs))); } -MBGL_CONSTEXPR MapDebugOptions operator~(MapDebugOptions value) { +constexpr MapDebugOptions operator~(MapDebugOptions value) { return MapDebugOptions(~mbgl::underlying_type(value)); } diff --git a/include/mbgl/util/bitmask_operations.hpp b/include/mbgl/util/bitmask_operations.hpp index b22eb58c2..e2c64de8d 100644 --- a/include/mbgl/util/bitmask_operations.hpp +++ b/include/mbgl/util/bitmask_operations.hpp @@ -6,25 +6,25 @@ namespace mbgl { template -MBGL_CONSTEXPR Enum operator|(Enum a, Enum b) { +constexpr Enum operator|(Enum a, Enum b) { static_assert(std::is_enum::value, "Enum must be an enum type"); return Enum(mbgl::underlying_type(a) | mbgl::underlying_type(b)); } template -MBGL_CONSTEXPR Enum& operator|=(Enum& a, Enum b) { +constexpr Enum& operator|=(Enum& a, Enum b) { static_assert(std::is_enum::value, "Enum must be an enum type"); return (a = a | b); } template -MBGL_CONSTEXPR bool operator&(Enum a, Enum b) { +constexpr bool operator&(Enum a, Enum b) { static_assert(std::is_enum::value, "Enum must be an enum type"); return bool(mbgl::underlying_type(a) & mbgl::underlying_type(b)); } template -MBGL_CONSTEXPR Enum operator~(Enum value) { +constexpr Enum operator~(Enum value) { static_assert(std::is_enum::value, "Enum must be an enum type"); return Enum(~mbgl::underlying_type(value)); } diff --git a/include/mbgl/util/convert.hpp b/include/mbgl/util/convert.hpp index 8bda38143..1ddf5bc99 100644 --- a/include/mbgl/util/convert.hpp +++ b/include/mbgl/util/convert.hpp @@ -11,14 +11,14 @@ namespace mbgl { namespace util { template >> -MBGL_CONSTEXPR std::array convert(const std::array& from) { +constexpr std::array convert(const std::array& from) { std::array to{{}}; std::copy(std::begin(from), std::end(from), std::begin(to)); return to; } template >> -MBGL_CONSTEXPR std::array cast(const std::array& from) { +constexpr std::array cast(const std::array& from) { std::array to{{}}; std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast(x); }); return to; diff --git a/include/mbgl/util/util.hpp b/include/mbgl/util/util.hpp index 52d9ad85b..2ae898171 100644 --- a/include/mbgl/util/util.hpp +++ b/include/mbgl/util/util.hpp @@ -13,13 +13,6 @@ #endif -// GCC 4.9 compatibility -#if !defined(__GNUC__) || __GNUC__ >= 5 -#define MBGL_CONSTEXPR constexpr -#else -#define MBGL_CONSTEXPR inline -#endif - // Compiler defines for making symbols visible, otherwise they // will be defined as hidden by default. diff --git a/platform/default/src/mbgl/util/utf.cpp b/platform/default/src/mbgl/util/utf.cpp index f0f9d3e67..859cf9b12 100644 --- a/platform/default/src/mbgl/util/utf.cpp +++ b/platform/default/src/mbgl/util/utf.cpp @@ -1,17 +1,27 @@ #include -#include +#include +#include namespace mbgl { namespace util { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" + std::u16string convertUTF8ToUTF16(const std::string& str) { - return boost::locale::conv::utf_to_utf(str); + std::wstring_convert, char16_t> conv; + + return conv.from_bytes(str); } std::string convertUTF16ToUTF8(const std::u16string& str) { - return boost::locale::conv::utf_to_utf(str); + std::wstring_convert, char16_t> conv; + + return conv.to_bytes(str); } +#pragma GCC diagnostic pop + } // namespace util } // namespace mbgl diff --git a/scripts/update-boost.sh b/scripts/update-boost.sh index 2c411d9ea..68e39089c 100755 --- a/scripts/update-boost.sh +++ b/scripts/update-boost.sh @@ -2,30 +2,13 @@ set -eu -pushd "$BOOST" -if [ ! -f dist/bin/bcp ]; then - # Build bcp - ./bootstrap.sh - ./b2 tools/bcp -fi -popd - # Extract boost modules that we need rm -rf vendor/boost/include mkdir -p vendor/boost/include -"$BOOST/dist/bin/bcp" --boost="$BOOST" --scan $(find {src,include,test,platform,bin} -name "*.cpp" -o -name "*.hpp") vendor/boost/include +bcp --boost="$BOOST" --scan $(find {src,include,test,platform,bin,render-test} -name "*.cpp" -o -name "*.hpp") vendor/boost/include pushd vendor/boost VERSION=$(sed -n 's/^#define BOOST_LIB_VERSION "\([^"]*\)"$/\1/p' include/boost/version.hpp) -echo "libboost ${VERSION/_/.} for Mapbox GL Native" > README.md +echo "libboost ${VERSION/_/.} for MapLibre Native" > README.md git add README.md include popd - -echo "If everything works, run:" -echo "" -echo " git -C vendor/boost checkout main" -echo " git -C vendor/boost commit -m \"update boost to ${VERSION/_/.}\"" -echo " git -C vendor/boost push" -echo " git add vendor/boost" -echo "" -echo "and commit." diff --git a/scripts/vendor/icu.sh b/scripts/vendor/icu.sh index 7a2c63508..5a5c1e7c7 100755 --- a/scripts/vendor/icu.sh +++ b/scripts/vendor/icu.sh @@ -2,10 +2,11 @@ source "$(dirname "${BASH_SOURCE[0]}")/common.sh" NAME=icu -VERSION=61.1 +VERSION=73.2 ROOT=icu/source -download "http://download.icu-project.org/files/icu4c/$VERSION/icu4c-${VERSION//./_}-src.tgz" +VERSION_=${VERSION//./_} +download "https://github.com/unicode-org/icu/releases/download/release-${VERSION//./-}/icu4c-${VERSION_}-src.tgz" init STRIP_COMPONENTS=2 extract_gzip "${ROOT}/common/*.h" "${ROOT}/common/*.cpp" STRIP_COMPONENTS=1 extract_gzip "icu/LICENSE" @@ -33,7 +34,7 @@ FILES=( echo ">> Finding dependencies..." ALL=() for FILE in "${FILES[@]}"; do - ALL+=($(cd "common" && $CXX -std=c++14 -I. -c "$FILE" -M | sed -e 's/^[a-z0-9._-]*: *//;s/ *\\$//')) + ALL+=($(cd "common" && $CXX -std=c++17 -I. -c "$FILE" -M | sed -e 's/^[a-z0-9._-]*: *//;s/ *\\$//')) done # Remove duplicates @@ -49,24 +50,6 @@ for FILE in "${ALL[@]}"; do sed 's/^#include \"\(unicode\/[^\"]\{1,\}\)\"/#include <\1>/' "common/$FILE" > "$DIR/$FILE" done -# Apply patch from https://github.com/LibreOffice/core/blob/master/external/icu/icu4c-ubsan.patch.1 -# Shifting signed int to a number greater than can be represented is undefined behavior -patch -p0 << PATCH ---- src/ubidiimp.h -+++ src/ubidiimp.h -@@ -198,8 +198,8 @@ - /* in a Run, logicalStart will get this bit set if the run level is odd */ - #define INDEX_ODD_BIT (1UL<<31) - --#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((int32_t)(level)<<31)) -+#define MAKE_INDEX_ODD_PAIR(index, level) ((index)|((uint32_t)(level)<<31)) --#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((int32_t)(level)<<31)) -+#define ADD_ODD_BIT_FROM_LEVEL(x, level) ((x)|=((uint32_t)(level)<<31)) - #define REMOVE_ODD_BIT(x) ((x)&=~INDEX_ODD_BIT) - - #define GET_INDEX(x) ((x)&~INDEX_ODD_BIT) -PATCH - rm -rf common file_list include src -name "*.h" -o -name "*.cpp" diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index 1121a24ef..381680a9c 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include // Note: LayerManager::annotationsEnabled is defined // at compile time, so that linker (with LTO on) is able diff --git a/src/mbgl/text/language_tag.cpp b/src/mbgl/text/language_tag.cpp index 05851d18b..4fdd0c658 100644 --- a/src/mbgl/text/language_tag.cpp +++ b/src/mbgl/text/language_tag.cpp @@ -6,8 +6,8 @@ #endif #include -#include -#include +#include +#include #ifdef _MSC_VER #pragma warning(pop) diff --git a/src/mbgl/util/http_header.cpp b/src/mbgl/util/http_header.cpp index dbff7a275..ceb4bcf08 100644 --- a/src/mbgl/util/http_header.cpp +++ b/src/mbgl/util/http_header.cpp @@ -9,8 +9,8 @@ #endif #include -#include -#include +#include +#include #ifdef _MSC_VER #pragma warning(pop) diff --git a/vendor/BUILD.bazel b/vendor/BUILD.bazel index c950e3a3c..b822d9eea 100644 --- a/vendor/BUILD.bazel +++ b/vendor/BUILD.bazel @@ -178,7 +178,10 @@ cc_library( # vendor/metal-cpp.json cc_library( name = "metal-cpp", - hdrs = glob(["metal-cpp/**/*.hpp"], allow_empty = False), + hdrs = glob( + ["metal-cpp/**/*.hpp"], + allow_empty = False, + ), copts = CPP_FLAGS, includes = ["metal-cpp"], visibility = ["//visibility:public"], diff --git a/vendor/boost b/vendor/boost index 5140cf182..805bc2ee7 160000 --- a/vendor/boost +++ b/vendor/boost @@ -1 +1 @@ -Subproject commit 5140cf182b904138ba7f9848633fde9460df857a +Subproject commit 805bc2ee74cc06d7159ec9ac9bf56072c16a2389