Update Boost to 1.83, replace Boost Locale with deprecated codecvt STL (#1660)

Co-authored-by: mwilsnd <mwilsnd@gmail.com>
This commit is contained in:
Bart Louwers
2023-09-27 12:02:15 +02:00
committed by GitHub
parent ad6aac2930
commit 34a2097bdd
18 changed files with 72 additions and 94 deletions

8
.github/actionlint.yaml vendored Normal file
View File

@@ -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

View File

@@ -44,8 +44,7 @@ jobs:
"!**/*.md"] "!**/*.md"]
android-build: android-build:
runs-on: runs-on: MapLibre_Native_Linux_16_core
group: maplibre-native
needs: needs:
- pre_job - pre_job
if: needs.pre_job.outputs.should_skip != 'true' if: needs.pre_job.outputs.should_skip != 'true'

View File

@@ -46,8 +46,7 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
renderer: [legacy, drawable] renderer: [legacy, drawable]
runs-on: runs-on: MapLibre_Native_Linux_16_core
group: maplibre-native
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:

6
.gitmodules vendored
View File

@@ -16,9 +16,6 @@
[submodule "vendor/unique_resource"] [submodule "vendor/unique_resource"]
path = vendor/unique_resource path = vendor/unique_resource
url = https://github.com/okdshin/unique_resource.git 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"] [submodule "vendor/benchmark"]
path = vendor/benchmark path = vendor/benchmark
url = https://github.com/google/benchmark.git url = https://github.com/google/benchmark.git
@@ -49,3 +46,6 @@
[submodule "platform/windows/vendor/vcpkg"] [submodule "platform/windows/vendor/vcpkg"]
path = platform/windows/vendor/vcpkg path = platform/windows/vendor/vcpkg
url = https://github.com/microsoft/vcpkg.git url = https://github.com/microsoft/vcpkg.git
[submodule "vendor/boost"]
path = vendor/boost
url = https://github.com/maplibre/maplibre-gl-native-boost.git

View File

@@ -3,14 +3,14 @@ load(
"//bazel:core.bzl", "//bazel:core.bzl",
"MLN_CORE_HEADERS", "MLN_CORE_HEADERS",
"MLN_CORE_SOURCE", "MLN_CORE_SOURCE",
"MLN_DRAWABLES_HEADERS",
"MLN_DRAWABLES_SOURCE",
"MLN_DRAWABLES_GL_HEADERS", "MLN_DRAWABLES_GL_HEADERS",
"MLN_DRAWABLES_GL_SOURCE", "MLN_DRAWABLES_GL_SOURCE",
"MLN_DRAWABLES_HEADERS",
"MLN_DRAWABLES_MTL_HEADERS", "MLN_DRAWABLES_MTL_HEADERS",
"MLN_DRAWABLES_MTL_SOURCE", "MLN_DRAWABLES_MTL_SOURCE",
"MLN_GENERATED_SHADER_HEADERS", "MLN_DRAWABLES_SOURCE",
"MLN_GENERATED_OPENGL_SHADER_HEADERS", "MLN_GENERATED_OPENGL_SHADER_HEADERS",
"MLN_GENERATED_SHADER_HEADERS",
"MLN_GENERATED_STYLE_SOURCE", "MLN_GENERATED_STYLE_SOURCE",
"MLN_OPENGL_HEADERS", "MLN_OPENGL_HEADERS",
"MLN_OPENGL_SOURCE", "MLN_OPENGL_SOURCE",
@@ -90,17 +90,17 @@ cc_library(
name = "mbgl-core", name = "mbgl-core",
srcs = MLN_CORE_SOURCE + srcs = MLN_CORE_SOURCE +
MLN_GENERATED_STYLE_SOURCE + select({ MLN_GENERATED_STYLE_SOURCE + select({
":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE, ":drawable_renderer": MLN_OPENGL_SOURCE + MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_GL_SOURCE,
":legacy_renderer": MLN_OPENGL_SOURCE, ":legacy_renderer": MLN_OPENGL_SOURCE,
":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE, ":metal_renderer": MLN_DRAWABLES_SOURCE + MLN_DRAWABLES_MTL_SOURCE,
"//conditions:default": [], "//conditions:default": [],
}), }),
hdrs = MLN_CORE_HEADERS + select({ hdrs = MLN_CORE_HEADERS + select({
":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS, ":drawable_renderer": MLN_OPENGL_HEADERS + MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_GL_HEADERS,
":legacy_renderer": MLN_OPENGL_HEADERS, ":legacy_renderer": MLN_OPENGL_HEADERS,
":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS, ":metal_renderer": MLN_DRAWABLES_HEADERS + MLN_DRAWABLES_MTL_HEADERS,
"//conditions:default": [], "//conditions:default": [],
}), }),
copts = CPP_FLAGS + MAPLIBRE_FLAGS, copts = CPP_FLAGS + MAPLIBRE_FLAGS,
defines = select({ defines = select({
":legacy_renderer": [ ":legacy_renderer": [
@@ -209,11 +209,11 @@ config_setting(
string_flag( string_flag(
name = "renderer", name = "renderer",
build_setting_default = "legacy", build_setting_default = "legacy",
values=[ values = [
"legacy", "legacy",
"drawable", "drawable",
"metal" "metal",
] ],
) )
config_setting( config_setting(
@@ -233,8 +233,8 @@ config_setting(
config_setting( config_setting(
name = "metal_renderer", name = "metal_renderer",
flag_values = { flag_values = {
":renderer": "metal" ":renderer": "metal",
} },
) )
exports_files( exports_files(

View File

@@ -74,7 +74,7 @@ protected:
friend class BackendScope; 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; return &a == &b;
} }

View File

@@ -45,23 +45,23 @@ enum class MapDebugOptions : EnumType {
DepthBuffer = 1 << 7, 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)); 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))); 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); 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))); 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)); return MapDebugOptions(~mbgl::underlying_type(value));
} }

