diff options
author | Adam C. Foltzer <acfoltzer@galois.com> | 2018-01-11 16:04:40 -0800 |
---|---|---|
committer | Adam C. Foltzer <acfoltzer@galois.com> | 2018-01-29 15:47:05 -0800 |
commit | 1d81efb03d5efee5899db01737880b1b3969e1fc (patch) | |
tree | 5333fba87ba73d881364934454ebdaaaf98cc7b0 /mesonbuild/compilers/rust.py | |
parent | 7eb6a2918080fce37df7e6d25194d46ed98f0f35 (diff) | |
download | meson-1d81efb03d5efee5899db01737880b1b3969e1fc.zip meson-1d81efb03d5efee5899db01737880b1b3969e1fc.tar.gz meson-1d81efb03d5efee5899db01737880b1b3969e1fc.tar.bz2 |
Add cross-compilation support for `rustc`
This patch is largely modeled on the relatively-straightforward code
for Fortran cross-compilation, so there might be some intricacies
missing.
Diffstat (limited to 'mesonbuild/compilers/rust.py')
-rw-r--r-- | mesonbuild/compilers/rust.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mesonbuild/compilers/rust.py b/mesonbuild/compilers/rust.py index b93289f..d1a05ed 100644 --- a/mesonbuild/compilers/rust.py +++ b/mesonbuild/compilers/rust.py @@ -19,9 +19,11 @@ from ..mesonlib import EnvironmentException, Popen_safe from .compilers import Compiler, rust_buildtype_args class RustCompiler(Compiler): - def __init__(self, exelist, version): + def __init__(self, exelist, version, is_cross, exe_wrapper=None): self.language = 'rust' super().__init__(exelist, version) + self.is_cross = is_cross + self.exe_wrapper = exe_wrapper self.id = 'rustc' def needs_static_linker(self): @@ -41,7 +43,16 @@ class RustCompiler(Compiler): pc.wait() if pc.returncode != 0: raise EnvironmentException('Rust compiler %s can not compile programs.' % self.name_string()) - if subprocess.call(output_name) != 0: + 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 + [output_name] + else: + cmdlist = [output_name] + pe = subprocess.Popen(cmdlist, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) + pe.wait() + if pe.returncode != 0: raise EnvironmentException('Executables created by Rust compiler %s are not runnable.' % self.name_string()) def get_dependency_gen_args(self, outfile): |