Skip to content

Commit aa4820b

Browse files
committed
Auto merge of #7499 - orium:document-rustc-wrapper, r=Eh2406
Document rustc wrapper
2 parents 94bf478 + 674241b commit aa4820b

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

src/cargo/util/config/mod.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -873,9 +873,17 @@ impl Config {
873873
return Ok(Some(path));
874874
}
875875

876-
let var = format!("build.{}", tool);
877-
if let Some(tool_path) = self.get_path(&var)? {
878-
return Ok(Some(tool_path.val));
876+
// For backwards compatibility we allow both snake_case config paths as well as the
877+
// idiomatic kebab-case paths.
878+
let config_paths = [
879+
format!("build.{}", tool),
880+
format!("build.{}", tool.replace('_', "-")),
881+
];
882+
883+
for config_path in &config_paths {
884+
if let Some(tool_path) = self.get_path(&config_path)? {
885+
return Ok(Some(tool_path.val));
886+
}
879887
}
880888

881889
Ok(None)

src/doc/src/guide/build-cache.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ a similar result can be achieved by using a third party tool, [sccache].
77
To setup `sccache`, install it with `cargo install sccache` and set
88
`RUSTC_WRAPPER` environmental variable to `sccache` before invoking Cargo.
99
If you use bash, it makes sense to add `export RUSTC_WRAPPER=sccache` to
10-
`.bashrc`. Refer to sccache documentation for more details.
10+
`.bashrc`. Alternatively, you can set `build.rustc-wrapper` in the
11+
[Cargo configuration][config]. Refer to sccache documentation for more
12+
details.
1113

1214
[sccache]: https://github.com/mozilla/sccache
13-
14-
15+
[config]: ../reference/config.md

src/doc/src/reference/config.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,8 @@ debug = false
130130
[build]
131131
jobs = 1 # number of parallel jobs, defaults to # of CPUs
132132
rustc = "rustc" # the rust compiler tool
133+
rustc-wrapper = ".." # run this wrapper instead of `rustc`; useful to set up a
134+
# build cache tool such as `sccache`
133135
rustdoc = "rustdoc" # the doc generator tool
134136
target = "triple" # build for the target triple (ignored by `cargo install`)
135137
target-dir = "target" # path of where to place all generated artifacts

src/doc/src/reference/environment-variables.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ system:
2020
compiler instead.
2121
* `RUSTC_WRAPPER` — Instead of simply running `rustc`, Cargo will execute this
2222
specified wrapper instead, passing as its commandline arguments the rustc
23-
invocation, with the first argument being rustc.
23+
invocation, with the first argument being `rustc`. Useful to set up a build
24+
cache tool such as `sccache`.
2425
* `RUSTDOC` — Instead of running `rustdoc`, Cargo will execute this specified
2526
`rustdoc` instance instead.
2627
* `RUSTDOCFLAGS` — A space-separated list of custom flags to pass to all `rustdoc`

0 commit comments

Comments
 (0)