Skip to content

Commit bef2425

Browse files
Merge pull request #318 from GEOS-DEV/msek/grpc-linking-spack
Add gRPC dependency using spack
2 parents 10adf8c + 1b7324d commit bef2425

File tree

3 files changed

+101
-0
lines changed

3 files changed

+101
-0
lines changed

scripts/spack_configs/pangea-4/spack.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ spack:
7272
buildable: false
7373

7474
####
75+
# packages necessary on pangea4 when +grpc configuration is requested
76+
protobuf:
77+
require: "@3.26.1"
78+
grpc:
79+
require: "@1.64.0-full-clone"
80+
7581
# spec of spack packages to reuse
7682

7783
intel-oneapi-mkl:

scripts/spack_packages/packages/geosx/package.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Geosx(CMakePackage, CudaPackage, ROCmPackage):
7171
description='Linear algebra interface.',
7272
values=('trilinos', 'hypre', 'petsc'),
7373
multi=False)
74+
variant('grpc', default=False, description='Enable gRPC.')
7475
variant('pygeosx', default=True, description='Enable pygeosx.')
7576

7677
# SPHINX_END_VARIANTS
@@ -206,6 +207,7 @@ class Geosx(CMakePackage, CudaPackage, ROCmPackage):
206207
# Other
207208
#
208209
depends_on("mathpresso cxxflags='-fPIC'", when='+mathpresso')
210+
depends_on('grpc', when='+grpc')
209211

210212
# SPHINX_END_DEPENDS
211213

@@ -640,6 +642,17 @@ def geos_hostconfig(self, spec, prefix, py_site_pkgs_dir=None):
640642
cfg.write(cmake_cache_option('ENABLE_MATHPRESSO', False))
641643
cfg.write(cmake_cache_option('ENABLE_XML_UPDATES', False))
642644

645+
if '+grpc' in spec:
646+
cfg.write(cmake_cache_option('ENABLE_GRPC', True))
647+
cfg.write(cmake_cache_entry('GRPC_DIR', spec['grpc'].prefix))
648+
cfg.write(cmake_cache_entry('OPENSSL_DIR', spec['openssl'].prefix))
649+
cfg.write(cmake_cache_entry('ABSL_DIR', spec['abseil-cpp'].prefix))
650+
cfg.write(cmake_cache_entry('RE2_DIR', spec['re2'].prefix))
651+
cfg.write(cmake_cache_entry('C-ARES_DIR', spec['c-ares'].prefix))
652+
cfg.write(cmake_cache_entry('PROTOBUF_DIR', spec['protobuf'].prefix))
653+
else:
654+
cfg.write(cmake_cache_option('ENABLE_GRPC', False))
655+
643656
if '+shared' in spec:
644657
cfg.write(cmake_cache_option('GEOS_BUILD_SHARED_LIBS', True))
645658
else:
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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

Comments
 (0)