|
| 1 | +# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other |
| 2 | +# Spack Project Developers. See the top-level COPYRIGHT file for details. |
| 3 | +# |
| 4 | +# SPDX-License-Identifier: (Apache-2.0 OR MIT) |
| 5 | +from spack.package import * |
| 6 | + |
| 7 | + |
| 8 | +class Grpc(CMakePackage): |
| 9 | + """A high performance, open-source universal RPC framework.""" |
| 10 | + |
| 11 | + homepage = "https://grpc.io" |
| 12 | + url = "https://github.com/grpc/grpc/archive/v1.59.1.tar.gz" |
| 13 | + |
| 14 | + license("Apache-2.0 AND BSD-3-Clause AND MIT") |
| 15 | + |
| 16 | + # Provide a full clone of the grpc repo with all submodules to avoid |
| 17 | + # download issues when building behind a proxy. |
| 18 | + # Steps to create the tar-ball for a different version (replace 1.64.0 with |
| 19 | + # desired version): |
| 20 | + # $ git clone -b v1.64.0 --recurse-submodules https://github.com/grpc/grpc.git |
| 21 | + # $ mv grpc grpc-1.64.0-full-clone |
| 22 | + # $ tar cfvz grpc-1.64.0-full-clone.tar.gz grpc-1.64.0-full-clone |
| 23 | + # $ sha256sum grpc-1.64.0-full-clone.tar.gz |
| 24 | + # $ spack checksum grpc-1.64.0-full-clone.tar.gz |
| 25 | + # Then place the tar-ball in a mirror directory under grpc subdirectory and |
| 26 | + # pass the --mirror path-to-mirror-directory option to uberenv.py command. |
| 27 | + version("1.64.0-full-clone", sha256="a03fa383b885b325277580f9db50bad8608503a68720ebc2eb09474c23c46a36") |
| 28 | + |
| 29 | + depends_on("c", type="build") |
| 30 | + depends_on("cxx", type="build") |
| 31 | + |
| 32 | + variant("shared", default=False, description="Build shared instead of static libraries") |
| 33 | + variant( |
| 34 | + "codegen", |
| 35 | + default=True, |
| 36 | + description="Builds code generation plugins for protobuf " "compiler (protoc)", |
| 37 | + ) |
| 38 | + variant( |
| 39 | + "cxxstd", |
| 40 | + default="11", |
| 41 | + values=("11", "14", "17"), |
| 42 | + multi=False, |
| 43 | + description="Use the specified C++ standard when building.", |
| 44 | + ) |
| 45 | + |
| 46 | + depends_on("protobuf") |
| 47 | + depends_on("protobuf@3.22:", when="@1.55:") |
| 48 | + depends_on("openssl") |
| 49 | + depends_on("zlib-api") |
| 50 | + depends_on("c-ares") |
| 51 | + |
| 52 | + with when("@1.27:"): |
| 53 | + depends_on("abseil-cpp") |
| 54 | + # missing includes: https://github.com/grpc/grpc/commit/bc044174401a0842b36b8682936fc93b5041cf88 |
| 55 | + depends_on("abseil-cpp@:20230802", when="@:1.61") |
| 56 | + |
| 57 | + depends_on("re2+pic@2023-09-01", when="@1.33.1:") |
| 58 | + |
| 59 | + def cmake_args(self): |
| 60 | + args = [ |
| 61 | + self.define_from_variant("BUILD_SHARED_LIBS", "shared"), |
| 62 | + self.define_from_variant("gRPC_BUILD_CODEGEN", "codegen"), |
| 63 | + self.define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"), |
| 64 | + "-DgRPC_BUILD_CSHARP_EXT:Bool=OFF", |
| 65 | + "-DgRPC_INSTALL:Bool=ON", |
| 66 | + # Tell grpc to skip vendoring and look for deps via find_package: |
| 67 | + "-DgRPC_CARES_PROVIDER:String=package", |
| 68 | + "-DgRPC_ZLIB_PROVIDER:String=package", |
| 69 | + "-DgRPC_SSL_PROVIDER:String=package", |
| 70 | + "-DgRPC_PROTOBUF_PROVIDER:String=package", |
| 71 | + "-DgRPC_USE_PROTO_LITE:Bool=OFF", |
| 72 | + "-DgRPC_PROTOBUF_PACKAGE_TYPE:String=CONFIG", |
| 73 | + # Disable tests: |
| 74 | + "-DgRPC_BUILD_TESTS:BOOL=OFF", |
| 75 | + "-DgRPC_GFLAGS_PROVIDER:String=none", |
| 76 | + "-DgRPC_BENCHMARK_PROVIDER:String=none", |
| 77 | + ] |
| 78 | + if self.spec.satisfies("@1.27.0:"): |
| 79 | + args.append("-DgRPC_ABSL_PROVIDER:String=package") |
| 80 | + if self.spec.satisfies("@1.33.1:"): |
| 81 | + args.append("-DgRPC_RE2_PROVIDER:String=package") |
| 82 | + return args |
0 commit comments