Skip to content

Commit 97087b2

Browse files
lordgamezfgerlits
authored andcommitted
MINIFICPP-2601 Separate protobuf library from grpc
- Upgrade grpc library to v1.72.2 Signed-off-by: Ferenc Gerlits <fgerlits@gmail.com> Closes #2000
1 parent 5eda82d commit 97087b2

7 files changed

Lines changed: 67 additions & 475 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3231,7 +3231,7 @@ The above copyright notice and this permission notice shall be included in all c
32313231
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32323232

32333233

3234-
This product bundles 'protobuf' within 'gRPC' under a 3-Clause BSD license:
3234+
This product bundles 'protobuf' under a 3-Clause BSD license:
32353235

32363236
Copyright 2008 Google Inc. All rights reserved.
32373237

cmake/Grpc.cmake

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# specific language governing permissions and limitations
1616
# under the License.
1717
include(FetchContent)
18+
include(Abseil)
19+
include(Protobuf)
1820

1921
set(gRPC_BUILD_GRPC_CSHARP_PLUGIN OFF CACHE BOOL "" FORCE)
2022
set(gRPC_BUILD_GRPC_NODE_PLUGIN OFF CACHE BOOL "" FORCE)
@@ -26,20 +28,17 @@ set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)
2628
set(gRPC_ABSL_PROVIDER "package" CACHE STRING "" FORCE)
2729
set(gRPC_ZLIB_PROVIDER "package" CACHE STRING "" FORCE)
2830
set(gRPC_SSL_PROVIDER "package" CACHE STRING "" FORCE)
29-
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
30-
set(protobuf_ABSL_PROVIDER "package" CACHE STRING "" FORCE)
31+
set(gRPC_PROTOBUF_PROVIDER "package" CACHE STRING "" FORCE)
3132

32-
set(PATCH_FILE_1 "${CMAKE_SOURCE_DIR}/thirdparty/grpc/remove-custom-commands-for-unused-dependencies.patch")
33-
set(PATCH_FILE_2 "${CMAKE_SOURCE_DIR}/thirdparty/grpc/fix-constants-on-windows.patch")
33+
set(PATCH_FILE "${CMAKE_SOURCE_DIR}/thirdparty/grpc/fix-protobuf-find-package.patch")
3434
set(PC ${Bash_EXECUTABLE} -c "set -x &&\
35-
(\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_1}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_1}\\\") &&\
36-
(\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE_2}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE_2}\\\")")
35+
(\\\"${Patch_EXECUTABLE}\\\" -p1 -R -s -f --dry-run -i \\\"${PATCH_FILE}\\\" || \\\"${Patch_EXECUTABLE}\\\" -p1 -N -i \\\"${PATCH_FILE}\\\")")
3736

3837
FetchContent_Declare(
3938
grpc
4039
GIT_REPOSITORY https://github.com/grpc/grpc
41-
GIT_TAG v1.68.0
42-
GIT_SUBMODULES "third_party/cares/cares third_party/protobuf third_party/re2 third_party/upb"
40+
GIT_TAG v1.72.2
41+
GIT_SUBMODULES "third_party/cares/cares third_party/re2 third_party/upb"
4342
PATCH_COMMAND "${PC}"
4443
SYSTEM
4544
)
@@ -49,6 +48,4 @@ FetchContent_MakeAvailable(grpc)
4948
add_dependencies(grpc++ OpenSSL::SSL OpenSSL::Crypto ZLIB::ZLIB)
5049

5150
set(GRPC_INCLUDE_DIR "${grpc_SOURCE_DIR}/include" CACHE STRING "" FORCE)
52-
set(PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR}/src" CACHE STRING "" FORCE)
53-
set(PROTOBUF_COMPILER "$<TARGET_FILE:protoc>" CACHE STRING "" FORCE)
5451
set(GRPC_CPP_PLUGIN "$<TARGET_FILE:grpc_cpp_plugin>" CACHE STRING "" FORCE)

