diff options
author | Beau Johnston <beau@inbeta.org> | 2018-07-02 07:01:07 +1000 |
---|---|---|
committer | Beau Johnston <beau@inbeta.org> | 2018-07-02 07:01:07 +1000 |
commit | c6194ef777ef7877e2e526a9936bc5d2e481fa23 (patch) | |
tree | 4e46092aa076295de1067cfb9fc02fb3a6dd280d | |
parent | 8f0a118feb1191e3c5384d98f3246803cb64b9d8 (diff) | |
download | meson-c6194ef777ef7877e2e526a9936bc5d2e481fa23.zip meson-c6194ef777ef7877e2e526a9936bc5d2e481fa23.tar.gz meson-c6194ef777ef7877e2e526a9936bc5d2e481fa23.tar.bz2 |
added check to see if cuda was detected
-rw-r--r-- | mesonbuild/compilers/cuda.py | 27 | ||||
-rw-r--r-- | mesonbuild/environment.py | 1 |
2 files changed, 27 insertions, 1 deletions
diff --git a/mesonbuild/compilers/cuda.py b/mesonbuild/compilers/cuda.py index 1e427f1..ee47220 100644 --- a/mesonbuild/compilers/cuda.py +++ b/mesonbuild/compilers/cuda.py @@ -39,7 +39,32 @@ class CudaCompiler(Compiler): return [''] def sanity_check(self, work_dir, environment): - return True + source_name = os.path.join(work_dir, 'sanitycheckobjc.m') + binary_name = os.path.join(work_dir, 'sanitycheckobjc') + extra_flags = self.get_cross_extra_flags(environment, link=False) + if self.is_cross: + extra_flags += self.get_compile_only_args() + + code = ''' + #include <stdio.h> + int main(int argc,char** argv){ + return 0; + } + ''' + + with open(source_name, 'w') as ofile: + ofile.write(code) + pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name]) + pc.wait() + if pc.returncode != 0: + raise EnvironmentException('Cuda compiler %s can not compile programs.' % self.name_string()) + if self.is_cross: + # Can't check if the binaries run so we have to assume they do + return + pe = subprocess.Popen(binary_name) + pe.wait() + if pe.returncode != 0: + raise EnvironmentException('Executables created by ObjC compiler %s are not runnable.' % self.name_string()) def get_compiler_check_args(self): return super().get_compiler_check_args() + [] diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py index c5384cf..c53ee6d 100644 --- a/mesonbuild/environment.py +++ b/mesonbuild/environment.py @@ -603,6 +603,7 @@ class Environment: version = search_version(out) cls = CudaCompiler return cls(ccache + compiler, version, is_cross, exe_wrap) + raise EnvironmentException('Could not find suitable CUDA compiler: "' + ' '.join(compilers) + '"') def detect_fortran_compiler(self, want_cross): popen_exceptions = {} |