Пример #1
0
    def sanity_check(self, work_dir, environment):
        source_name = os.path.join(work_dir, 'sanitycheckf.f90')
        binary_name = os.path.join(work_dir, 'sanitycheckf')
        with open(source_name, 'w') as ofile:
            ofile.write('''program prog
     print *, "Fortran compilation is working."
end program prog
''')
        extra_flags = self.get_cross_extra_flags(environment, link=True)
        pc = subprocess.Popen(self.exelist + extra_flags +
                              [source_name, '-o', binary_name])
        pc.wait()
        if pc.returncode != 0:
            raise EnvironmentException(
                'Compiler %s can not compile programs.' % self.name_string())
        if self.is_cross:
            if self.exe_wrapper is None:
                # Can't check if the binaries run so we have to assume they do
                return
            cmdlist = self.exe_wrapper + [binary_name]
        else:
            cmdlist = [binary_name]
        pe = subprocess.Popen(cmdlist,
                              stdout=subprocess.DEVNULL,
                              stderr=subprocess.DEVNULL)
        pe.wait()
        if pe.returncode != 0:
            raise EnvironmentException(
                'Executables created by Fortran compiler %s are not runnable.'
                % self.name_string())
Пример #2
0
    def sanity_check(self, work_dir_: str, environment: 'Environment') -> None:
        work_dir = Path(work_dir_)
        source_name = work_dir / 'sanitycheckf.f90'
        binary_name = work_dir / 'sanitycheckf'
        if binary_name.is_file():
            binary_name.unlink()

        source_name.write_text('program main; print *, "Fortran compilation is working."; end program', encoding='utf-8')

        extra_flags: T.List[str] = []
        extra_flags += environment.coredata.get_external_args(self.for_machine, self.language)
        extra_flags += environment.coredata.get_external_link_args(self.for_machine, self.language)
        extra_flags += self.get_always_args()
        # %% build the test executable "sanitycheckf"
        # cwd=work_dir is necessary on Windows especially for Intel compilers to avoid error: cannot write on sanitycheckf.obj
        # this is a defect with how Windows handles files and ifort's object file-writing behavior vis concurrent ProcessPoolExecutor.
        # This simple workaround solves the issue.
        returncode = subprocess.run(self.exelist + extra_flags + [str(source_name), '-o', str(binary_name)],
                                    cwd=work_dir).returncode
        if returncode != 0:
            raise EnvironmentException('Compiler %s can not compile programs.' % self.name_string())
        if self.is_cross:
            if self.exe_wrapper is None:
                # Can't check if the binaries run so we have to assume they do
                return
            cmdlist = self.exe_wrapper.get_command() + [str(binary_name)]
        else:
            cmdlist = [str(binary_name)]
        # %% Run the test executable
        try:
            returncode = subprocess.run(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL).returncode
            if returncode != 0:
                raise EnvironmentException('Executables created by Fortran compiler %s are not runnable.' % self.name_string())
        except OSError:
            raise EnvironmentException('Executables created by Fortran compiler %s are not runnable.' % self.name_string())
Пример #3
0
 def sanity_check(self, work_dir, environment):
     source_name = os.path.join(work_dir, 'sanitycheckf.f90')
     binary_name = os.path.join(work_dir, 'sanitycheckf')
     with open(source_name, 'w') as ofile:
         ofile.write('print *, "Fortran compilation is working."; end')
     if environment.is_cross_build() and not self.is_cross:
         for_machine = MachineChoice.BUILD
     else:
         for_machine = MachineChoice.HOST
     extra_flags = environment.coredata.get_external_args(
         for_machine, self.language)
     extra_flags += environment.coredata.get_external_link_args(
         for_machine, self.language)
     pc = subprocess.Popen(self.exelist + extra_flags +
                           [source_name, '-o', binary_name])
     pc.wait()
     if pc.returncode != 0:
         raise EnvironmentException(
             'Compiler %s can not compile programs.' % self.name_string())
     if self.is_cross:
         if self.exe_wrapper is None:
             # Can't check if the binaries run so we have to assume they do
             return
         cmdlist = self.exe_wrapper + [binary_name]
     else:
         cmdlist = [binary_name]
     pe = subprocess.Popen(cmdlist,
                           stdout=subprocess.DEVNULL,
                           stderr=subprocess.DEVNULL)
     pe.wait()
     if pe.returncode != 0:
         raise EnvironmentException(
             'Executables created by Fortran compiler %s are not runnable.'
             % self.name_string())
