[PATCH] D84232: [clangd] Set minimum gRPC version to 1.27

Kirill Bobyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 21 02:59:42 PDT 2020


kbobyrev updated this revision to Diff 299618.
kbobyrev added a comment.

Rebase on top of master.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84232/new/

https://reviews.llvm.org/D84232

Files:
  clang-tools-extra/clangd/index/remote/README.md
  llvm/cmake/modules/FindGRPC.cmake


Index: llvm/cmake/modules/FindGRPC.cmake
===================================================================
--- llvm/cmake/modules/FindGRPC.cmake
+++ llvm/cmake/modules/FindGRPC.cmake
@@ -11,7 +11,7 @@
   set(protobuf_MODULE_COMPATIBLE TRUE)
   find_package(Protobuf CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
   message(STATUS "Using protobuf ${protobuf_VERSION}")
-  find_package(gRPC CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
+  find_package(gRPC 1.27 CONFIG REQUIRED HINTS ${GRPC_INSTALL_PATH})
   message(STATUS "Using gRPC ${gRPC_VERSION}")
 
   include_directories(${Protobuf_INCLUDE_DIRS})
@@ -41,6 +41,7 @@
   # On macOS the libraries are typically installed via Homebrew and are not on
   # the system path.
   if (${APPLE})
+    # FIXME(kirillbobyrev): Check gRPC version for macOS, too.
     find_program(HOMEBREW brew)
     # If Homebrew is not found, the user might have installed libraries
     # manually. Fall back to the system path.
@@ -78,6 +79,24 @@
                               IMPORTED_LOCATION ${PROTOBUF_LIBRARY})
       endif()
     endif()
+  elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
+    # Try to figure out gRPC version using APT for Debian-like Linux
+    # distributions.
+    find_program(APT apt)
+    if (NOT APT-NOTFOUND)
+      execute_process(COMMAND ${APT} policy libgrpc++-dev
+        OUTPUT_VARIABLE APT_GRPC_POLICY
+        RESULT_VARIABLE APT_GRPC_POLICY_RETURN_CODE)
+      if (APT_GRPC_POLICY_RETURN_CODE EQUAL "0")
+        # Parse MAJOR.MINOR gRPC version.
+        string(REGEX MATCH "Installed: ([0-9]+\\.[0-9]+)"
+          gRPC_VERSION ${APT_GRPC_POLICY})
+        if (CMAKE_MATCH_1 VERSION_LESS "1.27")
+          message(FATAL_ERROR "gRPC version rerquied: >=1.27, found: ${CMAKE_MATCH_1}")
+        endif()
+        message(STATUS "Using gRPC ${gRPC_VERSION}")
+      endif()
+    endif()
   endif()
 endif()
 
Index: clang-tools-extra/clangd/index/remote/README.md
===================================================================
--- clang-tools-extra/clangd/index/remote/README.md
+++ clang-tools-extra/clangd/index/remote/README.md
@@ -11,8 +11,9 @@
 
 ## Building
 
-This feature uses gRPC and Protobuf libraries, so you will need to install them.
-There are two ways of doing that.
+This feature uses gRPC (known to work with versions starting from 1.27.0) and
+Protobuf libraries, so you will need to install them. There are two ways of
+doing that.
 
 However you install dependencies, to enable this feature and build remote index
 tools you will need to set this CMake flag — `-DCLANGD_ENABLE_REMOTE=On`.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D84232.299618.patch
Type: text/x-patch
Size: 2590 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201021/acb3eda3/attachment.bin>


More information about the llvm-commits mailing list