Esempio n. 1
0
    def configure(self, spec, prefix):
        """Make adjustments to the OpenFOAM configuration files in their various
        locations: etc/bashrc, etc/config.sh/FEATURE and customizations that
        don't properly fit get placed in the etc/prefs.sh file (similiarly for
        csh).
        """
        # Filtering bashrc, cshrc
        edits = {}
        edits.update(self.foam_arch.foam_dict())
        rewrite_environ_files(  # Adjust etc/bashrc and etc/cshrc
            edits,
            posix=join_path('etc', 'bashrc'),
            cshell=join_path('etc', 'cshrc'))

        # MPI content, with absolute paths
        user_mpi = mplib_content(spec)

        # Content for etc/prefs.{csh,sh}
        self.etc_prefs = {
            r'MPI_ROOT': spec['mpi'].prefix,  # Absolute
            r'MPI_ARCH_FLAGS': '"%s"' % user_mpi['FLAGS'],
            r'MPI_ARCH_INC':   '"%s"' % user_mpi['PINC'],
            r'MPI_ARCH_LIBS':  '"%s"' % user_mpi['PLIBS'],
        }

        # Content for etc/config.{csh,sh}/ files
        self.etc_config = {
            'CGAL': {},
            'scotch': {},
            'metis': {},
            'paraview': [],
            'gperftools': [],  # Currently unused
        }

        if True:
            self.etc_config['scotch'] = {
                'SCOTCH_ARCH_PATH': spec['scotch'].prefix,
                # For src/parallel/decompose/Allwmake
                'SCOTCH_VERSION': 'scotch-{0}'.format(spec['scotch'].version),
            }

        if '+metis' in spec:
            self.etc_config['metis'] = {
                'METIS_ARCH_PATH': spec['metis'].prefix,
            }

        # Write prefs files according to the configuration.
        # Only need prefs.sh for building, but install both for end-users
        if self.etc_prefs:
            write_environ(
                self.etc_prefs,
                posix=join_path('etc', 'prefs.sh'),
                cshell=join_path('etc', 'prefs.csh'))

        # Adjust components to use SPACK variants
        for component, subdict in self.etc_config.items():
            # Versions up to 3.0 used an etc/config/component.sh naming
            # convention instead of etc/config.sh/component
            if spec.satisfies('@:3.0'):
                write_environ(
                    subdict,
                    posix=join_path('etc', 'config',  component) + '.sh',
                    cshell=join_path('etc', 'config', component) + '.csh')
            else:
                write_environ(
                    subdict,
                    posix=join_path('etc', 'config.sh',  component),
                    cshell=join_path('etc', 'config.csh', component))
Esempio n. 2
0
    def configure(self, spec, prefix):
        """Make adjustments to the OpenFOAM configuration files in their various
        locations: etc/bashrc, etc/config.sh/FEATURE and customizations that
        don't properly fit get placed in the etc/prefs.sh file (similiarly for
        csh).
        """
        # Content for etc/prefs.{csh,sh}
        self.etc_prefs = {
            '000': {  # Sort first
                'compilerInstall': 'System',
            },
            '001': {},
            'cmake': {
                'CMAKE_DIR': spec['cmake'].prefix,
                'CMAKE_BIN_DIR': spec['cmake'].prefix.bin,
            },
            'python': {
                'PYTHON_DIR': spec['python'].home,
                'PYTHON_BIN_DIR': spec['python'].home.bin,
            },
            'flex': {
                'FLEX_SYSTEM': 1,
                'FLEX_DIR': spec['flex'].prefix,
            },
            'bison': {
                'BISON_SYSTEM': 1,
                'BISON_DIR': spec['flex'].prefix,
            },
            'zlib': {
                'ZLIB_SYSTEM': 1,
                'ZLIB_DIR': spec['zlib'].prefix,
            },
        }
        # Adjust configuration via prefs - sort second
        self.etc_prefs['001'].update(self.foam_arch.foam_dict())

        if '+scotch' in spec or '+ptscotch' in spec:
            pkg = spec['scotch'].prefix
            self.etc_prefs['scotch'] = {
                'SCOTCH_SYSTEM': 1,
                'SCOTCH_DIR': pkg,
                'SCOTCH_BIN_DIR': pkg.bin,
                'SCOTCH_LIB_DIR': pkg.lib,
                'SCOTCH_INCLUDE_DIR': pkg.include,
            }

        if '+metis' in spec:
            pkg = spec['metis'].prefix
            self.etc_prefs['metis'] = {
                'METIS_SYSTEM': 1,
                'METIS_DIR': pkg,
                'METIS_BIN_DIR': pkg.bin,
                'METIS_LIB_DIR': pkg.lib,
                'METIS_INCLUDE_DIR': pkg.include,
            }

        if '+parmetis' in spec:
            pkg = spec['parmetis'].prefix
            self.etc_prefs['parametis'] = {
                'PARMETIS_SYSTEM': 1,
                'PARMETIS_DIR': pkg,
                'PARMETIS_BIN_DIR': pkg.bin,
                'PARMETIS_LIB_DIR': pkg.lib,
                'PARMETIS_INCLUDE_DIR': pkg.include,
            }

        if '+parmgridgen' in spec:
            pkg = spec['parmgridgen'].prefix
            self.etc_prefs['parmgridgen'] = {
                'PARMGRIDGEN_SYSTEM': 1,
                'PARMGRIDGEN_DIR': pkg,
                'PARMGRIDGEN_BIN_DIR': pkg.bin,
                'PARMGRIDGEN_LIB_DIR': pkg.lib,
                'PARMGRIDGEN_INCLUDE_DIR': pkg.include,
            }

        if '+paraview' in self.spec:
            self.etc_prefs['paraview'] = {
                'PARAVIEW_SYSTEM': 1,
                'PARAVIEW_DIR': spec['paraview'].prefix,
                'PARAVIEW_BIN_DIR': spec['paraview'].prefix.bin,
            }
            self.etc_prefs['qt'] = {
                'QT_SYSTEM': 1,
                'QT_DIR': spec['qt'].prefix,
                'QT_BIN_DIR': spec['qt'].prefix.bin,
            }

        # Write prefs files according to the configuration.
        # Only need prefs.sh for building, but install both for end-users
        write_environ(self.etc_prefs,
                      posix=join_path('etc', 'prefs.sh'),
                      cshell=join_path('etc', 'prefs.csh'))