cross/armhf-linux-musl/buildroot/buildroot-2025.05/package/grpc/0002-Add-option-to-restrict...

194 lines
5.0 KiB
Diff

From 6aab068a6bd92e215b61eaab61062bf1d97bc065 Mon Sep 17 00:00:00 2001
From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Date: Tue, 25 May 2021 14:55:23 +0200
Subject: [PATCH] Add option to restrict building of (host-)grpc to
grpc_cpp_plugin only.
This avoids unnecessary dependencies on big packages like libabseil-cpp and
others.
Upstream: not accepted (see https://github.com/grpc/grpc/issues/25322)
Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com>
Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
Updated for 1.48.0:
Signed-off-by: Michael Nosthoff <buildroot@heine.tech>
---
CMakeLists.txt | 36 +++++++++++++++++++++++++++++++-----
1 file changed, 31 insertions(+), 5 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2565dc5c84..94f8fd3e93 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -50,12 +50,16 @@ set(gRPC_BUILD_MSVC_MP_COUNT 0 CACHE STRING "The maximum number of processes for
option(gRPC_BUILD_TESTS "Build tests" OFF)
option(gRPC_BUILD_CODEGEN "Build codegen" ON)
option(gRPC_DOWNLOAD_ARCHIVES "Download archives for empty 3rd party directories" ON)
+option(gRPC_BUILD_PLUGIN_SUPPORT_ONLY "Build plugin support only" OFF)
set(gRPC_INSTALL_default ON)
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# Disable gRPC_INSTALL by default if building as a submodule
set(gRPC_INSTALL_default OFF)
endif()
+if(gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+ set(gRPC_INSTALL_default OFF)
+endif()
set(gRPC_INSTALL ${gRPC_INSTALL_default} CACHE BOOL
"Generate installation target")
@@ -662,6 +666,8 @@ add_custom_target(plugins
DEPENDS ${_gRPC_PLUGIN_LIST}
)
+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+
add_custom_target(tools_c
DEPENDS
)
@@ -673,6 +679,8 @@ add_custom_target(tools_cxx
add_custom_target(tools
DEPENDS tools_c tools_cxx)
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
+
protobuf_generate_grpc_cpp_with_import_path_correction(
src/proto/grpc/channelz/channelz.proto src/proto/grpc/channelz/channelz.proto
)
@@ -1660,7 +1668,7 @@ if(gRPC_BUILD_TESTS)
DEPENDS buildtests_c buildtests_cxx)
endif()
-
+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
add_library(address_sorting
third_party/address_sorting/address_sorting.c
@@ -2855,6 +2863,8 @@ if(gRPC_INSTALL)
)
endif()
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
+
if(gRPC_BUILD_TESTS)
add_library(grpc_test_util
@@ -2987,6 +2997,8 @@ endif()
endif()
+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+
add_library(grpc_unsecure
src/core/channelz/channel_trace.cc
src/core/channelz/channelz.cc
@@ -3547,6 +3559,8 @@ if(gRPC_INSTALL)
)
endif()
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
+
if(gRPC_BUILD_TESTS)
add_library(gtest
@@ -3621,6 +3635,8 @@ target_link_libraries(gtest
endif()
+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+
add_library(upb_base_lib
third_party/upb/upb/base/status.c
)
@@ -4108,6 +4124,8 @@ if(gRPC_INSTALL)
)
endif()
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
+
if(gRPC_BUILD_TESTS)
if(gRPC_BUILD_CODEGEN)
@@ -4193,6 +4211,8 @@ endif()
endif()
+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+
add_library(grpc++
src/core/ext/transport/binder/client/binder_connector.cc
src/core/ext/transport/binder/client/channel_create.cc
@@ -4684,6 +4704,7 @@ if(gRPC_INSTALL)
)
endif()
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
if(gRPC_BUILD_CODEGEN)
add_library(grpc++_reflection ${_gRPC_STATIC_WIN32}
@@ -4967,6 +4988,8 @@ target_link_libraries(grpc++_test_util
endif()
+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
+
add_library(grpc++_unsecure
src/cpp/client/call_credentials.cc
src/cpp/client/channel_cc.cc
@@ -5707,6 +5730,7 @@ if(gRPC_INSTALL)
)
endif()
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
add_library(grpc_plugin_support
src/compiler/cpp_generator.cc
@@ -5769,7 +5793,7 @@ foreach(_hdr
endforeach()
-if(gRPC_INSTALL)
+if(gRPC_INSTALL OR gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
install(TARGETS grpc_plugin_support EXPORT gRPCTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
BUNDLE DESTINATION ${gRPC_INSTALL_BINDIR}
@@ -16520,7 +16544,7 @@ target_link_libraries(grpc_completion_queue_test
endif()
-if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_CPP_PLUGIN)
+if(gRPC_BUILD_GRPC_CPP_PLUGIN)
add_executable(grpc_cpp_plugin
src/compiler/cpp_plugin.cc
@@ -16548,7 +16572,7 @@ target_link_libraries(grpc_cpp_plugin
-if(gRPC_INSTALL)
+if(gRPC_INSTALL OR gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
install(TARGETS grpc_cpp_plugin EXPORT gRPCPluginTargets
RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR}
BUNDLE DESTINATION ${gRPC_INSTALL_BINDIR}
@@ -37968,7 +37992,7 @@ endif()
-
+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY)
if(gRPC_INSTALL)
install(EXPORT gRPCTargets
@@ -38089,3 +38113,5 @@ generate_pkgconfig(
"-lgrpcpp_otel_plugin"
"-laddress_sorting -lupb_textformat_lib -lupb_json_lib -lupb_wire_lib -lupb_message_lib -lutf8_range_lib -lupb_mini_descriptor_lib -lupb_mem_lib -lupb_base_lib"
"grpcpp_otel_plugin.pc")
+
+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY
\ No newline at end of file
--
2.34.1