kbobyrev created this revision.
kbobyrev added a reviewer: sammccall.
Herald added subscribers: llvm-commits, cfe-commits, usaxena95, kadircet, 
arphaman, jkorous, MaskRay, ilya-biryukov, mgorny.
Herald added projects: clang, LLVM.

Generated Protobuf library has to be in CLANG_EXPORTS and should also be
installed appropriately. The easiest way to do that is via CMake's
add_clang_library. That unfortunately applies "one directory - one
clang_(library|tool)" policy so .proto files should be in a separate directory
and complicates the layout.

This setup works both in shared and static libs mode.

Resolves: https://github.com/clangd/clangd/issues/351


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78885

Files:
  clang-tools-extra/clangd/index/remote/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/Index.proto
  clang-tools-extra/clangd/index/remote/protos/CMakeLists.txt
  clang-tools-extra/clangd/index/remote/protos/Index.proto
  llvm/cmake/modules/FindGRPC.cmake

Index: llvm/cmake/modules/FindGRPC.cmake
===================================================================
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -45,6 +45,6 @@
           "${ProtoSourceAbsolutePath}"
           DEPENDS "${ProtoSourceAbsolutePath}")
 
-  add_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource})
-  target_link_libraries(${LibraryName} grpc++ protobuf)
+  add_clang_library(${LibraryName} ${GeneratedProtoSource} ${GeneratedGRPCSource}
+    LINK_LIBS grpc++ protobuf)
 endfunction()
Index: clang-tools-extra/clangd/index/remote/Index.proto
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/Index.proto
@@ -1,69 +0,0 @@
-//===--- Index.proto - Remote index Protocol Buffers definition -----------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-syntax = "proto3";
-
-package clang.clangd.remote;
-
-service SymbolIndex {
-  rpc Lookup(LookupRequest) returns (stream LookupReply) {}
-
-  rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
-
-  rpc Refs(RefsRequest) returns (stream RefsReply) {}
-}
-
-message LookupRequest { repeated string ids = 1; }
-
-// The response is a stream of symbol messages and the terminating message
-// indicating the end of stream.
-message LookupReply {
-  oneof kind {
-    Symbol stream_result = 1;
-    bool final_result = 2;
-  }
-}
-
-message FuzzyFindRequest {
-  string query = 1;
-  repeated string scopes = 2;
-  bool any_scope = 3;
-  uint32 limit = 4;
-  bool resricted_for_code_completion = 5;
-  repeated string proximity_paths = 6;
-  repeated string preferred_types = 7;
-}
-
-// The response is a stream of symbol messages, and one terminating has_more
-// message.
-message FuzzyFindReply {
-  oneof kind {
-    Symbol stream_result = 1;
-    bool final_result = 2; // HasMore
-  }
-}
-
-message RefsRequest {
-  repeated string ids = 1;
-  uint32 filter = 2;
-  uint32 limit = 3;
-}
-
-// The response is a stream of reference messages, and one terminating has_more
-// message.
-message RefsReply {
-  oneof kind {
-    Ref stream_result = 1;
-    bool final_result = 2; // HasMore
-  }
-}
-
-// FIXME(kirillbobyrev): Properly serialize symbols and refs instead of passing
-// YAML.
-message Ref { string yaml_serialization = 1; }
-message Symbol { string yaml_serialization = 1; }
Index: clang-tools-extra/clangd/index/remote/protos/CMakeLists.txt
===================================================================
--- /dev/null
+++ clang-tools-extra/clangd/index/remote/protos/CMakeLists.txt
@@ -0,0 +1 @@
+generate_grpc_protos(RemoteIndexProtos "Index.proto")
Index: clang-tools-extra/clangd/index/remote/CMakeLists.txt
===================================================================
--- clang-tools-extra/clangd/index/remote/CMakeLists.txt
+++ clang-tools-extra/clangd/index/remote/CMakeLists.txt
@@ -1,6 +1,6 @@
 if (CLANGD_ENABLE_REMOTE)
-  generate_grpc_protos(RemoteIndexProtos "Index.proto")
-  include_directories(${CMAKE_CURRENT_BINARY_DIR})
+  add_subdirectory(protos)
+  include_directories(${CMAKE_CURRENT_BINARY_DIR}/protos)
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
 
   # FIXME(kirillbobyrev): target_compile_definitions is not working with
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to