kbobyrev created this revision. kbobyrev added a reviewer: kadircet. Herald added subscribers: usaxena95, arphaman, mgorny. kbobyrev requested review of this revision. Herald added subscribers: llvm-commits, cfe-commits, MaskRay, ilya-biryukov. Herald added projects: clang, LLVM.
This was originally landed without the optional part and reverted later: https://github.com/llvm/llvm-project/commit/8080ea4c4b8c456c72c617587cc32f174b3105c1 Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D98404 Files: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt clang-tools-extra/clangd/index/remote/server/Server.cpp llvm/cmake/modules/FindGRPC.cmake Index: llvm/cmake/modules/FindGRPC.cmake =================================================================== --- llvm/cmake/modules/FindGRPC.cmake +++ llvm/cmake/modules/FindGRPC.cmake @@ -18,10 +18,14 @@ # gRPC CMake CONFIG gives the libraries slightly odd names, make them match # the conventional system-installed names. - set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(protobuf ALIAS protobuf::libprotobuf) set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE) add_library(grpc++ ALIAS gRPC::grpc++) + if (ENABLE_GRPC_REFLECTION) + set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection) + endif() + set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(protobuf ALIAS protobuf::libprotobuf) set(GRPC_CPP_PLUGIN $<TARGET_FILE:gRPC::grpc_cpp_plugin>) set(PROTOC ${Protobuf_PROTOC_EXECUTABLE}) @@ -71,6 +75,11 @@ add_library(grpc++ UNKNOWN IMPORTED GLOBAL) message(STATUS "Using grpc++: " ${GRPC_LIBRARY}) set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY}) + if (ENABLE_GRPC_REFLECTION) + find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED) + add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL) + set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY}) + endif() find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED) message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY}) add_library(protobuf UNKNOWN IMPORTED GLOBAL) Index: clang-tools-extra/clangd/index/remote/server/Server.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/server/Server.cpp +++ clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -35,6 +35,10 @@ #include <memory> #include <thread> +#ifdef ENABLE_GRPC_REFLECTION +#include <grpc++/ext/proto_server_reflection_plugin.h> +#endif + namespace clang { namespace clangd { namespace remote { @@ -313,6 +317,9 @@ RemoteIndexServer Service(Index, IndexRoot); grpc::EnableDefaultHealthCheckService(true); +#ifdef ENABLE_GRPC_REFLECTION + grpc::reflection::InitProtoReflectionServerBuilderPlugin(); +#endif grpc::ServerBuilder Builder; Builder.AddListeningPort(ServerAddress.str(), grpc::InsecureServerCredentials()); Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt =================================================================== --- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt +++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt @@ -9,6 +9,11 @@ RemoteIndexServiceProto ) +if (ENABLE_GRPC_REFLECTION) + set(REFLECTION_LIBRARY grpc++_reflection) + add_definitions(-DENABLE_GRPC_REFLECTION) +endif() + target_link_libraries(clangd-index-server PRIVATE clangDaemon @@ -17,4 +22,6 @@ RemoteIndexProto RemoteIndexServiceProto clangdRemoteMarshalling + + ${REFLECTION_LIBRARY} )
Index: llvm/cmake/modules/FindGRPC.cmake =================================================================== --- llvm/cmake/modules/FindGRPC.cmake +++ llvm/cmake/modules/FindGRPC.cmake @@ -18,10 +18,14 @@ # gRPC CMake CONFIG gives the libraries slightly odd names, make them match # the conventional system-installed names. - set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE) - add_library(protobuf ALIAS protobuf::libprotobuf) set_target_properties(gRPC::grpc++ PROPERTIES IMPORTED_GLOBAL TRUE) add_library(grpc++ ALIAS gRPC::grpc++) + if (ENABLE_GRPC_REFLECTION) + set_target_properties(gRPC::grpc++_reflection PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(grpc++_reflection ALIAS gRPC::grpc++_reflection) + endif() + set_target_properties(protobuf::libprotobuf PROPERTIES IMPORTED_GLOBAL TRUE) + add_library(protobuf ALIAS protobuf::libprotobuf) set(GRPC_CPP_PLUGIN $<TARGET_FILE:gRPC::grpc_cpp_plugin>) set(PROTOC ${Protobuf_PROTOC_EXECUTABLE}) @@ -71,6 +75,11 @@ add_library(grpc++ UNKNOWN IMPORTED GLOBAL) message(STATUS "Using grpc++: " ${GRPC_LIBRARY}) set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY}) + if (ENABLE_GRPC_REFLECTION) + find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection $GRPC_OPTS REQUIRED) + add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL) + set_target_properties(grpc++_reflection PROPERTIES IMPORTED_LOCATION ${GRPC_REFLECTION_LIBRARY}) + endif() find_library(PROTOBUF_LIBRARY protobuf $PROTOBUF_OPTS REQUIRED) message(STATUS "Using protobuf: " ${PROTOBUF_LIBRARY}) add_library(protobuf UNKNOWN IMPORTED GLOBAL) Index: clang-tools-extra/clangd/index/remote/server/Server.cpp =================================================================== --- clang-tools-extra/clangd/index/remote/server/Server.cpp +++ clang-tools-extra/clangd/index/remote/server/Server.cpp @@ -35,6 +35,10 @@ #include <memory> #include <thread> +#ifdef ENABLE_GRPC_REFLECTION +#include <grpc++/ext/proto_server_reflection_plugin.h> +#endif + namespace clang { namespace clangd { namespace remote { @@ -313,6 +317,9 @@ RemoteIndexServer Service(Index, IndexRoot); grpc::EnableDefaultHealthCheckService(true); +#ifdef ENABLE_GRPC_REFLECTION + grpc::reflection::InitProtoReflectionServerBuilderPlugin(); +#endif grpc::ServerBuilder Builder; Builder.AddListeningPort(ServerAddress.str(), grpc::InsecureServerCredentials()); Index: clang-tools-extra/clangd/index/remote/server/CMakeLists.txt =================================================================== --- clang-tools-extra/clangd/index/remote/server/CMakeLists.txt +++ clang-tools-extra/clangd/index/remote/server/CMakeLists.txt @@ -9,6 +9,11 @@ RemoteIndexServiceProto ) +if (ENABLE_GRPC_REFLECTION) + set(REFLECTION_LIBRARY grpc++_reflection) + add_definitions(-DENABLE_GRPC_REFLECTION) +endif() + target_link_libraries(clangd-index-server PRIVATE clangDaemon @@ -17,4 +22,6 @@ RemoteIndexProto RemoteIndexServiceProto clangdRemoteMarshalling + + ${REFLECTION_LIBRARY} )
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits