diff --git a/packages/brainscales-logger/package.py b/packages/brainscales-logger/package.py new file mode 100644 index 0000000000000000000000000000000000000000..ac535df8bcd1920091c9d83640d4e65c565010bf --- /dev/null +++ b/packages/brainscales-logger/package.py @@ -0,0 +1,180 @@ +# 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 BrainscalesLogger(WafPackage): + """Testing log4cxx""" + + homepage = "https://github.com/electronicvisions/pynn-brainscales" + # This repo provides a custom waf binary used for the build below + git = "https://github.com/electronicvisions/pynn-brainscales.git" + + maintainers = ['emuller'] + + version('8.0-a5', tag='logger-8.0-a5') + version('8.0-a4', tag='logger-8.0-a4') + + depends_on('git', type=('build', 'link')) + depends_on('py-git-review', type=('build', 'link')) + # 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('genpybind@ebrains', type=('build', 'link')) + depends_on('gflags', type=('build', 'link', 'run')) + depends_on('googletest@1.11.0:+gmock', type=('build', 'link', 'run')) # variadic templates needed + depends_on('inja', type=('build', 'link', 'run', 'test')) # template engine for PPU source jit generation + depends_on('intel-tbb', type=('build', 'link', 'run')) # ppu gdbserver + depends_on('libelf', type=('build', 'link', 'run')) + depends_on('liblockfile', type=('build', 'link', 'run')) + depends_on('log4cxx-test@0.12.1:1.0', when="@:8.0-a3", type=('build', 'link', 'run')) + depends_on('log4cxx-test@1.1:', when="@8.0-a4:", type=('build', 'link', 'run')) + depends_on('pkgconfig', type=('build', 'link', 'run')) + depends_on('psmisc', type=('run', 'test')) + depends_on('python@3.7.0:', type=('build', 'link', 'run')) # BrainScaleS-2 only supports Python >= 3.7 + depends_on('py-deap@1.3.1:', type=('build', 'link', 'run')) + depends_on('py-h5py', type=('build', 'link', 'run')) # PyNN tests need it + depends_on('py-matplotlib', type=('build', 'link', 'run')) + depends_on('py-nose', type=('build', 'link', 'run')) + depends_on('py-numpy', type=('build', 'link', 'run')) + depends_on('py-pybind11', type=('build', 'link', 'run')) + depends_on('py-pybind11-stubgen', type=('build', 'link', 'run')) + depends_on('py-pycodestyle', type=('build', 'link', 'run')) + depends_on('py-pyelftools', type=('build', 'link', 'run')) + depends_on('py-pylint', type=('build', 'link', 'run')) + depends_on('py-pynn@0.9.4:', type=('build', 'link', 'run')) + depends_on('py-pyyaml', type=('build', 'link', 'run')) + depends_on('py-scipy', type=('build', 'link', 'run')) + depends_on('py-sqlalchemy', type=('build', 'link', 'run')) + depends_on('util-linux', type=('build', 'link', 'run')) + depends_on('yaml-cpp+shared', type=('build', 'link', 'run')) + extends('python') + + def do_fetch(self, mirror_only=False): + """Setup the project.""" + + self.stage.create() + self.stage.fetch(mirror_only) + + # if fetcher didn't do anything, it's cached already + if not os.path.exists(self.stage.source_path): + return + + with working_dir(self.stage.source_path): + python = which('python3') + python('./waf', 'setup', '--repo-db-url=https://github.com/electronicvisions/projects', + '--clone-depth=2', + '--project=logger', + '--release-branch=ebrains-' + str(self.spec.version) + ) + python('./waf', 'setup', + '--directory=logger', + '--directory=logger/pylogging', + ) + + # in the configure step, we need access to all archived .git folders + def custom_archive(self, destination): + super(spack.fetch_strategy.GitFetchStrategy, self).archive(destination) + with unittest.mock.patch('spack.fetch_strategy.GitFetchStrategy.archive', new=custom_archive): + self.stage.cache_local() + + def _setup_common_env(self, env): + # grenade needs to find some libraries for the JIT-compilation of + # programs for BrainScaleS-2's embedded processor. + ppu_include_dirs = [] + ppu_dep_names = ['bitsery', 'boost', 'cereal'] + for ppu_dep_name in ppu_dep_names: + dep = self.spec[ppu_dep_name] + dep_include_dirs = set(dep.headers.directories) + ppu_include_dirs.extend(list(dep_include_dirs)) + for dir in reversed(ppu_include_dirs): + env.prepend_path("C_INCLUDE_PATH", dir) + env.prepend_path("CPLUS_INCLUDE_PATH", dir) + + def setup_build_environment(self, env): + my_envmod = EnvironmentModifications(env) + spack.build_environment.set_wrapper_variables(self, my_envmod) + my_env = {} + my_envmod.apply_modifications(my_env) + + def get_path(env, name): + path = env.get(name, "").strip() + if path: + return path.split(os.pathsep) + return [] + + # spack tries to find headers and libraries by itself (i.e. it's not + # relying on the compiler to find it); we explicitly expose the + # spack-provided env vars that contain include and library paths + if 'SPACK_INCLUDE_DIRS' in my_env: + for dir in reversed(get_path(my_env, "SPACK_INCLUDE_DIRS")): + env.prepend_path("C_INCLUDE_PATH", dir) + env.prepend_path("CPLUS_INCLUDE_PATH", dir) + if 'SPACK_LINK_DIRS' in my_env: + for dir in reversed(get_path(my_env, "SPACK_LINK_DIRS")): + env.prepend_path("LIBRARY_PATH", dir) + env.prepend_path("LD_LIBRARY_PATH", dir) + for dir in reversed(self.compiler.implicit_rpaths()): + env.prepend_path("LIBRARY_PATH", dir) + # technically this is probably not needed for the non-configure steps + env.prepend_path("LD_LIBRARY_PATH", dir) + + def setup_dependent_build_environment(self, env, dependent_spec): + self._setup_common_env(env) + + def setup_run_environment(self, env): + self._setup_common_env(env) + + def setup_dependent_run_environment(self, env, dependent_spec): + self._setup_common_env(env) + + # override configure step as we perform a project setup first + def configure(self, spec, prefix): + """Configure the project.""" + + args = ['--prefix={0}'.format(self.prefix)] + args += self.configure_args() + self.waf('configure', '--build-profile=release', *args) + + def build_args(self): + args = ['--keep', '--test-execnone', '-v'] + return args + + def build_test(self): + self.builder.waf('build', '--test-execall') + copy_tree('build/test_results', join_path(self.prefix, '.build')) + copy_tree('build/test_results', join_path(self.stage.path, ".install_time_tests")) + ## propagate failures from junit output to spack + #tree = ET.parse('build/test_results/summary.xml') + #for testsuite in tree.getroot(): + # for testcase in testsuite: + # if (testcase.get('name').startswith("pycodestyle") or + # testcase.get('name').startswith("pylint")): + # continue + # for elem in testcase: + # if (elem.tag == 'failure') and not ( + # elem.get('message').startswith("pylint:") or + # elem.get('message').startswith("pycodestyle:") or + # ("OK" in elem.get('message') and "Segmentation fault" in elem.get('message'))): + # raise RuntimeError("Failed test found: {}".format(testcase.get('name'))) + + 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") + bash('-c', 'python -c "import pylogging; logger1 = pylogging.get(\'test\'); pylogging.set_loglevel(logger1, pylogging.LogLevel.WARN)"') diff --git a/packages/log4cxx-test/log4cxx-0.10.0-missing_includes.patch b/packages/log4cxx-test/log4cxx-0.10.0-missing_includes.patch new file mode 100644 index 0000000000000000000000000000000000000000..6834648d09a826c18cf5755c406006c16accc36d --- /dev/null +++ b/packages/log4cxx-test/log4cxx-0.10.0-missing_includes.patch @@ -0,0 +1,38 @@ +diff -Naur apache-log4cxx-0.10.0.orig/src/examples/cpp/console.cpp apache-log4cxx-0.10.0/src/examples/cpp/console.cpp +--- apache-log4cxx-0.10.0.orig/src/examples/cpp/console.cpp 2008-04-01 00:34:52.000000000 +0200 ++++ apache-log4cxx-0.10.0/src/examples/cpp/console.cpp 2008-05-06 05:40:52.000000000 +0200 +@@ -15,7 +15,10 @@ + * limitations under the License. + */ + +-#include <stdlib.h> ++#include <cstdio> ++#include <cstdlib> ++#include <cstring> ++#include <stdint.h> + #include <log4cxx/logger.h> + #include <log4cxx/consoleappender.h> + #include <log4cxx/simplelayout.h> +diff -Naur apache-log4cxx-0.10.0.orig/src/main/cpp/inputstreamreader.cpp apache-log4cxx-0.10.0/src/main/cpp/inputstreamreader.cpp +--- apache-log4cxx-0.10.0.orig/src/main/cpp/inputstreamreader.cpp 2008-04-01 00:34:09.000000000 +0200 ++++ apache-log4cxx-0.10.0/src/main/cpp/inputstreamreader.cpp 2008-05-06 05:32:31.000000000 +0200 +@@ -21,6 +21,8 @@ + #include <log4cxx/helpers/pool.h> + #include <log4cxx/helpers/bytebuffer.h> + ++#include <cstring> ++ + using namespace log4cxx; + using namespace log4cxx::helpers; + +diff -Naur apache-log4cxx-0.10.0.orig/src/main/cpp/socketoutputstream.cpp apache-log4cxx-0.10.0/src/main/cpp/socketoutputstream.cpp +--- apache-log4cxx-0.10.0.orig/src/main/cpp/socketoutputstream.cpp 2008-04-01 00:34:09.000000000 +0200 ++++ apache-log4cxx-0.10.0/src/main/cpp/socketoutputstream.cpp 2008-05-06 05:35:55.000000000 +0200 +@@ -20,6 +20,8 @@ + #include <log4cxx/helpers/socket.h> + #include <log4cxx/helpers/bytebuffer.h> + ++#include <cstring> ++ + using namespace log4cxx; + using namespace log4cxx::helpers; \ No newline at end of file diff --git a/packages/log4cxx-test/log4cxx-0.10.0-narrowing-fixes-from-upstream.patch b/packages/log4cxx-test/log4cxx-0.10.0-narrowing-fixes-from-upstream.patch new file mode 100644 index 0000000000000000000000000000000000000000..e583e7661d1d0adc0650dd3d96f5bf8d77aa6cbf --- /dev/null +++ b/packages/log4cxx-test/log4cxx-0.10.0-narrowing-fixes-from-upstream.patch @@ -0,0 +1,117 @@ +diff --git a/src/main/cpp/locationinfo.cpp b/src/main/cpp/locationinfo.cpp +index e76ea29..bd22a1d 100644 +--- a/src/main/cpp/locationinfo.cpp ++++ b/src/main/cpp/locationinfo.cpp +@@ -149,18 +149,21 @@ void LocationInfo::write(ObjectOutputStream& os, Pool& p) const { + os.writeNull(p); + } else { + char prolog[] = { +- 0x72, 0x00, 0x21, 0x6F, 0x72, 0x67, 0x2E, +- 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E, 0x6C, +- 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, +- 0x2E, 0x4C, 0x6F, 0x63, 0x61, 0x74, 0x69, 0x6F, +- 0x6E, 0x49, 0x6E, 0x66, 0x6F, 0xED, 0x99, 0xBB, +- 0xE1, 0x4A, 0x91, 0xA5, 0x7C, 0x02, 0x00, 0x01, +- 0x4C, 0x00, 0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, +- 0x6E, 0x66, 0x6F, +- 0x74, 0x00, 0x12, 0x4C, 0x6A, +- 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, +- 0x2F, 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, +- 0x78, 0x70 }; ++ 0x72, ++ 0x00, ++ 0x21, 0x6F, 0x72, 0x67, 0x2E, 0x61, 0x70, 0x61, 0x63, 0x68, 0x65, 0x2E, ++ 0x6C, 0x6F, 0x67, 0x34, 0x6A, 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F, ++ 0x63, 0x61, 0x74, 0x69, 0x6F, 0x6E, 0x49, 0x6E, 0x66, 0x6F, static_cast<char>(0xED), ++ static_cast<char>(0x99), static_cast<char>(0xBB), static_cast<char>(0xE1), ++ 0x4A, static_cast<char>(0x91), static_cast<char>(0xA5), 0x7C, 0x02, ++ 0x00, ++ 0x01, 0x4C, ++ 0x00, ++ 0x08, 0x66, 0x75, 0x6C, 0x6C, 0x49, 0x6E, 0x66, 0x6F, 0x74, ++ 0x00, ++ 0x12, 0x4C, 0x6A, 0x61, 0x76, 0x61, 0x2F, 0x6C, 0x61, 0x6E, 0x67, 0x2F, ++ 0x53, 0x74, 0x72, 0x69, 0x6E, 0x67, 0x3B, 0x78, 0x70 ++ }; + os.writeProlog("org.apache.log4j.spi.LocationInfo", 2, prolog, sizeof(prolog), p); + char* line = p.itoa(lineNumber); + // +diff --git a/src/main/cpp/loggingevent.cpp b/src/main/cpp/loggingevent.cpp +index 1c0d4be..edbf40b 100644 +--- a/src/main/cpp/loggingevent.cpp ++++ b/src/main/cpp/loggingevent.cpp +@@ -242,7 +242,7 @@ void LoggingEvent::writeProlog(ObjectOutputStream& os, Pool& p) { + 0x68, 0x65, 0x2E, 0x6C, 0x6F, 0x67, 0x34, 0x6A, + 0x2E, 0x73, 0x70, 0x69, 0x2E, 0x4C, 0x6F, 0x67, + 0x67, 0x69, 0x6E, 0x67, 0x45, 0x76, 0x65, 0x6E, +- 0x74, 0xF3, 0xF2, 0xB9, 0x23, 0x74, 0x0B, 0xB5, ++ 0x74, static_cast<char>(0xF3), static_cast<char>(0xF2), static_cast<char>(0xB9), 0x23, 0x74, 0x0B, static_cast<char>(0xB5), + 0x3F, 0x03, 0x00, 0x0A, 0x5A, 0x00, 0x15, 0x6D, + 0x64, 0x63, 0x43, 0x6F, 0x70, 0x79, 0x4C, 0x6F, + 0x6F, 0x6B, 0x75, 0x70, 0x52, 0x65, 0x71, 0x75, +diff --git a/src/main/cpp/objectoutputstream.cpp b/src/main/cpp/objectoutputstream.cpp +index 7cd696b..5442420 100644 +--- a/src/main/cpp/objectoutputstream.cpp ++++ b/src/main/cpp/objectoutputstream.cpp +@@ -36,7 +36,7 @@ ObjectOutputStream::ObjectOutputStream(OutputStreamPtr outputStream, Pool& p) + objectHandle(0x7E0000), + classDescriptions(new ClassDescriptionMap()) + { +- char start[] = { 0xAC, 0xED, 0x00, 0x05 }; ++ char start[] = { static_cast<char>(0xAC), static_cast<char>(0xED), 0x00, 0x05 }; + ByteBuffer buf(start, sizeof(start)); + os->write(buf, p); + } +@@ -81,15 +81,15 @@ void ObjectOutputStream::writeObject(const MDC::Map& val, Pool& p) { + // + // TC_OBJECT and the classDesc for java.util.Hashtable + // +- char prolog[] = { +- 0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61, +- 0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61, +- 0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13, +- 0xBB, 0x0F, 0x25, 0x21, 0x4A, 0xE4, 0xB8, 0x03, +- 0x00, 0x02, 0x46, 0x00, 0x0A, 0x6C, 0x6F, 0x61, +- 0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49, +- 0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, +- 0x6F, 0x6C, 0x64, 0x78, 0x70 }; ++ char prolog[] = { ++ 0x72, 0x00, 0x13, 0x6A, 0x61, 0x76, 0x61, ++ 0x2E, 0x75, 0x74, 0x69, 0x6C, 0x2E, 0x48, 0x61, ++ 0x73, 0x68, 0x74, 0x61, 0x62, 0x6C, 0x65, 0x13, ++ static_cast<char>(0xBB), 0x0F, 0x25, 0x21, 0x4A, static_cast<char>(0xE4), static_cast<char>(0xB8), 0x03, ++ 0x00, 0x02, 0x46, 0x00, 0x0A, 0x6C, 0x6F, 0x61, ++ 0x64, 0x46, 0x61, 0x63, 0x74, 0x6F, 0x72, 0x49, ++ 0x00, 0x09, 0x74, 0x68, 0x72, 0x65, 0x73, 0x68, ++ 0x6F, 0x6C, 0x64, 0x78, 0x70 }; + writeProlog("java.util.Hashtable", 1, prolog, sizeof(prolog), p); + // + // loadFactor = 0.75, threshold = 5, blockdata start, buckets.size = 7 +diff --git a/src/test/cpp/xml/domtestcase.cpp b/src/test/cpp/xml/domtestcase.cpp +index a500628..29d67dd 100644 +--- a/src/test/cpp/xml/domtestcase.cpp ++++ b/src/test/cpp/xml/domtestcase.cpp +@@ -190,9 +190,9 @@ public: + DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase3.xml")); + LOG4CXX_INFO(logger, "File name is expected to end with a superscript 3"); + #if LOG4CXX_LOGCHAR_IS_UTF8 +- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xC2, 0xB3, 0 }; ++ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xC2), static_cast<logchar>(0xB3), 0 }; + #else +- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xB3, 0 }; ++ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xB3), 0 }; + #endif + File file; + file.setPath(fname); +@@ -209,9 +209,9 @@ public: + DOMConfigurator::configure(LOG4CXX_TEST_STR("input/xml/DOMTestCase4.xml")); + LOG4CXX_INFO(logger, "File name is expected to end with an ideographic 4"); + #if LOG4CXX_LOGCHAR_IS_UTF8 +- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0xE3, 0x86, 0x95, 0 }; ++ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0xE3), static_cast<logchar>(0x86), static_cast<logchar>(0x95), 0 }; + #else +- const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, 0x3195, 0 }; ++ const logchar fname[] = { 0x6F, 0x75, 0x74, 0x70, 0x75, 0x74, 0x2F, 0x64, 0x6F, 0x6D, static_cast<logchar>(0x3195), 0 }; + #endif + File file; + file.setPath(fname); \ No newline at end of file diff --git a/packages/log4cxx-test/package.py b/packages/log4cxx-test/package.py new file mode 100644 index 0000000000000000000000000000000000000000..9ce57a50750678660ae2360be494c6917a6c569f --- /dev/null +++ b/packages/log4cxx-test/package.py @@ -0,0 +1,39 @@ +# Copyright 2013-2023 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 Log4cxxTest(CMakePackage): + """A C++ port of Log4j""" + + homepage = "https://logging.apache.org/log4cxx/latest_stable/" + url = "https://dlcdn.apache.org/logging/log4cxx/0.12.0/apache-log4cxx-0.12.0.tar.gz" + + maintainers("nicmcd") + + # begin EBRAINS (added): bring upstream (ref. spack@0.21.2) + version("1.2.0", sha256="09f4748aa5675ef5c0770bedbf5e00488668933c5a935a43ac5b85be2436c48a") + version("1.1.0", sha256="1fc7d82697534184bc0f757348d969d24852b948f63d6b17283fd1ee29c2c28a") + # end EBRAINS + version("0.12.1", sha256="7bea5cb477f0e31c838f0e1f4f498cc3b30c2eae74703ddda923e7e8c2268d22") + version("0.12.0", sha256="bd5b5009ca914c8fa7944b92ea6b4ca6fb7d146f65d526f21bf8b3c6a0520e44") + + variant("cxxstd", default="17", description="C++ standard", values=("11", "17"), multi=False) + + depends_on("cmake@3.13:", type="build") + + depends_on("apr-util") + depends_on("apr") + depends_on("boost+thread+system", when="cxxstd=11") + depends_on("zlib-api") + depends_on("zip") + + def cmake_args(self): + return [ + self.define_from_variant("CMAKE_CXX_STANDARD", "cxxstd"), + self.define("BUILD_TESTING", "off"), + self.define("LOG4CXX_EVENTS_AT_EXIT", "on"), + ] diff --git a/spack.yaml b/spack.yaml index 3b54982b77c92f4091ad6e07a1bc884340e4dbfc..3274229287a5ebb84499c60084a2497f293e0027 100644 --- a/spack.yaml +++ b/spack.yaml @@ -3,6 +3,7 @@ spack: - site-config/$SYSTEMNAME specs: # EBRAINS tools + - brainscales-logger@8.0-a5 - arbor@0.9.0 +python +mpi - biobb-analysis@4.0.1 - biobb-chemistry@4.0.0