View File

@@ -6,25 +6,25 @@
namespace mbgl { namespace mbgl {
template <typename Enum> template <typename Enum>
MBGL_CONSTEXPR Enum operator|(Enum a, Enum b) { constexpr Enum operator|(Enum a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type"); static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
return Enum(mbgl::underlying_type(a) | mbgl::underlying_type(b)); return Enum(mbgl::underlying_type(a) | mbgl::underlying_type(b));
} }
template <typename Enum> template <typename Enum>
MBGL_CONSTEXPR Enum& operator|=(Enum& a, Enum b) { constexpr Enum& operator|=(Enum& a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type"); static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
return (a = a | b); return (a = a | b);
} }
template <typename Enum> template <typename Enum>
MBGL_CONSTEXPR bool operator&(Enum a, Enum b) { constexpr bool operator&(Enum a, Enum b) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type"); static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
return bool(mbgl::underlying_type(a) & mbgl::underlying_type(b)); return bool(mbgl::underlying_type(a) & mbgl::underlying_type(b));
} }
template <typename Enum> template <typename Enum>
MBGL_CONSTEXPR Enum operator~(Enum value) { constexpr Enum operator~(Enum value) {
static_assert(std::is_enum<Enum>::value, "Enum must be an enum type"); static_assert(std::is_enum<Enum>::value, "Enum must be an enum type");
return Enum(~mbgl::underlying_type(value)); return Enum(~mbgl::underlying_type(value));
} }

View File

@@ -11,14 +11,14 @@ namespace mbgl {
namespace util { namespace util {
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_convertible_v<From, To>>> template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_convertible_v<From, To>>>
MBGL_CONSTEXPR std::array<To, Size> convert(const std::array<From, Size>& from) { constexpr std::array<To, Size> convert(const std::array<From, Size>& from) {
std::array<To, Size> to{{}}; std::array<To, Size> to{{}};
std::copy(std::begin(from), std::end(from), std::begin(to)); std::copy(std::begin(from), std::end(from), std::begin(to));
return to; return to;
} }
template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_assignable_v<To&, From>>> template <typename To, typename From, std::size_t Size, typename = std::enable_if_t<std::is_assignable_v<To&, From>>>
MBGL_CONSTEXPR std::array<To, Size> cast(const std::array<From, Size>& from) { constexpr std::array<To, Size> cast(const std::array<From, Size>& from) {
std::array<To, Size> to{{}}; std::array<To, Size> to{{}};
std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast<To>(x); }); std::transform(std::begin(from), std::end(from), std::begin(to), [](From x) { return static_cast<To>(x); });
return to; return to;

View File

@@ -13,13 +13,6 @@
#endif #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 // Compiler defines for making symbols visible, otherwise they
// will be defined as hidden by default. // will be defined as hidden by default.

View File

@@ -1,17 +1,27 @@
#include <mbgl/util/utf.hpp> #include <mbgl/util/utf.hpp>
#include <boost/locale/encoding_utf.hpp> #include <locale>
#include <codecvt>
namespace mbgl { namespace mbgl {
namespace util { namespace util {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
std::u16string convertUTF8ToUTF16(const std::string& str) { std::u16string convertUTF8ToUTF16(const std::string& str) {
return boost::locale::conv::utf_to_utf<char16_t>(str); std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> conv;
return conv.from_bytes(str);
} }
std::string convertUTF16ToUTF8(const std::u16string& str) { std::string convertUTF16ToUTF8(const std::u16string& str) {
return boost::locale::conv::utf_to_utf<char>(str); std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> conv;
return conv.to_bytes(str);
} }
#pragma GCC diagnostic pop
} // namespace util } // namespace util
} // namespace mbgl } // namespace mbgl

View File

@@ -2,30 +2,13 @@
set -eu 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 # Extract boost modules that we need
rm -rf vendor/boost/include rm -rf vendor/boost/include
mkdir -p 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 pushd vendor/boost
VERSION=$(sed -n 's/^#define BOOST_LIB_VERSION "\([^"]*\)"$/\1/p' include/boost/version.hpp) 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 git add README.md include
popd 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."

25
scripts/vendor/icu.sh vendored
View File

@@ -2,10 +2,11 @@
source "$(dirname "${BASH_SOURCE[0]}")/common.sh" source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
NAME=icu NAME=icu
VERSION=61.1 VERSION=73.2
ROOT=icu/source 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 init
STRIP_COMPONENTS=2 extract_gzip "${ROOT}/common/*.h" "${ROOT}/common/*.cpp" STRIP_COMPONENTS=2 extract_gzip "${ROOT}/common/*.h" "${ROOT}/common/*.cpp"
STRIP_COMPONENTS=1 extract_gzip "icu/LICENSE" STRIP_COMPONENTS=1 extract_gzip "icu/LICENSE"
@@ -33,7 +34,7 @@ FILES=(
echo ">> Finding dependencies..." echo ">> Finding dependencies..."
ALL=() ALL=()
for FILE in "${FILES[@]}"; do 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 done
# Remove duplicates # Remove duplicates
@@ -49,24 +50,6 @@ for FILE in "${ALL[@]}"; do
sed 's/^#include \"\(unicode\/[^\"]\{1,\}\)\"/#include <\1>/' "common/$FILE" > "$DIR/$FILE" sed 's/^#include \"\(unicode\/[^\"]\{1,\}\)\"/#include <\1>/' "common/$FILE" > "$DIR/$FILE"
done 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 rm -rf common
file_list include src -name "*.h" -o -name "*.cpp" file_list include src -name "*.h" -o -name "*.cpp"

View File

@@ -12,7 +12,7 @@
#include <mbgl/style/style.hpp> #include <mbgl/style/style.hpp>
#include <mbgl/style/style_impl.hpp> #include <mbgl/style/style_impl.hpp>
#include <boost/function_output_iterator.hpp> #include <boost/iterator/function_output_iterator.hpp>
// Note: LayerManager::annotationsEnabled is defined // Note: LayerManager::annotationsEnabled is defined
// at compile time, so that linker (with LTO on) is able // at compile time, so that linker (with LTO on) is able

View File

@@ -6,8 +6,8 @@
#endif #endif
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp> #include <boost/phoenix/core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp> #include <boost/phoenix/operator.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)

View File

@@ -9,8 +9,8 @@
#endif #endif
#include <boost/spirit/include/qi.hpp> #include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix_core.hpp> #include <boost/phoenix/core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp> #include <boost/phoenix/operator.hpp>
#ifdef _MSC_VER #ifdef _MSC_VER
#pragma warning(pop) #pragma warning(pop)

5
vendor/BUILD.bazel vendored
View File

@@ -178,7 +178,10 @@ cc_library(
# vendor/metal-cpp.json # vendor/metal-cpp.json
cc_library( cc_library(
name = "metal-cpp", name = "metal-cpp",
hdrs = glob(["metal-cpp/**/*.hpp"], allow_empty = False), hdrs = glob(
["metal-cpp/**/*.hpp"],
allow_empty = False,
),
copts = CPP_FLAGS, copts = CPP_FLAGS,
includes = ["metal-cpp"], includes = ["metal-cpp"],
visibility = ["//visibility:public"], visibility = ["//visibility:public"],

2
vendor/boost vendored