aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/environment.py
diff options
context:
space:
mode:
authorAdam C. Foltzer <acfoltzer@galois.com>2018-01-11 16:04:40 -0800
committerAdam C. Foltzer <acfoltzer@galois.com>2018-01-29 15:47:05 -0800
commit1d81efb03d5efee5899db01737880b1b3969e1fc (patch)
tree5333fba87ba73d881364934454ebdaaaf98cc7b0 /mesonbuild/environment.py
parent7eb6a2918080fce37df7e6d25194d46ed98f0f35 (diff)
downloadmeson-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/environment.py')
-rw-r--r--mesonbuild/environment.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/mesonbuild/environment.py b/mesonbuild/environment.py
index e5aa43e..0e5dff0 100644
--- a/mesonbuild/environment.py
+++ b/mesonbuild/environment.py
@@ -278,6 +278,7 @@ class Environment:
self.default_objc = ['cc']
self.default_objcpp = ['c++']
self.default_fortran = ['gfortran', 'g95', 'f95', 'f90', 'f77', 'ifort']
+ self.default_rust = ['rustc']
self.default_static_linker = ['ar']
self.vs_static_linker = ['lib']
self.gcc_static_linker = ['gcc-ar']
@@ -688,16 +689,24 @@ class Environment:
return ValaCompiler(exelist, version)
raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
- def detect_rust_compiler(self):
- exelist = ['rustc']
- try:
- p, out = Popen_safe(exelist + ['--version'])[0:2]
- except OSError:
- raise EnvironmentException('Could not execute Rust compiler "%s"' % ' '.join(exelist))
- version = search_version(out)
- if 'rustc' in out:
- return RustCompiler(exelist, version)
- raise EnvironmentException('Unknown compiler "' + ' '.join(exelist) + '"')
+ def detect_rust_compiler(self, want_cross):
+ popen_exceptions = {}
+ compilers, ccache, is_cross, exe_wrap = self._get_compilers('rust', 'RUSTC', want_cross)
+ for compiler in compilers:
+ if isinstance(compiler, str):
+ compiler = [compiler]
+ try:
+ p, out = Popen_safe(compiler + ['--version'])[0:2]
+ except OSError as e:
+ popen_exceptions[compiler] = e
+ continue
+
+ version = search_version(out)
+
+ if 'rustc' in out:
+ return RustCompiler(compiler, version, is_cross, exe_wrap)
+
+ self._handle_exceptions(popen_exceptions, compilers)
def detect_d_compiler(self, want_cross):
is_cross = False