cmake/Protobuf.cmake

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Licensed to the Apache Software Foundation (ASF) under one
2+
# or more contributor license agreements. See the NOTICE file
3+
# distributed with this work for additional information
4+
# regarding copyright ownership. The ASF licenses this file
5+
# to you under the Apache License, Version 2.0 (the
6+
# "License"); you may not use this file except in compliance
7+
# with the License. You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing,
12+
# software distributed under the License is distributed on an
13+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
# KIND, either express or implied. See the License for the
15+
# specific language governing permissions and limitations
16+
# under the License.
17+
include(FetchContent)
18+
19+
set(protobuf_BUILD_TESTS OFF CACHE BOOL "" FORCE)
20+
21+
FetchContent_Declare(
22+
protobuf
23+
URL https://github.com/protocolbuffers/protobuf/archive/refs/tags/v31.1.tar.gz
24+
URL_HASH SHA256=c3a0a9ece8932e31c3b736e2db18b1c42e7070cd9b881388b26d01aa71e24ca2
25+
)
26+
FetchContent_MakeAvailable(protobuf)
27+
28+
set(PROTOBUF_INCLUDE_DIR "${protobuf_SOURCE_DIR}/src" CACHE STRING "" FORCE)
29+
set(PROTOBUF_COMPILER "$<TARGET_FILE:protoc>" CACHE STRING "" FORCE)
30+
31+
if (WIN32)
32+
set(PROTOBUF_LIBRARIES "${protobuf_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}/protobuf_static.lib" CACHE STRING "" FORCE)
33+
set(PROTOBUF_LIBRARY "${protobuf_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE}/protobuf_static.lib" CACHE STRING "" FORCE)
34+
else()
35+
set(PROTOBUF_LIBRARIES "${protobuf_BINARY_DIR}/lib/libprotobuf.a" CACHE STRING "" FORCE)
36+
set(PROTOBUF_LIBRARY "${protobuf_BINARY_DIR}/lib/libprotobuf.a" CACHE STRING "" FORCE)
37+
endif()

extensions/grafana-loki/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ endif()
2323
include(${CMAKE_SOURCE_DIR}/extensions/ExtensionHeader.txt)
2424

2525
if (ENABLE_GRPC_FOR_LOKI)
26-
include(Abseil)
2726
include(Grpc)
2827

2928
set(LOKI_PROTOBUF_GENERATED_DIR ${CMAKE_BINARY_DIR}/grafana-loki-protobuf-generated)

thirdparty/grpc/fix-constants-on-windows.patch

Lines changed: 0 additions & 35 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
diff --git a/cmake/protobuf.cmake b/cmake/protobuf.cmake
2+
index ad80ca6e46..8df42dde40 100644
3+
--- a/cmake/protobuf.cmake
4+
+++ b/cmake/protobuf.cmake
5+
@@ -55,7 +55,7 @@ if(gRPC_PROTOBUF_PROVIDER STREQUAL "module")
6+
set(gRPC_INSTALL FALSE)
7+
endif()
8+
elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
9+
- find_package(Protobuf REQUIRED CONFIG)
10+
+ find_package(Protobuf REQUIRED)
11+
12+
if(Protobuf_FOUND OR PROTOBUF_FOUND)
13+
if(TARGET protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME})
14+
@@ -69,7 +69,7 @@ elseif(gRPC_PROTOBUF_PROVIDER STREQUAL "package")
15+
set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${PROTOBUF_PROTOC_LIBRARIES})
16+
endif()
17+
# Well-known proto files are expected to be in the Protobuf include directory.
18+
- get_target_property(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${_gRPC_PROTOBUF_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES)
19+
+ set(_gRPC_PROTOBUF_WELLKNOWN_INCLUDE_DIR ${PROTOBUF_INCLUDE_DIR})
20+
if(TARGET protobuf::protoc)
21+
set(_gRPC_PROTOBUF_PROTOC protobuf::protoc)
22+
if(CMAKE_CROSSCOMPILING)

0 commit comments

Comments
 (0)