78 lines
3.0 KiB
Diff
78 lines
3.0 KiB
Diff
|
From: Takuro Ashie <ashie>
|
||
|
Date: Thu, 18 Apr 2019 07:21:00 -0700
|
||
|
Subject: Bug 1545437 - Add options to specify Rust target name
|
||
|
|
||
|
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.
|
||
|
|
||
|
Bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1545437
|
||
|
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=954774
|
||
|
Forwarded: https://phabricator.services.mozilla.com/D28069
|
||
|
Applied-upstream: no, upstream consider this a workaround and do not support armel
|
||
|
---
|
||
|
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 9647cbc..5aed73f 100644
|
||
|
--- a/build/moz.configure/rust.configure
|
||
|
+++ b/build/moz.configure/rust.configure
|
||
|
@@ -218,6 +218,28 @@ def rust_supported_targets(rustc):
|
||
|
return namespace(per_os=per_os, per_raw_os=per_raw_os)
|
||
|
|
||
|
|
||
|
+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.
|
||
|
@@ -228,8 +250,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')
|
||
|
@@ -237,8 +260,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
|