Skip to content
Snippets Groups Projects
package.py 2.82 KiB
Newer Older
Eric Müller's avatar
Eric Müller committed
# Copyright 2013-2021 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 import *


class PynnBrainscales(WafPackage):
    """PyNN toplevel for the BrainScaleS-2 neuromorphic hardware systems"""

    homepage = "https://github.com/electronicvisions/pynn-brainscales"
    #url      = "https://github.com/electronicvisions/pynn-brainscales/archive/v0.1.0.tar.gz"
    git      = "https://github.com/electronicvisions/pynn-brainscales.git"

    version('waf', branch='waf')
    depends_on('meta-brainscales', type=('build', 'link', 'run'))
    extends('python')

    def setup_build_environment(self, env):
        """waf needs to find headers and libraries by itself (mostly `boost`
        tool, but also `gtest`); it also needs to run executables during
        configuration."""

        include = []
        for dep in self.spec.traverse(deptype='build'):
            query = self.spec[dep.name]
            try:
                include.extend(query.headers.directories)
            except:
                pass

        library = []
        for dep in self.spec.traverse(deptype=('link', 'run')):
            query = self.spec[dep.name]
            try:
                library.extend(query.libs.directories)
                print(query.libs.directories, "\n")
            except:
                pass

        path = []
        for dep in self.spec.traverse(deptype=('build', 'link', 'run')):
            query = self.spec[dep.name]
            try:
                path.append(query.prefix.bin)
            except:
                pass

        # llvm might be built with ~shared_libs but still builds shared libs
        if not any('llvm' in lib for lib in library):
            library.append(self.spec['llvm'].prefix.lib)

        env.set('CPATH', ':'.join(include))
        env.set('C_INCLUDE_PATH', ':'.join(include))
        env.set('CPLUS_INCLUDE_PATH', ':'.join(include))
        env.set('LIBRARY_PATH', ':'.join(library))
        env.set('LD_LIBRARY_PATH', ':'.join(library))
        env.prepend_path('PATH', ':'.join(path))

    # override configure step as we perform a project setup first
    def configure(self, spec, prefix):
        """Setup and configure the project."""

        self.waf('setup', '--project=pynn-brainscales', '--without-grenade-ppu-support', '--without-munge',
                 '--project=grenade@ebrains_release-1-rc1',
                 '--project=hate@ebrains_release-1-rc1',
                 '--project=hxcomm@ebrains_release-1-rc1',
                 '--project=lib-rcf@ebrains_release-1-rc1',
                 '--project=visions-slurm@ebrains_release-1-rc1'
                 )

        args = ['--prefix={0}'.format(self.prefix)]
        args += self.configure_args()

        self.waf('configure', *args)