summaryrefslogtreecommitdiff
path: root/var/spack/repos/builtin/packages/of-adios-write/package.py
blob: 98a293c1d96706c9a9b134ebb9ee6c563d676d3d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# Copyright 2013-2018 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)

# Legal Notice
# ------------
# OPENFOAM is a trademark owned by OpenCFD Ltd
# (producer and distributor of the OpenFOAM software via www.openfoam.com).
# The trademark information must remain visible and unadulterated in this
# file and via the "spack info" and comply with the term set by
# http://openfoam.com/legal/trademark-policy.php
#
# This file is not part of OpenFOAM, nor does it constitute a component of an
# OpenFOAM distribution.
#
##############################################################################
import os

import llnl.util.tty as tty

from spack import *
from spack.pkg.builtin.openfoam_com import add_extra_files


class OfAdiosWrite(Package):
    """adios-write supplies additional libraries and function objects
    for reading/writing OpenFOAM data with ADIOS.
    This offering is part of the community repository supported by OpenCFD Ltd,
    producer and distributor of the OpenFOAM software via www.openfoam.com,
    and owner of the OPENFOAM trademark.
    OpenCFD Ltd has been developing and releasing OpenFOAM since its debut
    in 2004.
    """

    # Currently only via git, but with some branches corresponding to main
    # OpenFOAM releases.
    homepage = "https://develop.openfoam.com/Community/feature-adiosWrite/"
    git      = "https://develop.openfoam.com/Community/feature-adiosWrite.git"

    version('develop', branch='develop')
    version('1706', branch='v1706')
    version('1612', branch='v1612')

    variant('source', default=True, description='Install library source')

    depends_on('openfoam-com@develop+source', when='@develop')
    depends_on('openfoam-com@1706+source', when='@1706')
    depends_on('openfoam-com@1612+source', when='@1612')
    depends_on('adios')

    # General patches
    common = ['change-userdir.sh', 'spack-derived-Allwmake']
    assets = []

    build_script  = './spack-derived-Allwmake'
    build_userdir = 'spack-userdir'  # Build user APPBIN, LIBBIN into here

    phases = ['configure', 'build', 'install']

    #
    # - End of definitions / setup -
    #

    def patch(self):
        """Copy additional files or other patching."""
        add_extra_files(self, self.common, self.assets)
        # Emit openfoam version immediately, if we resolved the wrong version
        # it takes a very long time to rebuild!
        tty.info('Build for ' + self.spec['openfoam'].format('$_$@$%@+$+'))

    def configure(self, spec, prefix):
        """Generate spack-config.sh file."""
        # Local tweaks
        config = join_path(self.stage.source_path, 'spack-config.sh')
        with open(config, 'w') as out:
            out.write(
                """# Local tweaks for building
# Location of adios from spack
export ADIOS_ARCH_PATH={adios_dir}

# Local build (for user appbin, libbin)
. ./change-userdir.sh $PWD/{user_dir}
#
"""
                .format(
                    adios_dir=spec['adios'].prefix,
                    user_dir=self.build_userdir))

    def build(self, spec, prefix):
        """Build with Allwmake script, wrapped to source environment first."""
        args = []
        if self.parallel:  # Parallel build? - pass via environment
            os.environ['WM_NCOMPPROCS'] = str(make_jobs)
        builder = Executable(self.build_script)
        builder(*args)

    def install(self, spec, prefix):
        """Install under the prefix directory"""

        for f in ['README.md', 'Issues.txt']:
            if os.path.isfile(f):
                install(f, join_path(self.prefix, f))

        dirs = ['doc', 'etc', 'tutorials']
        if '+source' in spec:
            dirs.append('src')

        for d in dirs:
            install_tree(d, join_path(self.prefix, d))

        # Place directly under 'lib' (no bin)
        for d in ['lib']:
            install_tree(
                join_path(self.build_userdir, d),
                join_path(self.prefix, d))