diff options
Diffstat (limited to 'vcpkg/ports/protobuf')
| -rw-r--r-- | vcpkg/ports/protobuf/fix-abseil.patch | 91 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/fix-default-proto-file-path.patch | 21 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/fix-install-dirs.patch | 12 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/fix-mingw-tail-call.patch | 18 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/fix-static-build.patch | 22 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/fix-utf8-range.patch | 48 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/portfile.cmake | 139 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake | 8 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/vcpkg-cmake-wrapper.cmake | 3 | ||||
| -rw-r--r-- | vcpkg/ports/protobuf/vcpkg.json | 32 |
10 files changed, 394 insertions, 0 deletions
diff --git a/vcpkg/ports/protobuf/fix-abseil.patch b/vcpkg/ports/protobuf/fix-abseil.patch new file mode 100644 index 0000000..0314591 --- /dev/null +++ b/vcpkg/ports/protobuf/fix-abseil.patch @@ -0,0 +1,91 @@ +diff --git a/src/google/protobuf/arena.h b/src/google/protobuf/arena.h +index 545fd5126..55b1ec83b 100644 +--- a/src/google/protobuf/arena.h ++++ b/src/google/protobuf/arena.h +@@ -32,7 +32,6 @@ using type_info = ::type_info; + #include "absl/base/optimization.h" + #include "absl/base/prefetch.h" + #include "absl/log/absl_check.h" +-#include "absl/utility/internal/if_constexpr.h" + #include "google/protobuf/arena_align.h" + #include "google/protobuf/arena_allocation_policy.h" + #include "google/protobuf/port.h" +@@ -214,41 +213,31 @@ class PROTOBUF_EXPORT PROTOBUF_ALIGNAS(8) Arena final { + // otherwise, returns a heap-allocated object. + template <typename T, typename... Args> + PROTOBUF_NDEBUG_INLINE static T* Create(Arena* arena, Args&&... args) { +- return absl::utility_internal::IfConstexprElse< +- is_arena_constructable<T>::value>( +- // Arena-constructable +- [arena](auto&&... args) { +- using Type = std::remove_const_t<T>; +-#ifdef __cpp_if_constexpr +- // DefaultConstruct/CopyConstruct are optimized for messages, which +- // are both arena constructible and destructor skippable and they +- // assume much. Don't use these functions unless the invariants +- // hold. +- if constexpr (is_destructor_skippable<T>::value) { +- constexpr auto construct_type = GetConstructType<T, Args&&...>(); +- // We delegate to DefaultConstruct/CopyConstruct where appropriate +- // because protobuf generated classes have external templates for +- // these functions for code size reasons. When `if constexpr` is not +- // available always use the fallback. +- if constexpr (construct_type == ConstructType::kDefault) { +- return static_cast<Type*>(DefaultConstruct<Type>(arena)); +- } else if constexpr (construct_type == ConstructType::kCopy) { +- return static_cast<Type*>(CopyConstruct<Type>(arena, &args...)); +- } +- } +-#endif +- return CreateArenaCompatible<Type>(arena, +- std::forward<Args>(args)...); +- }, +- // Non arena-constructable +- [arena](auto&&... args) { +- if (PROTOBUF_PREDICT_FALSE(arena == nullptr)) { +- return new T(std::forward<Args>(args)...); +- } +- return new (arena->AllocateInternal<T>()) +- T(std::forward<Args>(args)...); +- }, +- std::forward<Args>(args)...); ++ if constexpr (is_arena_constructable<T>::value) { ++ using Type = std::remove_const_t<T>; ++ // DefaultConstruct/CopyConstruct are optimized for messages, which ++ // are both arena constructible and destructor skippable and they ++ // assume much. Don't use these functions unless the invariants ++ // hold. ++ if constexpr (is_destructor_skippable<T>::value) { ++ constexpr auto construct_type = GetConstructType<T, Args&&...>(); ++ // We delegate to DefaultConstruct/CopyConstruct where appropriate ++ // because protobuf generated classes have external templates for ++ // these functions for code size reasons. When `if constexpr` is not ++ // available always use the fallback. ++ if constexpr (construct_type == ConstructType::kDefault) { ++ return static_cast<Type*>(DefaultConstruct<Type>(arena)); ++ } else if constexpr (construct_type == ConstructType::kCopy) { ++ return static_cast<Type*>(CopyConstruct<Type>(arena, &args...)); ++ } ++ } ++ return CreateArenaCompatible<Type>(arena, std::forward<Args>(args)...); ++ } else { ++ if (ABSL_PREDICT_FALSE(arena == nullptr)) { ++ return new T(std::forward<Args>(args)...); ++ } ++ return new (arena->AllocateInternal<T>()) T(std::forward<Args>(args)...); ++ } + } + + // API to delete any objects not on an arena. This can be used to safely +diff --git a/cmake/abseil-cpp.cmake b/cmake/abseil-cpp.cmake +index 1b64affa5..c45fb222a 100644 +--- a/cmake/abseil-cpp.cmake ++++ b/cmake/abseil-cpp.cmake +@@ -72,7 +72,6 @@ else() + absl::flat_hash_set + absl::function_ref + absl::hash +- absl::if_constexpr + absl::layout + absl::log_initialize + absl::log_globals diff --git a/vcpkg/ports/protobuf/fix-default-proto-file-path.patch b/vcpkg/ports/protobuf/fix-default-proto-file-path.patch new file mode 100644 index 0000000..b7a8c88 --- /dev/null +++ b/vcpkg/ports/protobuf/fix-default-proto-file-path.patch @@ -0,0 +1,21 @@ +diff --git a/src/google/protobuf/compiler/command_line_interface.cc b/src/google/protobuf/compiler/command_line_interface.cc
+index cd95c8b41..d4825180d 100644
+--- a/src/google/protobuf/compiler/command_line_interface.cc
++++ b/src/google/protobuf/compiler/command_line_interface.cc
+@@ -272,12 +272,15 @@ void AddDefaultProtoPaths(
+ paths->emplace_back("", std::move(include_path));
+ return;
+ }
+- // Check if the upper level directory has an "include" subdirectory.
++ // change "'$/bin' is next to 'include'" assumption to "'$/bin/tools' is next to 'include'"
++ for (int i = 0; i < 2; i++)
++ {
+ pos = path.find_last_of("/\\");
+ if (pos == std::string::npos || pos == 0) {
+ return;
+ }
+ path = path.substr(0, pos);
++ }
+ include_path = absl::StrCat(path, "/include");
+ if (IsInstalledProtoPath(include_path)) {
+ paths->emplace_back("", std::move(include_path));
diff --git a/vcpkg/ports/protobuf/fix-install-dirs.patch b/vcpkg/ports/protobuf/fix-install-dirs.patch new file mode 100644 index 0000000..d9ea3b8 --- /dev/null +++ b/vcpkg/ports/protobuf/fix-install-dirs.patch @@ -0,0 +1,12 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 540c12253..320aaf72d 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -13,6 +13,7 @@ endif()
+
+ # Project
+ project(protobuf C CXX)
++include(GNUInstallDirs)
+
+ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
+ if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
diff --git a/vcpkg/ports/protobuf/fix-mingw-tail-call.patch b/vcpkg/ports/protobuf/fix-mingw-tail-call.patch new file mode 100644 index 0000000..dc9de46 --- /dev/null +++ b/vcpkg/ports/protobuf/fix-mingw-tail-call.patch @@ -0,0 +1,18 @@ +diff --git a/src/google/protobuf/port_def.inc b/src/google/protobuf/port_def.inc +index 56f995e45e..bc7a01e534 100644 +--- a/src/google/protobuf/port_def.inc ++++ b/src/google/protobuf/port_def.inc +@@ -228,11 +228,12 @@ static_assert(PROTOBUF_ABSL_MIN(20230125, 3), + #endif + #if ABSL_HAVE_CPP_ATTRIBUTE(clang::musttail) && !defined(__arm__) && \ + !defined(_ARCH_PPC) && !defined(__wasm__) && \ +- !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__) ++ !(defined(_MSC_VER) && defined(_M_IX86)) && !defined(__i386__) && !defined(__MINGW32__) + // Compilation fails on ARM32: b/195943306 + // Compilation fails on powerpc64le: b/187985113 + // Compilation fails on X86 Windows: + // https://github.com/llvm/llvm-project/issues/53271 ++// Compilation fails on MINGW: https://github.com/protocolbuffers/protobuf/issues/21625 + #define PROTOBUF_MUSTTAIL [[clang::musttail]] + #define PROTOBUF_TAILCALL true + #else diff --git a/vcpkg/ports/protobuf/fix-static-build.patch b/vcpkg/ports/protobuf/fix-static-build.patch new file mode 100644 index 0000000..4e75b4b --- /dev/null +++ b/vcpkg/ports/protobuf/fix-static-build.patch @@ -0,0 +1,22 @@ +diff --git a/cmake/install.cmake b/cmake/install.cmake
+index 65765ca29..f5ad69102 100644
+--- a/cmake/install.cmake
++++ b/cmake/install.cmake
+@@ -65,7 +65,7 @@ if (protobuf_BUILD_PROTOC_BINARIES)
+ endforeach ()
+ endif ()
+ foreach (binary IN LISTS _protobuf_binaries)
+- if (UNIX AND NOT APPLE)
++ if (UNIX AND NOT APPLE AND NOT protobuf_MSVC_STATIC_RUNTIME)
+ set_property(TARGET ${binary}
+ PROPERTY INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
+ elseif (APPLE)
+@@ -85,7 +85,5 @@ set(protobuf_HEADERS
+ ${cpp_features_proto_proto_srcs}
+ ${descriptor_proto_proto_srcs}
+ ${plugin_proto_proto_srcs}
+- ${java_features_proto_proto_srcs}
+- ${go_features_proto_proto_srcs}
+ )
+ if (protobuf_BUILD_LIBUPB)
+ list(APPEND protobuf_HEADERS ${libupb_hdrs})
\ No newline at end of file diff --git a/vcpkg/ports/protobuf/fix-utf8-range.patch b/vcpkg/ports/protobuf/fix-utf8-range.patch new file mode 100644 index 0000000..72d671c --- /dev/null +++ b/vcpkg/ports/protobuf/fix-utf8-range.patch @@ -0,0 +1,48 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 15065d874..540c12253 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -302,6 +302,7 @@ endif (protobuf_BUILD_TESTS)
+ include(${protobuf_SOURCE_DIR}/cmake/abseil-cpp.cmake)
+
+ if (protobuf_BUILD_PROTOBUF_BINARIES)
++ find_package(utf8_range CONFIG REQUIRED)
+ include(${protobuf_SOURCE_DIR}/cmake/utf8_range.cmake)
+ include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
+ if (NOT DEFINED protobuf_LIB_PROTOBUF_LITE)
+diff --git a/cmake/libprotobuf-lite.cmake b/cmake/libprotobuf-lite.cmake
+index 9aa81fb88..699c92ddd 100644
+--- a/cmake/libprotobuf-lite.cmake
++++ b/cmake/libprotobuf-lite.cmake
+@@ -46,4 +46,4 @@ set_target_properties(libprotobuf-lite PROPERTIES
+ )
+ add_library(protobuf::libprotobuf-lite ALIAS libprotobuf-lite)
+
+-target_link_libraries(libprotobuf-lite PRIVATE utf8_validity)
++target_link_libraries(libprotobuf-lite PRIVATE utf8_range::utf8_validity)
+diff --git a/cmake/libprotobuf.cmake b/cmake/libprotobuf.cmake
+index 11c09b1bc..33ebac7cc 100644
+--- a/cmake/libprotobuf.cmake
++++ b/cmake/libprotobuf.cmake
+@@ -48,4 +48,4 @@ set_target_properties(libprotobuf PROPERTIES
+ )
+ add_library(protobuf::libprotobuf ALIAS libprotobuf)
+
+-target_link_libraries(libprotobuf PRIVATE utf8_validity)
++target_link_libraries(libprotobuf PRIVATE utf8_range::utf8_validity)
+diff --git a/cmake/utf8_range.cmake b/cmake/utf8_range.cmake
+index f411a8c5b..21bf8235b 100644
+--- a/cmake/utf8_range.cmake
++++ b/cmake/utf8_range.cmake
+@@ -1,4 +1,4 @@
+-if (NOT TARGET utf8_range)
++if (0)
+ set(utf8_range_ENABLE_TESTS OFF CACHE BOOL "Disable utf8_range tests")
+
+ if (NOT EXISTS "${protobuf_SOURCE_DIR}/third_party/utf8_range/CMakeLists.txt")
+@@ -12,4 +12,4 @@ if (NOT TARGET utf8_range)
+ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/third_party/utf8_range)
+ endif ()
+
+-set(_protobuf_FIND_UTF8_RANGE "if(NOT TARGET utf8_range)\n find_package(utf8_range CONFIG)\nendif()")
++set(_protobuf_FIND_UTF8_RANGE "if(NOT TARGET utf8_range::utf8_range)\n find_package(utf8_range CONFIG)\nendif()")
diff --git a/vcpkg/ports/protobuf/portfile.cmake b/vcpkg/ports/protobuf/portfile.cmake new file mode 100644 index 0000000..a5ec253 --- /dev/null +++ b/vcpkg/ports/protobuf/portfile.cmake @@ -0,0 +1,139 @@ +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO protocolbuffers/protobuf + REF "v${VERSION}" + SHA512 46d60de626480f5bac256a09c57300fe5ec990664876edbe04c9385769b500ec88409da976acc28fcb2b2e987afc1bbbf5669f4fed4033c5464ab8bbd38723bc + HEAD_REF master + PATCHES + fix-static-build.patch + fix-default-proto-file-path.patch + fix-utf8-range.patch + fix-install-dirs.patch + fix-mingw-tail-call.patch + fix-abseil.patch +) + +string(COMPARE EQUAL "${TARGET_TRIPLET}" "${HOST_TRIPLET}" protobuf_BUILD_PROTOC_BINARIES) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" protobuf_BUILD_SHARED_LIBS) +string(COMPARE EQUAL "${VCPKG_CRT_LINKAGE}" "static" protobuf_MSVC_STATIC_RUNTIME) + +vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + zlib protobuf_WITH_ZLIB +) + +if(VCPKG_TARGET_IS_UWP) + set(protobuf_BUILD_LIBPROTOC OFF) +else() + set(protobuf_BUILD_LIBPROTOC ON) +endif() + +if (VCPKG_DOWNLOAD_MODE) + # download PKGCONFIG in download mode which is used in `vcpkg_fixup_pkgconfig()` at the end of this script. + # download it here because `vcpkg_cmake_configure()` halts execution in download mode when running configure process. + vcpkg_find_acquire_program(PKGCONFIG) +endif() + +# Delete language backends we aren't targeting to reduce false positives in automated dependency +# detectors like Dependabot. +file(REMOVE_RECURSE + "${SOURCE_PATH}/csharp" + "${SOURCE_PATH}/java" + "${SOURCE_PATH}/lua" + "${SOURCE_PATH}/objectivec" + "${SOURCE_PATH}/php" + "${SOURCE_PATH}/python" + "${SOURCE_PATH}/ruby" + "${SOURCE_PATH}/rust" + "${SOURCE_PATH}/go" +) + +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + -Dprotobuf_BUILD_SHARED_LIBS=${protobuf_BUILD_SHARED_LIBS} + -Dprotobuf_MSVC_STATIC_RUNTIME=${protobuf_MSVC_STATIC_RUNTIME} + -Dprotobuf_BUILD_TESTS=OFF + -DCMAKE_INSTALL_CMAKEDIR:STRING=share/protobuf + -Dprotobuf_BUILD_PROTOC_BINARIES=${protobuf_BUILD_PROTOC_BINARIES} + -Dprotobuf_BUILD_LIBPROTOC=${protobuf_BUILD_LIBPROTOC} + -Dprotobuf_ABSL_PROVIDER=package + -Dprotobuf_BUILD_LIBUPB=OFF + ${FEATURE_OPTIONS} +) + +vcpkg_cmake_install() + +if(protobuf_BUILD_PROTOC_BINARIES) + if(VCPKG_TARGET_IS_WINDOWS) + vcpkg_copy_tools(TOOL_NAMES protoc AUTO_CLEAN) + else() + string(REPLACE "." ";" VERSION_LIST ${VERSION}) + list(GET VERSION_LIST 1 VERSION_MINOR) + list(GET VERSION_LIST 2 VERSION_PATCH) + vcpkg_copy_tools(TOOL_NAMES protoc protoc-${VERSION_MINOR}.${VERSION_PATCH}.0 AUTO_CLEAN) + endif() +else() + file(COPY "${CURRENT_HOST_INSTALLED_DIR}/tools/${PORT}" DESTINATION "${CURRENT_PACKAGES_DIR}/tools") +endif() + +vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-config.cmake" + "if(protobuf_MODULE_COMPATIBLE)" + "if(protobuf_MODULE_COMPATIBLE OR CMAKE_FIND_PACKAGE_NAME STREQUAL \"Protobuf\")" +) +if(NOT protobuf_BUILD_LIBPROTOC) + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-module.cmake" + "_protobuf_find_libraries(Protobuf_PROTOC protoc)" + "" + ) +endif() + +vcpkg_cmake_config_fixup() + +if(VCPKG_LIBRARY_LINKAGE STREQUAL "dynamic") + vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/google/protobuf/port_def.inc" + "\#ifdef PROTOBUF_PORT_" + "\#ifndef PROTOBUF_USE_DLLS\n\#define PROTOBUF_USE_DLLS\n\#endif // PROTOBUF_USE_DLLS\n\n\#ifdef PROTOBUF_PORT_" + ) +endif() + +vcpkg_copy_pdbs() + +function(replace_package_string package) + set(debug_file "${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/${package}.pc") + set(release_file "${CURRENT_PACKAGES_DIR}/lib/pkgconfig/${package}.pc") + + if(EXISTS "${release_file}") + vcpkg_replace_string("${release_file}" "absl_abseil_dll" "abseil_dll" IGNORE_UNCHANGED) + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + vcpkg_replace_string("${release_file}" "-l${package}" "-llib${package}" IGNORE_UNCHANGED) + endif() + endif() + + if(EXISTS "${debug_file}") + vcpkg_replace_string("${debug_file}" "absl_abseil_dll" "abseil_dll" IGNORE_UNCHANGED) + if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) + vcpkg_replace_string("${debug_file}" "-l${package}" "-llib${package}d" IGNORE_UNCHANGED) + else() + vcpkg_replace_string("${debug_file}" "-l${package}" "-l${package}d" IGNORE_UNCHANGED) + endif() + endif() +endfunction() + +set(packages protobuf protobuf-lite) +foreach(package IN LISTS packages) + replace_package_string("${package}") +endforeach() + + +vcpkg_fixup_pkgconfig() + +if(NOT protobuf_BUILD_PROTOC_BINARIES) + configure_file("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets-vcpkg-protoc.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/protobuf-targets-vcpkg-protoc.cmake" COPYONLY) +endif() + +configure_file("${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake" "${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake" @ONLY) + +file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share" "${CURRENT_PACKAGES_DIR}/debug/include") + +vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE") diff --git a/vcpkg/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake b/vcpkg/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake new file mode 100644 index 0000000..245adf5 --- /dev/null +++ b/vcpkg/ports/protobuf/protobuf-targets-vcpkg-protoc.cmake @@ -0,0 +1,8 @@ +# Create imported target protobuf::protoc
+add_executable(protobuf::protoc IMPORTED)
+
+# Import target "protobuf::protoc" for configuration "Release"
+set_property(TARGET protobuf::protoc APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
+set_target_properties(protobuf::protoc PROPERTIES
+ IMPORTED_LOCATION_RELEASE "${Protobuf_PROTOC_EXECUTABLE}"
+)
diff --git a/vcpkg/ports/protobuf/vcpkg-cmake-wrapper.cmake b/vcpkg/ports/protobuf/vcpkg-cmake-wrapper.cmake new file mode 100644 index 0000000..17d7873 --- /dev/null +++ b/vcpkg/ports/protobuf/vcpkg-cmake-wrapper.cmake @@ -0,0 +1,3 @@ +find_program(Protobuf_PROTOC_EXECUTABLE NAMES protoc PATHS "${CMAKE_CURRENT_LIST_DIR}/../../../@HOST_TRIPLET@/tools/protobuf" NO_DEFAULT_PATH)
+
+_find_package(${ARGS} CONFIG)
diff --git a/vcpkg/ports/protobuf/vcpkg.json b/vcpkg/ports/protobuf/vcpkg.json new file mode 100644 index 0000000..4ceada9 --- /dev/null +++ b/vcpkg/ports/protobuf/vcpkg.json @@ -0,0 +1,32 @@ +{ + "name": "protobuf", + "version": "5.29.5", + "port-version": 2, + "description": "Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data.", + "homepage": "https://github.com/protocolbuffers/protobuf", + "license": "BSD-3-Clause", + "dependencies": [ + "abseil", + { + "name": "protobuf", + "host": true + }, + "utf8-range", + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ], + "features": { + "zlib": { + "description": "ZLib based features like Gzip streams", + "dependencies": [ + "zlib" + ] + } + } +} |