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/backend/ninjabackend.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'mesonbuild/backend') diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py index 77c7d50..e1f3909 100644 --- a/mesonbuild/backend/ninjabackend.py +++ b/mesonbuild/backend/ninjabackend.py @@ -1291,7 +1291,11 @@ int dummy; # installations for rpath_arg in rpath_args: args += ['-C', 'link-arg=' + rpath_arg + ':' + os.path.join(rustc.get_sysroot(), 'lib')] - element = NinjaBuildElement(self.all_outputs, target_name, 'rust_COMPILER', relsrc) + crstr = '' + if target.is_cross: + crstr = '_CROSS' + compiler_name = 'rust%s_COMPILER' % crstr + element = NinjaBuildElement(self.all_outputs, target_name, compiler_name, relsrc) if len(orderdeps) > 0: element.add_orderdep(orderdeps) element.add_item('ARGS', args) @@ -1579,8 +1583,11 @@ int dummy; outfile.write(restat) outfile.write('\n') - def generate_rust_compile_rules(self, compiler, outfile): - rule = 'rule %s_COMPILER\n' % compiler.get_language() + def generate_rust_compile_rules(self, compiler, outfile, is_cross): + crstr = '' + if is_cross: + crstr = '_CROSS' + rule = 'rule %s%s_COMPILER\n' % (compiler.get_language(), crstr) invoc = ' '.join([ninja_quote(i) for i in compiler.get_exelist()]) command = ' command = %s $ARGS $in\n' % invoc description = ' description = Compiling Rust source $in.\n' @@ -1671,8 +1678,7 @@ rule FORTRAN_DEP_HACK self.generate_vala_compile_rules(compiler, outfile) return if langname == 'rust': - if not is_cross: - self.generate_rust_compile_rules(compiler, outfile) + self.generate_rust_compile_rules(compiler, outfile, is_cross) return if langname == 'swift': if not is_cross: -- cgit v1.1