Skip to content

Commit 3590ac9

Browse files
committed
Upgrade the versions of gRPC, upb, and flatbuffers via modified versions of the upstream portfiles
1 parent bb89f90 commit 3590ac9

27 files changed

+904
-0
lines changed

dependencies.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ gflags
66
protobuf
77
abseil
88
grpc[absl-sync,codegen]
9+
flatbuffers
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
diff --git a/src/util.cpp b/src/util.cpp
2+
index 3670a019..fb5d884f 100644
3+
--- a/src/util.cpp
4+
+++ b/src/util.cpp
5+
@@ -255,9 +255,15 @@ bool ReadEnvironmentVariable(const char *var_name, std::string *_value) {
6+
#ifdef _MSC_VER
7+
__pragma(warning(disable : 4996)); // _CRT_SECURE_NO_WARNINGS
8+
#endif
9+
+#if _WIN32_WINNT < 0x0A00
10+
auto env_str = std::getenv(var_name);
11+
if (!env_str) return false;
12+
if (_value) *_value = std::string(env_str);
13+
+#else
14+
+ //There is no support for environment variables in UWP
15+
+ var_name; // Do nothing
16+
+ *_value = std::string("");
17+
+#endif
18+
return true;
19+
}
20+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index ec782239..f163b64d 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -216,7 +216,7 @@ set(FlatBuffers_GRPCTest_SRCS
6+
# source_group(Compiler FILES ${FlatBuffers_Compiler_SRCS})
7+
# source_group(Tests FILES ${FlatBuffers_Tests_SRCS})
8+
9+
-if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
10+
+if(EXISTS "${CMAKE_TOOLCHAIN_FILE}" AND NOT DEFINED VCPKG_TOOLCHAIN)
11+
# do not apply any global settings if the toolchain
12+
# is being configured externally
13+
message(STATUS "Using toolchain file: ${CMAKE_TOOLCHAIN_FILE}.")

ports/flatbuffers/no-werror.patch

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index ec782239..57566c5a 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -233,13 +233,17 @@ elseif(CMAKE_COMPILER_IS_GNUCXX)
6+
"${CMAKE_CXX_FLAGS} -std=c++0x")
7+
endif(CYGWIN)
8+
set(CMAKE_CXX_FLAGS
9+
- "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror -Wextra -Werror=shadow")
10+
+ "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wextra -Werror=shadow")
11+
set(FLATBUFFERS_PRIVATE_CXX_FLAGS "-Wold-style-cast")
12+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.4)
13+
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7.0)
14+
set(CMAKE_CXX_FLAGS
15+
"${CMAKE_CXX_FLAGS} -faligned-new -Werror=implicit-fallthrough=2")
16+
endif()
17+
+ if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.0)
18+
+ set(CMAKE_CXX_FLAGS
19+
+ "${CMAKE_CXX_FLAGS} -Wextra")
20+
+ endif()
21+
set(CMAKE_CXX_FLAGS
22+
"${CMAKE_CXX_FLAGS} -Wunused-result -Werror=unused-result -Wunused-parameter -Werror=unused-parameter")
23+
endif()

