From 2817f07563070d71b624b4397af32d820efec244 Mon Sep 17 00:00:00 2001 From: Takuro Ashie Date: Thu, 18 Apr 2019 23:15:16 +0900 Subject: [PATCH] Bug 1545437 - Add options to specify Rust target name r?glandium Certain build systems such as Yocto know more suitable Rust target name, so it would be better that there is a way to pass it to Mozilla's build system. Differential Revision: https://phabricator.services.mozilla.com/D28069 --- build/moz.configure/rust.configure | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/build/moz.configure/rust.configure b/build/moz.configure/rust.configure index dc23355253..e2d9a8552f 100644 --- a/build/moz.configure/rust.configure +++ b/build/moz.configure/rust.configure @@ -211,6 +211,28 @@ def rust_supported_targets(rustc): return data +option(env='RUST_HOST', + nargs=1, + help='Define the system type for Rust performing the build') + +@depends('RUST_HOST') +@checking('rust host', lambda host: host) +def rust_host_env(value): + if value: + return value[0] + + +option(env='RUST_TARGET', + nargs=1, + help='Define the system type for Rust where the resulting executables will be used') + +@depends('RUST_TARGET') +@checking('rust target', lambda target: target) +def rust_target_env(value): + if value: + return value[0] + + @template def rust_triple_alias(host_or_target): """Template defining the alias used for rustc's --target flag. @@ -221,8 +243,9 @@ def rust_triple_alias(host_or_target): host_or_target_str = {host: 'host', target: 'target'}[host_or_target] - @depends(rustc, host_or_target, c_compiler, rust_supported_targets, - arm_target, when=rust_compiler) + @depends(rustc, host_or_target, rust_host_env, rust_target_env, + c_compiler, rust_supported_targets, arm_target, + when=rust_compiler) @checking('for rust %s triplet' % host_or_target_str) @imports('os') @imports('subprocess') @@ -230,8 +253,14 @@ def rust_triple_alias(host_or_target): @imports(_from='mozbuild.shellutil', _import='quote') @imports(_from='tempfile', _import='mkstemp') @imports(_from='textwrap', _import='dedent') - def rust_target(rustc, host_or_target, compiler_info, - rust_supported_targets, arm_target): + def rust_target(rustc, host_or_target, rust_host_env, rust_target_env, + compiler_info, rust_supported_targets, arm_target): + + specified_targets = {"host": rust_host_env, "target": rust_target_env} + specified_target = specified_targets[host_or_target_str] + if (specified_target): + return specified_target + # Rust's --target options are similar to, but not exactly the same # as, the autoconf-derived targets we use. An example would be that # Rust uses distinct target triples for targetting the GNU C++ ABI