From 89794d5d347d1358ec32ed42e1f0faa6e0ac6abe Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Wed, 28 Aug 2019 22:19:07 -0700 Subject: build: make it possible to pass arbitrary env vars to rustc --- build_extra/rust/rust.gni | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'build_extra/rust/rust.gni') diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index 2af3b2b12..01f1b8a49 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -63,6 +63,7 @@ template("_rust_crate") { "crate_version", "deps", "edition", + "env", "features", "generated_source_dir", "inputs", @@ -234,24 +235,6 @@ template("_rust_crate") { "--color=always", ] - if (defined(generated_source_dir)) { - args += [ - # Some crates (e.g. 'typenum') generate source files and place them in - # the directory indicated by the 'OUT_DIR' environment variable, which - # is normally set by Cargo. This flag tells run.py to set 'OUT_DIR' to - # the path where the current crate can find its generated sources. - "--generated-source-dir=" + - rebase_path(generated_source_dir, root_build_dir), - ] - } - - if (defined(crate_version)) { - args += [ - # This is used to set env variables for Cargo build compatibility - "--cargo-pkg-version=$crate_version", - ] - } - if (is_win) { # Proc-macro crates need to be linked by rustc itself, because rustc # doesn't expose all the information necessary to produce the correct @@ -318,6 +301,22 @@ template("_rust_crate") { sources += [ info.out_path ] deps += [ info.label ] } + + if (defined(generated_source_dir)) { + args += [ + # Some crates (e.g. 'typenum') generate source files and place them in + # the directory indicated by the 'OUT_DIR' environment variable, which + # is normally set by Cargo. This flag tells run.py to set 'OUT_DIR' to + # the path where the current crate can find its generated sources. + "--env=OUT_DIR=" + rebase_path(generated_source_dir, root_build_dir), + ] + } + + if (defined(env)) { + foreach(e, env) { + args += [ "--env=$e" ] + } + } } } -- cgit v1.2.3