ports/flatbuffers/portfile.cmake

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
2+
3+
vcpkg_from_github(
4+
OUT_SOURCE_PATH SOURCE_PATH
5+
REPO google/flatbuffers
6+
REF 31bb0b9726b0fa4db252680e156abd44adbdf4f4 # 2021-10-06
7+
SHA512 12fde1c8ecc12dca5402a3272119213dffdbe247a7ae72dc36aa677f83cb28a58d9edb0f1f1630b8617d3767db28c13ee202cb7f02fbafe11277e9e3e2595b90
8+
HEAD_REF master
9+
PATCHES
10+
ignore_use_of_cmake_toolchain_file.patch
11+
no-werror.patch
12+
fix-uwp-build.patch
13+
)
14+
15+
set(OPTIONS)
16+
if(VCPKG_TARGET_IS_UWP OR VCPKG_TARGET_IS_IOS)
17+
list(APPEND OPTIONS -DFLATBUFFERS_BUILD_FLATC=OFF -DFLATBUFFERS_BUILD_FLATHASH=OFF)
18+
endif()
19+
20+
vcpkg_configure_cmake(
21+
SOURCE_PATH ${SOURCE_PATH}
22+
PREFER_NINJA
23+
OPTIONS
24+
-DFLATBUFFERS_BUILD_TESTS=OFF
25+
-DFLATBUFFERS_BUILD_GRPCTEST=OFF
26+
${OPTIONS}
27+
)
28+
29+
vcpkg_install_cmake()
30+
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/flatbuffers)
31+
32+
file(GLOB flatc_path ${CURRENT_PACKAGES_DIR}/bin/flatc*)
33+
if(flatc_path)
34+
make_directory(${CURRENT_PACKAGES_DIR}/tools/flatbuffers)
35+
get_filename_component(flatc_executable ${flatc_path} NAME)
36+
file(
37+
RENAME
38+
${flatc_path}
39+
${CURRENT_PACKAGES_DIR}/tools/flatbuffers/${flatc_executable}
40+
)
41+
vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/flatbuffers)
42+
endif()
43+
44+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
45+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/bin ${CURRENT_PACKAGES_DIR}/debug/bin)
46+
47+
# Handle copyright
48+
file(INSTALL ${SOURCE_PATH}/LICENSE.txt DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)

ports/flatbuffers/vcpkg.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"name": "flatbuffers",
3+
"version-date": "2021-10-06",
4+
"port-version": 2,
5+
"description": [
6+
"Memory Efficient Serialization Library",
7+
"FlatBuffers is an efficient cross platform serialization library for games and other memory constrained apps. It allows you to directly access serialized data without unpacking/parsing it first, while still having great forwards/backwards compatibility."
8+
],
9+
"homepage": "https://google.github.io/flatbuffers/"
10+
}