Пример #4
0
    def sanity_check(self, work_dir: Path, environment):
        """
        Check to be sure a minimal program can compile and execute
          with this compiler & platform.
        """
        work_dir = Path(work_dir)
        source_name = work_dir / 'sanitycheckf.f90'
        binary_name = work_dir / 'sanitycheckf'
        if binary_name.is_file():
            binary_name.unlink()

        source_name.write_text(
            'print *, "Fortran compilation is working."; end')

        extra_flags = []
        extra_flags += environment.coredata.get_external_args(
            self.for_machine, self.language)
        extra_flags += environment.coredata.get_external_link_args(
            self.for_machine, self.language)
        extra_flags += self.get_always_args()
        # %% build the test executable "sanitycheckf"
        # cwd=work_dir is necessary on Windows especially for Intel compilers to avoid error: cannot write on sanitycheckf.obj
        # this is a defect with how Windows handles files and ifort's object file-writing behavior vis concurrent ProcessPoolExecutor.
        # This simple workaround solves the issue.
        # FIXME: cwd=str(work_dir) is for Python 3.5 on Windows, when 3.5 is deprcated, this can become cwd=work_dir
        returncode = subprocess.run(
            self.exelist + extra_flags +
            [str(source_name), '-o', str(binary_name)],
            cwd=str(work_dir)).returncode
        if returncode != 0:
            raise EnvironmentException(
                'Compiler %s can not compile programs.' % self.name_string())
        if self.is_cross:
            if self.exe_wrapper is None:
                # Can't check if the binaries run so we have to assume they do
                return
            cmdlist = self.exe_wrapper + [str(binary_name)]
        else:
            cmdlist = [str(binary_name)]
        # %% Run the test executable
        try:
            returncode = subprocess.run(cmdlist,
                                        stdout=subprocess.DEVNULL,
                                        stderr=subprocess.DEVNULL).returncode
            if returncode != 0:
                raise EnvironmentException(
                    'Executables created by Fortran compiler %s are not runnable.'
                    % self.name_string())
        except OSError:
            raise EnvironmentException(
                'Executables created by Fortran compiler %s are not runnable.'
                % self.name_string())
Пример #5
0
    def sanity_check(self, work_dir: Path, environment):
        """
        Check to be sure a minimal program can compile and execute
          with this compiler & platform.
        """
        work_dir = Path(work_dir)
        source_name = work_dir / 'sanitycheckf.f90'
        binary_name = work_dir / 'sanitycheckf'
        if binary_name.is_file():
            binary_name.unlink()

        source_name.write_text(
            'print *, "Fortran compilation is working."; end')

        if environment.is_cross_build() and not self.is_cross:
            for_machine = MachineChoice.BUILD
        else:
            for_machine = MachineChoice.HOST
        extra_flags = environment.coredata.get_external_args(
            for_machine, self.language)
        extra_flags += environment.coredata.get_external_link_args(
            for_machine, self.language)
        extra_flags += self.get_always_args()
        # %% build the test executable
        pc = subprocess.Popen(
            self.exelist + extra_flags +
            [str(source_name), '-o', str(binary_name)])
        pc.wait()
        if pc.returncode != 0:
            raise EnvironmentException(
                'Compiler %s can not compile programs.' % self.name_string())
        if self.is_cross:
            if self.exe_wrapper is None:
                # Can't check if the binaries run so we have to assume they do
                return
            cmdlist = self.exe_wrapper + [str(binary_name)]
        else:
            cmdlist = [str(binary_name)]
        # %% Run the test executable
        try:
            pe = subprocess.Popen(cmdlist,
                                  stdout=subprocess.DEVNULL,
                                  stderr=subprocess.DEVNULL)
            pe.wait()
            if pe.returncode != 0:
                raise EnvironmentException(
                    'Executables created by Fortran compiler %s are not runnable.'
                    % self.name_string())
        except OSError:
            raise EnvironmentException(
                'Executables created by Fortran compiler %s are not runnable.'
                % self.name_string())