From 8d2a059279cffab502b2810188d63905c209782a Mon Sep 17 00:00:00 2001
From: "H. Joe Lee" <hyoklee@hdfgroup.org>
Date: Wed, 16 Oct 2024 16:33:05 -0500
Subject: hermes: add more versions, variants and depend on hermes-shm (#46602)

Co-authored-by: Bernhard Kaindl <bernhardkaindl7@gmail.com>
---
 var/spack/repos/builtin/packages/adios2/package.py |   6 +-
 .../repos/builtin/packages/hermes-shm/package.py   |   3 +-
 var/spack/repos/builtin/packages/hermes/package.py | 104 +++++++++++++---
 .../repos/builtin/packages/libcatalyst/package.py  |   1 +
 var/spack/repos/builtin/packages/margo/package.py  | 135 ---------------------
 5 files changed, 90 insertions(+), 159 deletions(-)
 delete mode 100644 var/spack/repos/builtin/packages/margo/package.py

diff --git a/var/spack/repos/builtin/packages/adios2/package.py b/var/spack/repos/builtin/packages/adios2/package.py
index a5baeb0cbd..16481106dc 100644
--- a/var/spack/repos/builtin/packages/adios2/package.py
+++ b/var/spack/repos/builtin/packages/adios2/package.py
@@ -45,9 +45,9 @@ class Adios2(CMakePackage, CudaPackage, ROCmPackage):
     version("2.4.0", sha256="50ecea04b1e41c88835b4b3fd4e7bf0a0a2a3129855c9cc4ba6cf6a1575106e2")
     version("2.3.1", sha256="3bf81ccc20a7f2715935349336a76ba4c8402355e1dc3848fcd6f4c3c5931893")
 
-    depends_on("c", type="build")  # generated
-    depends_on("cxx", type="build")  # generated
-    depends_on("fortran", type="build")  # generated
+    depends_on("c", type="build")
+    depends_on("cxx", type="build")
+    depends_on("fortran", type="build")
 
     # There's not really any consistency about how static and shared libs are
     # implemented across spack.  What we're trying to support is specifically three
diff --git a/var/spack/repos/builtin/packages/hermes-shm/package.py b/var/spack/repos/builtin/packages/hermes-shm/package.py
index 6b51724548..f93300553a 100644
--- a/var/spack/repos/builtin/packages/hermes-shm/package.py
+++ b/var/spack/repos/builtin/packages/hermes-shm/package.py
@@ -40,7 +40,8 @@ class HermesShm(CMakePackage):
     depends_on("pkgconfig", type="build")
     depends_on("catch2@3.0.1")
     depends_on("yaml-cpp")
-    depends_on("doxygen@1.9.3", type="build")
+    depends_on("doxygen@1.9.3:", type="build")
+    depends_on("pkgconfig", type="build")
     depends_on("libelf")
 
     # Machine variants
diff --git a/var/spack/repos/builtin/packages/hermes/package.py b/var/spack/repos/builtin/packages/hermes/package.py
index 7072524c53..fa04336fc6 100644
--- a/var/spack/repos/builtin/packages/hermes/package.py
+++ b/var/spack/repos/builtin/packages/hermes/package.py
@@ -11,38 +11,102 @@ class Hermes(CMakePackage):
     I/O buffering system that aims to significantly accelerate I/O performance.
     """
 
-    homepage = "http://www.cs.iit.edu/~scs/assets/projects/Hermes/Hermes.html"
+    homepage = "https://grc.iit.edu/research/projects/hermes"
     git = "https://github.com/HDFGroup/hermes.git"
 
-    maintainers("hyoklee")
+    maintainers("lukemartinlogan", "hyoklee")
 
-    license("GPL-2.0-only")
+    version("master", branch="master", submodules=True)
 
-    version("master", branch="master")
+    version(
+        "1.2.1",
+        url="https://github.com/HDFGroup/hermes/archive/refs/tags/v1.2.1.tar.gz",
+        sha256="d60ee5d6856dc1a1f389fb08f61252cc7736d1c38d3049043749640897fe3b6d",
+    )
     version(
         "0.9.0-beta",
         url="https://github.com/HDFGroup/hermes/archive/refs/tags/v0.9.0-beta.tar.gz",
         sha256="abf258a52fa79729dfeb28559957abf8945f3ad37cadefb3bc685227c5f057a8",
     )
 
-    depends_on("c", type="build")  # generated
-    depends_on("cxx", type="build")  # generated
-
+    variant("adios", default=False, description="Build Adios tests")
+    variant("ares", default=False, description="Enable full libfabric install")
+    variant("compress", default=False, description="Enable compression")
+    variant("encrypt", default=False, description="Enable encryption")
+    variant("mpiio", default=True, description="Enable MPI I/O adapter")
+    # Builds with hermes@master. 1.2.1, we'd need to extract pybind11 source in external/pybind11:
+    variant("python", default=False, description="Build Python Wrapper", when="@master")
+    variant("stdio", default=True, description="Enable STDIO adapter")
     variant("vfd", default=False, description="Enable HDF5 VFD")
+    variant("zmq", default=False, description="Build ZeroMQ tests")
+
+    depends_on("c", type="build")
+    depends_on("cxx", type="build")
+    depends_on("pkgconfig", type="build")
+    depends_on("libelf")
+
+    depends_on("hermes-shm@master+boost+cereal+mochi")
+
+    depends_on("hermes-shm+adios", when="+adios")
+    depends_on("hermes-shm+ares", when="+ares")
+    depends_on("hermes-shm+compress", when="+compress")
+    depends_on("hermes-shm+encrypt", when="+encrypt")
+    depends_on("hermes-shm+mpiio", when="+mpiio")
+    depends_on("hermes-shm+vfd", when="+vfd")
+    depends_on("hermes-shm+zmq", when="+zmq")
 
-    depends_on("mochi-thallium~cereal@0.8:")
-    depends_on("catch2")
-    depends_on("glpk")
-    depends_on("glog@0.4.0:")
-    depends_on("mpi")
-    depends_on("hdf5@1.14.0:", when="+vfd")
-    depends_on("yaml-cpp")
+    depends_on("py-jarvis-util", type="test")
+
+    depends_on("mpi", when="+mpiio")
+    conflicts("^[virtuals=mpi] nvhpc", when="+mpiio", msg="+mpio does not support nvhpc MPI")
 
     def cmake_args(self):
-        args = [
-            self.define("HERMES_RPC_THALLIUM", True),
-            self.define("HERMES_INSTALL_TESTS", True),
-            self.define("BUILD_TESTING", True),
-            self.define_from_variant("HERMES_ENABLE_VFD", "vfd"),
-        ]
+        args = []
+        if "+mpiio" in self.spec:
+            args.append("-DHERMES_ENABLE_MPIIO_ADAPTER=ON")
+            mpi_name = self.spec["mpi"].name
+            if mpi_name == "openmpi":
+                args.append("-DHERMES_OPENMPI=ON")
+            elif mpi_name == "mpich":
+                args.append("-DHERMES_MPICH=ON")
+            else:
+                raise InstallError("hermes+mpiio needs openmpi or mpich, got " + mpi_name)
+        if "+stdio" in self.spec:
+            args.append("-DHERMES_ENABLE_STDIO_ADAPTER=ON")
+        if "+vfd" in self.spec:
+            args.append("-DHERMES_ENABLE_VFD=ON")
+        if "+compress" in self.spec:
+            args.append(self.define("HERMES_ENABLE_COMPRESSION", "ON"))
+        if "+encrypt" in self.spec:
+            args.append(self.define("HERMES_ENABLE_ENCRYPTION", "ON"))
+        if "+adios" in self.spec:
+            args.append(self.define("HERMES_ENABLE_ADIOS", "ON"))
+        if "+python" in self.spec:
+            args.append(self.define("HERMES_ENABLE_PYTHON", "ON"))
         return args
+
+    def set_include(self, env, path):
+        env.append_flags("CFLAGS", "-I{}".format(path))
+        env.append_flags("CXXFLAGS", "-I{}".format(path))
+        env.prepend_path("INCLUDE", "{}".format(path))
+        env.prepend_path("CPATH", "{}".format(path))
+
+    def set_lib(self, env, path):
+        env.prepend_path("LIBRARY_PATH", path)
+        env.prepend_path("LD_LIBRARY_PATH", path)
+        env.append_flags("LDFLAGS", "-L{}".format(path))
+        env.prepend_path("PYTHONPATH", "{}".format(path))
+
+    def set_flags(self, env):
+        self.set_include(env, "{}/include".format(self.prefix))
+        self.set_include(env, "{}/include".format(self.prefix))
+        self.set_lib(env, "{}/lib".format(self.prefix))
+        self.set_lib(env, "{}/lib64".format(self.prefix))
+        env.prepend_path("CMAKE_PREFIX_PATH", "{}/cmake".format(self.prefix))
+        env.prepend_path("CMAKE_MODULE_PATH", "{}/cmake".format(self.prefix))
+
+    def setup_dependent_environment(self, spack_env, run_env, dependent_spec):
+        self.set_flags(spack_env)
+
+    def setup_run_environment(self, env):
+        self.set_flags(env)
diff --git a/var/spack/repos/builtin/packages/libcatalyst/package.py b/var/spack/repos/builtin/packages/libcatalyst/package.py
index 6bfc26cf93..bf10c56b43 100644
--- a/var/spack/repos/builtin/packages/libcatalyst/package.py
+++ b/var/spack/repos/builtin/packages/libcatalyst/package.py
@@ -27,6 +27,7 @@ class Libcatalyst(CMakePackage):
     depends_on("c", type="build")  # generated
     depends_on("cxx", type="build")  # generated
     depends_on("fortran", type="build")  # generated
+    depends_on("pkgconfig", type="build")
 
     variant("mpi", default=False, description="Enable MPI support")
     variant("conduit", default=False, description="Use external Conduit for Catalyst")
diff --git a/var/spack/repos/builtin/packages/margo/package.py b/var/spack/repos/builtin/packages/margo/package.py
deleted file mode 100644
index 399b38d63a..0000000000
--- a/var/spack/repos/builtin/packages/margo/package.py
+++ /dev/null
@@ -1,135 +0,0 @@
-# Copyright 2013-2024 Lawrence Livermore National Security, LLC and other
-# Spack Project Developers. See the top-level COPYRIGHT file for details.
-#
-# SPDX-License-Identifier: (Apache-2.0 OR MIT)
-
-from spack.package import *
-
-
-class Margo(AutotoolsPackage):
-    """A library that provides Argobots bindings to the Mercury RPC
-    implementation.  This name will be deprecated soon; please use the
-    mochi-margo package instead."""
-
-    homepage = "https://github.com/mochi-hpc/mochi-margo"
-    git = "https://github.com/mochi-hpc/mochi-margo.git"
-    url = "https://github.com/mochi-hpc/mochi-margo/archive/v0.9.tar.gz"
-
-    maintainers("carns", "mdorier", "fbudin69500")
-
-    version("master", branch="master", deprecated=True)
-    version(
-        "0.9.1",
-        sha256="3fe933f2d758ef23d582bc776e4f8cfae9bf9d0849b8b1f9d73ee024e218f2bc",
-        deprecated=True,
-    )
-    version(
-        "0.9",
-        sha256="a24376f66450cc8fd7a43043e189f8efce5a931585e53c1e2e41894a3e99b517",
-        deprecated=True,
-    )
-    version(
-        "0.7",
-        sha256="492d1afe2e7984fa638614a5d34486d2ff761f5599b5984efd5ae3f55cafde54",
-        deprecated=True,
-    )
-    version(
-        "0.7.2",
-        sha256="0ca796abdb82084813a5de033d92364910b5ad1a0df135534d6b1c36ef627859",
-        deprecated=True,
-    )
-    version(
-        "0.7.1",
-        sha256="eebbe02c47ed4c65ef1d4f23ffdc6a8aa2e2348ca6c51bfc3c4dfbf78fbfc30b",
-        deprecated=True,
-    )
-    version(
-        "0.6",
-        sha256="56feb718da2b155d7277a7b10b669516ebffaa034f811f3665ceed7ad0f19d1b",
-        deprecated=True,
-    )
-    version(
-        "0.6.4",
-        sha256="5ba1c72ee05aa9738d3dc4d6d01bd59790284c6c77b909c5d7756fe7049d6177",
-        deprecated=True,
-    )
-    version(
-        "0.6.3",
-        sha256="5f373cd554edd15cead58bd5d30093bd88d45039d06ff7738eb18b3674287c76",
-        deprecated=True,
-    )
-    version(
-        "0.6.2",
-        sha256="c6a6909439e1d3ba1a1693d8da66057eb7e4ec4b239c04bc7f19fc487c4c58da",
-        deprecated=True,
-    )
-    version(
-        "0.6.1",
-        sha256="80d8d15d0917b5522c31dc2d83136de2313d50ca05c71c5e5ad83c483a3214b7",
-        deprecated=True,
-    )
-    version(
-        "0.5",
-        sha256="d3b768b8300bc2cb87964e74c39b4e8eb9822d8a2e56fc93dc475ddcb1a868e3",
-        deprecated=True,
-    )
-    version(
-        "0.5.2",
-        sha256="73be3acaf012a85a91ac62824c93f5ee1ea0ffe4c25779ece19723f4baf9547d",
-        deprecated=True,
-    )
-    version(
-        "0.5.1",
-        sha256="6fdf58e189538e22341c8361ab069fc80fe5460a6869882359b295a890febad7",
-        deprecated=True,
-    )
-    version(
-        "0.4.7",
-        sha256="596d83b11fb2bd9950fd99c9ab12c14915ab2cda233084ae40ecae1e6c584333",
-        deprecated=True,
-    )
-    version(
-        "0.4.6",
-        sha256="b27447a2050ae61091bae3ff6b4d23a56153947f18847face9f98facbdb4e329",
-        deprecated=True,
-    )
-    version(
-        "0.4.5",
-        sha256="b0d02f73edf180f2393f54c5a980620b8d6dcd42b90efdea6866861824fa49cf",
-        deprecated=True,
-    )
-    version(
-        "0.4.4",
-        sha256="2e2e6e2a8a7d7385e2fe204c113cb149f30847f0b1f48ec8dd708a74280bd89e",
-        deprecated=True,
-    )
-    version(
-        "0.4.3",
-        sha256="61a634d6983bee2ffa06e1e2da4c541cb8f56ddd9dd9f8e04e8044fb38657475",
-        deprecated=True,
-    )
-    version(
-        "0.4.2",
-        sha256="91085e28f50e373b9616e1ae5c3c8d40a19a7d3776259592d8f361766890bcaa",
-        deprecated=True,
-    )
-
-    depends_on("c", type="build")  # generated
-
-    depends_on("json-c", when="@0.9:")
-    depends_on("autoconf@2.65:", type=("build"))
-    depends_on("m4", type=("build"))
-    depends_on("automake", type=("build"))
-    depends_on("libtool", type=("build"))
-    depends_on("pkgconfig", type=("build"))
-    depends_on("argobots@1.0:")
-    # "breadcrumb" support not available in mercury-1.0
-    depends_on("mercury@1.0.0:", type=("build", "link", "run"), when="@:0.5.1")
-    depends_on("mercury@2.0.0:", type=("build", "link", "run"), when="@0.5.2:")
-
-    # dependencies for develop version
-    depends_on("mercury@master", type=("build", "link", "run"), when="@develop")
-
-    def autoreconf(self, spec, prefix):
-        sh = which("sh")
-        sh("./prepare.sh")
-- 
cgit v1.2.3-70-g09d2