1From a1922eadfc87da3dd221ff631f94ddd4a8ee7049 Mon Sep 17 00:00:00 2001 2From: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 3Date: Tue, 25 May 2021 14:55:23 +0200 4Subject: [PATCH] Add option to restrict building of (host-)grpc to 5 grpc_cpp_plugin only. 6 7This avoids unnecessary dependencies on big packages like libabseil-cpp and 8others. 9 10Upstream-status: not accepted (see https://github.com/grpc/grpc/issues/25322) 11 12Signed-off-by: Thomas De Schampheleire <thomas.de_schampheleire@nokia.com> 13Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> 14 15Updated for 1.48.0: 16Signed-off-by: Michael Nosthoff <buildroot@heine.tech> 17--- 18 CMakeLists.txt | 43 +++++++++++++++++++++++++++++++++++-------- 19 1 file changed, 35 insertions(+), 8 deletions(-) 20 21diff --git a/CMakeLists.txt b/CMakeLists.txt 22index d3963b074b..51cef83141 100644 23--- a/CMakeLists.txt 24+++ b/CMakeLists.txt 25@@ -49,12 +49,16 @@ option(gRPC_BUILD_TESTS "Build tests" OFF) 26 option(gRPC_BUILD_CODEGEN "Build codegen" ON) 27 option(gRPC_BUILD_CSHARP_EXT "Build C# extensions" ON) 28 option(gRPC_BACKWARDS_COMPATIBILITY_MODE "Build libraries that are binary compatible across a larger number of OS and libc versions" OFF) 29+option(gRPC_BUILD_PLUGIN_SUPPORT_ONLY "Build plugin support only" OFF) 30 31 set(gRPC_INSTALL_default ON) 32 if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) 33 # Disable gRPC_INSTALL by default if building as a submodule 34 set(gRPC_INSTALL_default OFF) 35 endif() 36+if(gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 37+ set(gRPC_INSTALL_default OFF) 38+endif() 39 set(gRPC_INSTALL ${gRPC_INSTALL_default} CACHE BOOL 40 "Generate installation target") 41 42@@ -555,6 +559,8 @@ add_custom_target(plugins 43 DEPENDS ${_gRPC_PLUGIN_LIST} 44 ) 45 46+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 47+ 48 add_custom_target(tools_c 49 DEPENDS 50 ) 51@@ -567,6 +573,8 @@ add_custom_target(tools_cxx 52 add_custom_target(tools 53 DEPENDS tools_c tools_cxx) 54 55+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 56+ 57 protobuf_generate_grpc_cpp_with_import_path_correction( 58 src/proto/grpc/channelz/channelz.proto src/proto/grpc/channelz/channelz.proto 59 ) 60@@ -1228,6 +1236,7 @@ if(gRPC_BUILD_TESTS) 61 DEPENDS buildtests_c buildtests_cxx) 62 endif() 63 64+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 65 66 add_library(address_sorting 67 third_party/address_sorting/address_sorting.c 68@@ -1280,6 +1289,8 @@ if(gRPC_INSTALL) 69 ) 70 endif() 71 72+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 73+ 74 if(gRPC_BUILD_TESTS) 75 76 add_library(end2end_tests 77@@ -1451,6 +1462,8 @@ endforeach() 78 79 endif() 80 81+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 82+ 83 add_library(gpr 84 src/core/ext/upb-generated/google/protobuf/any.upb.c 85 src/core/ext/upb-generated/google/rpc/status.upb.c 86@@ -2373,6 +2386,8 @@ if(gRPC_INSTALL) 87 ) 88 endif() 89 90+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 91+ 92 if(gRPC_BUILD_TESTS) 93 94 add_library(grpc_test_util 95@@ -2511,6 +2526,8 @@ endif() 96 97 endif() 98 99+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 100+ 101 add_library(grpc_unsecure 102 src/core/ext/filters/census/grpc_context.cc 103 src/core/ext/filters/channel_idle/channel_idle_filter.cc 104@@ -2916,6 +2933,8 @@ if(gRPC_INSTALL) 105 ) 106 endif() 107 108+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 109+ 110 if(gRPC_BUILD_TESTS) 111 112 if(gRPC_BUILD_CODEGEN) 113@@ -2987,6 +3006,8 @@ endif() 114 115 endif() 116 117+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 118+ 119 add_library(grpc++ 120 src/core/ext/transport/binder/client/binder_connector.cc 121 src/core/ext/transport/binder/client/channel_create.cc 122@@ -3463,6 +3484,7 @@ if(gRPC_INSTALL) 123 ) 124 endif() 125 126+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 127 128 if(gRPC_BUILD_CODEGEN) 129 add_library(grpc++_reflection 130@@ -3705,6 +3727,8 @@ target_link_libraries(grpc++_test_util 131 132 endif() 133 134+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 135+ 136 add_library(grpc++_unsecure 137 src/cpp/client/channel_cc.cc 138 src/cpp/client/client_callback.cc 139@@ -4023,6 +4047,7 @@ if(gRPC_INSTALL) 140 ) 141 endif() 142 143+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 144 145 add_library(grpc_plugin_support 146 src/compiler/cpp_generator.cc 147@@ -4082,7 +4107,7 @@ foreach(_hdr 148 endforeach() 149 150 151-if(gRPC_INSTALL) 152+if(gRPC_INSTALL OR gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 153 install(TARGETS grpc_plugin_support EXPORT gRPCTargets 154 RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} 155 BUNDLE DESTINATION ${gRPC_INSTALL_BINDIR} 156@@ -4166,6 +4191,8 @@ endif() 157 158 endif() 159 160+if(NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 161+ 162 add_library(upb 163 third_party/upb/third_party/utf8_range/naive.c 164 third_party/upb/third_party/utf8_range/range2-neon.c 165@@ -4256,6 +4283,8 @@ target_link_libraries(gen_hpack_tables 166 gpr 167 ) 168 169+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 170+ 171 172 if(gRPC_BUILD_TESTS) 173 174@@ -11228,7 +11257,7 @@ target_link_libraries(grpc_cli 175 176 177 endif() 178-if(gRPC_BUILD_CODEGEN AND gRPC_BUILD_GRPC_CPP_PLUGIN) 179+if(gRPC_BUILD_GRPC_CPP_PLUGIN) 180 181 add_executable(grpc_cpp_plugin 182 src/compiler/cpp_plugin.cc 183@@ -11258,7 +11287,7 @@ target_link_libraries(grpc_cpp_plugin 184 185 186 187-if(gRPC_INSTALL) 188+if(gRPC_INSTALL OR gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 189 install(TARGETS grpc_cpp_plugin EXPORT gRPCTargets 190 RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} 191 BUNDLE DESTINATION ${gRPC_INSTALL_BINDIR} 192@@ -19803,7 +19832,7 @@ endif() 193 194 195 196- 197+if (NOT gRPC_BUILD_PLUGIN_SUPPORT_ONLY) 198 199 if(gRPC_INSTALL) 200 install(EXPORT gRPCTargets 201@@ -19900,3 +19929,5 @@ generate_pkgconfig( 202 "-lgrpc++_unsecure" 203 "" 204 "grpc++_unsecure.pc") 205+ 206+endif() # gRPC_BUILD_PLUGIN_SUPPORT_ONLY 207