diff options
| author | Bert Belder <bertbelder@gmail.com> | 2018-10-25 20:04:23 +0200 |
|---|---|---|
| committer | Bert Belder <bertbelder@gmail.com> | 2018-10-25 22:48:08 +0200 |
| commit | 00e4f7cf835cda09464d67fc1e1b966fc2214823 (patch) | |
| tree | d0923652f2ffaac4ddffb6f7eee874734890ef7b /build_extra/rust/rust.gni | |
| parent | 243a3ba2d0ea3cfa6aa1aa126a7eecf39dd76596 (diff) | |
build: fix compatibility with rustc 1.30.0
Additionally:
* Rebuild rust crates when the rustc version changes.
* Fetch all rust ldflags in one exec_script() call instead of two.
Diffstat (limited to 'build_extra/rust/rust.gni')
| -rw-r--r-- | build_extra/rust/rust.gni | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/build_extra/rust/rust.gni b/build_extra/rust/rust.gni index 9cb5729da..889e25467 100644 --- a/build_extra/rust/rust.gni +++ b/build_extra/rust/rust.gni @@ -29,23 +29,15 @@ out_dir = "$root_out_dir/rust_crates" # * To sidestep rustc weirdness (e.g. on Windows, it always links with the # release C runtime library, even for debug builds). # -# The `get_rust_ldflags` tool outputs the linker flags that are needed to +# The `get_rustc_info` tool outputs the linker flags that are needed to # successfully link rustc object code into an executable. # We generate two sets of ldflags: -# `rust_bin_ldflags`: Used for rust_executable targets. -# `rust_test_ldflags`: Used for rust_test targets; includes the test harness. +# `ldflags_bin` : Used for rust_executable targets. +# `ldflags_test`: Used for rust_test targets; includes the test harness. # # The tool works by compiling and linking something with rustc, and analyzing # the arguments it passes to the system linker. That's what dummy.rs is for. -dummy_rs_path = rebase_path("dummy.rs", root_build_dir) -rust_bin_ldflags = - exec_script("get_rust_ldflags.py", [ dummy_rs_path ], "list lines") -rust_test_ldflags = exec_script("get_rust_ldflags.py", - [ - dummy_rs_path, - "--test", - ], - "list lines") +_rustc_info = exec_script("get_rustc_info.py", [], "json") template("rust_crate") { config_name = "${target_name}_config" @@ -184,7 +176,10 @@ template("rust_crate") { # This is to disambiguate multiple versions of the same crate. "-Cextra-filename=$crate_suffix", - "-Cmetadata=$crate_suffix", + + # Appending the rustc version to the crate metadata ensures that they are + # rebuilt when rustc is upgraded, by changing the command line. + "-Cmetadata=\"${crate_suffix}_${_rustc_info.version}\"", # This is needed for transitive dependencies. "-L", @@ -244,9 +239,9 @@ template("rust_executable") { forward_variables_from(invoker, "*") if (defined(is_test) && is_test) { - ldflags = rust_test_ldflags + ldflags = _rustc_info.ldflags_test } else { - ldflags = rust_bin_ldflags + ldflags = _rustc_info.ldflags_bin } if (!defined(deps)) { |
