build: support crate imports using an alias name

A crate can assign an alternative name, different from the crate name,
when importing another crate. On the command line this looks like:

  rustc ... --extern foo_crate=path/to/bar_crate.rlib

We need to support this so we can eventually upgrade to rand-0.7.x.
This commit is contained in:
Bert Belder 2019-08-02 00:50:29 +02:00
parent deec1b9b97
commit 5bca001f97
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -148,12 +148,10 @@ template("_rust_crate") {
extern_outputs += [
{
label = info.label
crate_name = info.crate_name
crate_type = info.crate_type
crate_name = info.crate_name
if (!defined(info.crate_version)) {
crate_suffix = ""
} else {
if (defined(info.crate_version)) {
crate_version = info.crate_version
crate_suffix = exec_script("//tools/sha256sum.py",
[
@ -161,6 +159,14 @@ template("_rust_crate") {
"--format=-%.8s",
],
"trim string")
} else {
crate_suffix = ""
}
if (defined(info.crate_alias)) {
crate_alias = info.crate_alias
} else {
crate_alias = info.crate_name
}
if (crate_type == "rlib") {
@ -293,7 +299,7 @@ template("_rust_crate") {
foreach(info, extern_outputs) {
args += [
"--extern",
info.crate_name + "=" + rebase_path(info.out_path, root_build_dir),
info.crate_alias + "=" + rebase_path(info.out_path, root_build_dir),
]
sources += [ info.out_path ]
deps += [ info.label ]