From 1d81efb03d5efee5899db01737880b1b3969e1fc Mon Sep 17 00:00:00 2001 From: "Adam C. Foltzer" Date: Thu, 11 Jan 2018 16:04:40 -0800 Subject: 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. --- mesonbuild/compilers/rust.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'mesonbuild/compilers/rust.py') 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): -- cgit v1.1