From 4706a2b39491e490b27151f730b0ffe85ee1625e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Eric=20M=C3=BCller?= <mueller@kip.uni-heidelberg.de>
Date: Wed, 2 Oct 2024 13:33:22 +0200
Subject: [PATCH] feat(BSS2): add quiggeldy (service) [DO-NOT-MERGE]

---
 packages/quiggeldy/package.py | 62 +++++++++++++++++++++++++++++++++++
 spack.yaml                    |  2 ++
 2 files changed, 64 insertions(+)
 create mode 100644 packages/quiggeldy/package.py

diff --git a/packages/quiggeldy/package.py b/packages/quiggeldy/package.py
new file mode 100644
index 00000000..999644d9
--- /dev/null
+++ b/packages/quiggeldy/package.py
@@ -0,0 +1,62 @@
+# 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)
+
+import os
+import unittest.mock
+import xml.etree.ElementTree as ET
+
+from spack import *
+from spack.util.environment import EnvironmentModifications
+import spack.build_environment
+
+import importlib
+build_brainscales = importlib.import_module("spack.pkg.ebrains-spack-builds.build_brainscales")
+
+
+class Quiggeldy(build_brainscales.BuildBrainscales):
+    """quiggeldy --- the low-latency/high-throughput BSS-2 nmhw resource scheduler"""
+
+    homepage = "https://github.com/electronicvisions/hxcomm"
+    git      = "https://github.com/electronicvisions/hxcomm"
+
+    maintainers = ["emuller", "muffgaga"]
+
+    # host software dependencies
+    depends_on('bitsery', type=('build', 'link', 'run', 'test'))
+    depends_on('binutils+gold+ld+plugins', type=('build', 'link', 'run')) # specialize
+    depends_on('boost@1.69.0: +graph+icu+mpi+numpy+coroutine+context+filesystem+python+serialization+system+thread+program_options cxxstd=17', type=('build', 'link', 'run', 'test'))
+    depends_on('cereal', type=('build', 'link', 'run', 'test'))
+    depends_on('cppcheck', type=('build', 'link', 'run'))
+    depends_on('gflags', type=('build', 'link', 'run'))
+    depends_on('googletest@1.11.0:+gmock', type=('build', 'link', 'run')) # variadic templates needed
+    depends_on('liblockfile', type=('build', 'link', 'run'))
+    depends_on('log4cxx@0.12.1:1.0', when="@:8.0-a3", type=('build', 'link', 'run'))
+    depends_on('log4cxx@1.1: +events_at_exit', when="@8.0-a4:", type=('build', 'link', 'run'))
+    depends_on('pkgconfig', type=('build', 'link', 'run'))
+    depends_on('psmisc', type=('run', 'test'))
+    depends_on('util-linux', type=('build', 'link', 'run'))
+    depends_on('yaml-cpp+shared', type=('build', 'link', 'run'))
+
+    # override configure step as we only want to build quiggeldy from hxcomm
+    def configure(self, spec, prefix):
+        args = ['--prefix={0}'.format(self.prefix)]
+        args += self.configure_args()
+
+        if spec.version >= Version("9"):
+            self.waf('setup', '--directory=hxcomm', '--repo-db-url=https://github.com/electronicvisions/projects')
+        self.waf('configure', '--build-profile=release', '--disable-doxygen', *args)
+
+    def build_args(self):
+        args = super(BuildBrainscales, self).build_args()
+        args.append("--targets=quiggeldy")
+        return args
+
+    def install_test(self):
+        with working_dir('spack-test', create=True):
+            old_pythonpath = os.environ.get('PYTHONPATH', '')
+            os.environ['PYTHONPATH'] = ':'.join([str(self.prefix.lib), old_pythonpath])
+            bash = which("bash")
+            # ignore segfaults for now (exit code 139)
+            bash('-c', '(python -c "import hxtorch; print(hxtorch.__file__)" || ( test $? -eq 139 && echo "segfault")) || exit $?')
diff --git a/spack.yaml b/spack.yaml
index 6f227366..aa044218 100644
--- a/spack.yaml
+++ b/spack.yaml
@@ -70,5 +70,7 @@ spack:
     #- py-cerebstats
     #- py-cerebunit
     #- py-morphounit@1.0.4
+    # Services
+    - quiggeldy@9.0-a4
   concretizer:
     unify: true
-- 
GitLab