ports/grpc/00001-fix-uwp.patch

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 1911144984..8f78306f77 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -181,6 +181,9 @@ if(UNIX)
6+
endif()
7+
if(WIN32)
8+
set(_gRPC_PLATFORM_WINDOWS ON)
9+
+ if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
10+
+ set(_gRPC_PLATFORM_UWP ON)
11+
+ endif()
12+
endif()
13+
14+
# Use C99 standard
15+
@@ -219,6 +222,9 @@ if(MSVC)
16+
set(_gRPC_C_CXX_FLAGS "${_gRPC_C_CXX_FLAGS} /wd4267")
17+
# TODO(jtattermusch): needed to build boringssl with VS2017, revisit later
18+
set(_gRPC_C_CXX_FLAGS "${_gRPC_C_CXX_FLAGS} /wd4987 /wd4774 /wd4819 /wd4996 /wd4619")
19+
+ if(_gRPC_PLATFORM_UWP)
20+
+ add_definitions(-DGRPC_ARES=0)
21+
+ endif()
22+
endif()
23+
if (MINGW)
24+
add_definitions(-D_WIN32_WINNT=0x600)
25+
@@ -286,6 +292,10 @@ file(MAKE_DIRECTORY ${_gRPC_PROTO_GENS_DIR})
26+
# ``.proto`` files
27+
#
28+
function(protobuf_generate_grpc_cpp)
29+
+ if(_gRPC_PLATFORM_UWP)
30+
+ return()
31+
+ endif()
32+
+
33+
if(NOT ARGN)
34+
message(SEND_ERROR "Error: PROTOBUF_GENERATE_GRPC_CPP() called without any proto files")
35+
return()
36+
@@ -358,6 +368,7 @@ if (gRPC_BUILD_GRPC_RUBY_PLUGIN)
37+
list(APPEND _gRPC_PLUGIN_LIST grpc_ruby_plugin)
38+
endif ()
39+
40+
+if(NOT _gRPC_PLATFORM_UWP)
41+
add_custom_target(plugins
42+
DEPENDS ${_gRPC_PLUGIN_LIST}
43+
)
44+
@@ -376,6 +387,7 @@ add_custom_target(tools_cxx
45+
46+
add_custom_target(tools
47+
DEPENDS tools_c tools_cxx)
48+
+endif()
49+
50+
protobuf_generate_grpc_cpp(
51+
src/proto/grpc/channelz/channelz.proto
52+
diff --git a/src/core/lib/iomgr/resource_quota.cc b/src/core/lib/iomgr/resource_quota.cc
53+
index dbe84e3466..cda40b6435 100644
54+
--- a/src/core/lib/iomgr/resource_quota.cc
55+
+++ b/src/core/lib/iomgr/resource_quota.cc
56+
@@ -945,7 +945,7 @@ bool grpc_resource_user_alloc(grpc_resource_user* resource_user, size_t size,
57+
void grpc_resource_user_free(grpc_resource_user* resource_user, size_t size) {
58+
gpr_mu_lock(&resource_user->mu);
59+
grpc_resource_quota* resource_quota = resource_user->resource_quota;
60+
- gpr_atm prior = gpr_atm_no_barrier_fetch_add(&resource_quota->used, -size);
61+
+ gpr_atm prior = gpr_atm_no_barrier_fetch_add(&resource_quota->used, -static_cast<gpr_atm>(size));
62+
GPR_ASSERT(prior >= static_cast<long>(size));
63+
bool was_zero_or_negative = resource_user->free_pool <= 0;
64+
resource_user->free_pool += static_cast<int64_t>(size);
65+
diff --git a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
66+
index 59432cff36..fed574d5bc 100644
67+
--- a/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
68+
+++ b/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc
69+
@@ -39,6 +39,7 @@ bool check_bios_data(const char*) { return false; }
70+
bool check_windows_registry_product_name(HKEY root_key,
71+
const char* reg_key_path,
72+
const char* reg_key_name) {
73+
+#if !defined(WINAPI_FAMILY) || WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP
74+
const size_t kProductNameBufferSize = 256;
75+
char const expected_substr[] = "Google";
76+
77+
@@ -71,6 +72,9 @@ bool check_windows_registry_product_name(HKEY root_key,
78+
}
79+
80+
return strstr(buffer, expected_substr) != nullptr;
81+
+#else
82+
+ return false;
83+
+#endif
84+
}
85+
86+
} // namespace internal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 8f78306f77..e09f8fcc1e 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -211,6 +211,11 @@ if (NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
6+
endif()
7+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
8+
9+
+if (gRPC_STATIC_LINKING AND NOT _gRPC_PLATFORM_WINDOWS)
10+
+ # Force to static link
11+
+ set(CMAKE_EXE_LINKER_FLAGS "-Bstatic")
12+
+endif()
13+
+
14+
if(MSVC)
15+
include(cmake/msvc_static_runtime.cmake)
16+
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS -D_WINSOCK_DEPRECATED_NO_WARNINGS)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/src/core/lib/transport/transport.cc b/src/core/lib/transport/transport.cc
2+
index 99a32980aa..f55db67113 100644
3+
--- a/src/core/lib/transport/transport.cc
4+
+++ b/src/core/lib/transport/transport.cc
5+
@@ -97,6 +97,8 @@ void grpc_stream_ref_init(grpc_stream_refcount* refcount, int /*initial_refs*/,
6+
refcount, &refcount->slice_refcount);
7+
}
8+
9+
+#undef move64
10+
+
11+
static void move64(uint64_t* from, uint64_t* to) {
12+
*to += *from;
13+
*from = 0;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index e09f8fcc1e..ec1714687e 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -278,7 +278,7 @@ elseif(UNIX)
6+
endif()
7+
8+
if(WIN32)
9+
- set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32 crypt32)
10+
+ set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32 crypt32 gdi32)
11+
endif()
12+
13+
# Create directory for generated .proto files

0 commit comments

Comments
 (0)