Пример #1
0
    def emit_build_commands(self, environ):
        if not self.srcfile:
            raise BuildSystemError(
                'a source file is required when using the %s build system' %
                type(self).__name__)

        cc = self._cc(environ)
        cxx = self._cxx(environ)
        ftn = self._ftn(environ)
        nvcc = self._nvcc(environ)
        cppflags = self._cppflags(environ) or []
        cflags   = self._cflags(environ) or []
        cxxflags = self._cxxflags(environ) or []
        fflags   = self._fflags(environ)  or []
        ldflags  = self._ldflags(environ) or []

        # Adjust cppflags with the include directories
        # NOTE: We do not use the += operator on purpose, be cause we don't
        # want to change the original list passed by the user
        cppflags = cppflags + [*map(lambda d: '-I ' + d, self.include_path)]

        # Generate the executable
        executable = self.executable or self._auto_exec_name()

        # Prepare the compilation command
        lang = self.lang or self._guess_language(self.srcfile)
        cmd_parts = []
        if lang == 'C':
            if cc is None:
                raise BuildSystemError('I do not know how to compile a '
                                       'C program')

            cmd_parts += [cc, *cppflags, *cflags, self.srcfile,
                          '-o', executable, *ldflags]
        elif lang == 'C++':
            if cxx is None:
                raise BuildSystemError('I do not know how to compile a '
                                       'C++ program')

            cmd_parts += [cxx, *cppflags, *cxxflags, self.srcfile,
                          '-o', executable, *ldflags]
        elif lang == 'Fortran':
            if ftn is None:
                raise BuildSystemError('I do not know how to compile a '
                                       'Fortran program')

            cmd_parts += [ftn, *cppflags, *fflags, self.srcfile,
                          '-o', executable, *ldflags]
        elif lang == 'CUDA':
            if nvcc is None:
                raise BuildSystemError('I do not know how to compile a '
                                       'CUDA program')

            cmd_parts += [nvcc, *cppflags, *cxxflags, self.srcfile,
                          '-o', executable, *ldflags]
        else:
            BuildSystemError('could not guess language of file: %s' %
                             self.srcfile)

        return [' '.join(cmd_parts)]
Пример #2
0
    def emit_build_commands(self, environ):
        self._prefix_save = os.getcwd()
        if self.environment is _Undefined:
            raise BuildSystemError(f'no Spack environment is defined')

        ret = self._env_activate_cmds()
        if self.specs:
            specs_str = ' '.join(self.specs)
            ret.append(f'spack add {specs_str}')

        install_cmd = 'spack install'
        if self.install_opts:
            install_cmd += ' ' + ' '.join(self.install_opts)

        ret.append(install_cmd)
        return ret
Пример #3
0
    def emit_build_commands(self, environ):
        if not self.easyconfigs:
            raise BuildSystemError(f"'easyconfigs' must not be empty")

        easyconfigs = ' '.join(self.easyconfigs)
        if self.emit_package:
            self.options.append('--package')
            for key, val in self.package_opts.items():
                self.options.append(f'--package-{key}={val}')

        prefix = os.path.join(os.getcwd(), self.prefix)
        options = ' '.join(self.options)
        return [f'export EASYBUILD_BUILDPATH={prefix}/build',
                f'export EASYBUILD_INSTALLPATH={prefix}',
                f'export EASYBUILD_PREFIX={prefix}',
                f'export EASYBUILD_SOURCEPATH={prefix}',
                f'eb {easyconfigs} {options}']