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

Kirill Bobyrev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 21 05:59:52 PDT 2020


kbobyrev updated this revision to Diff 279497.
kbobyrev added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Check gRPC version for system-installed APT package on Debian-like Linux
distros.


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
@@ -6,7 +6,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})
@@ -29,6 +29,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.
@@ -52,6 +53,24 @@
         link_directories(${PROTOBUF_HOMEBREW_PATH}/lib)
       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.279497.patch
Type: text/x-patch
Size: 2575 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200721/9d73c875/attachment.bin>


More information about the llvm-commits mailing list