diff options
-rw-r--r-- | build_extra/rust/BUILD.gn | 8 | ||||
-rw-r--r-- | build_extra/rust/rust.gni | 26 |
2 files changed, 23 insertions, 11 deletions
diff --git a/build_extra/rust/BUILD.gn b/build_extra/rust/BUILD.gn index f5f0b9bb6..9988ea6e7 100644 --- a/build_extra/rust/BUILD.gn +++ b/build_extra/rust/BUILD.gn @@ -11,7 +11,7 @@ crates = "//third_party/rust_crates" rust_component("libc") { source_root = "$crates/registry/src/github.com-1ecc6299db9ec823/libc-0.2.42/src/lib.rs" - cfg = [ "feature=\"use_std\"" ] + features = [ "use_std" ] } rust_component("url") { @@ -91,9 +91,9 @@ rust_component("rand") { ":libc", ":rand_core", ] - cfg = [ - "feature=\"std\"", - "feature=\"alloc\"", + features = [ + "std", + "alloc", ] if (is_mac) { libs = [ "Security.framework" ] diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index f783126ed..88f80904f 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -43,10 +43,11 @@ template("run_rustc") { "cfg", "crate_name", "crate_type", - "source_root", "deps", "extern", + "features", "is_test", + "source_root", "testonly", ]) if (!defined(crate_name)) { @@ -119,6 +120,15 @@ template("run_rustc") { } } + if (defined(features)) { + foreach(f, features) { + args += [ + "--cfg", + "feature=\"" + f + "\"", + ] + } + } + if (defined(invoker.args)) { args += invoker.args } @@ -155,15 +165,16 @@ template("rust_component") { run_rustc(rustc_name) { forward_variables_from(invoker, [ + "args", + "cfg", "crate_name", "crate_type", + "deps", "extern", - "cfg", - "source_root", + "features", "is_test", + "source_root", "testonly", - "args", - "deps", ]) if (!defined(invoker.crate_type)) { crate_type = "rlib" @@ -176,8 +187,8 @@ template("rust_component") { component(target_name) { forward_variables_from(invoker, [ - "libs", "deps", + "libs", "testonly", ]) if (!defined(deps)) { @@ -195,9 +206,10 @@ template("rust_staticlib") { rust_component(target_name) { forward_variables_from(invoker, [ + "cfg", "crate_name", "extern", - "cfg", + "features", "source_root", "testonly", ]) |