Skip to content

Commit

Permalink
Auto merge of #7499 - orium:document-rustc-wrapper, r=Eh2406
Browse files Browse the repository at this point in the history
Document rustc wrapper
  • Loading branch information
bors committed Oct 10, 2019
2 parents 94bf478 + 674241b commit aa4820b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
14 changes: 11 additions & 3 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,9 +873,17 @@ impl Config {
return Ok(Some(path));
}

let var = format!("build.{}", tool);
if let Some(tool_path) = self.get_path(&var)? {
return Ok(Some(tool_path.val));
// For backwards compatibility we allow both snake_case config paths as well as the
// idiomatic kebab-case paths.
let config_paths = [
format!("build.{}", tool),
format!("build.{}", tool.replace('_', "-")),
];

for config_path in &config_paths {
if let Some(tool_path) = self.get_path(&config_path)? {
return Ok(Some(tool_path.val));
}
}

Ok(None)
Expand Down
7 changes: 4 additions & 3 deletions src/doc/src/guide/build-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ a similar result can be achieved by using a third party tool, [sccache].
To setup `sccache`, install it with `cargo install sccache` and set
`RUSTC_WRAPPER` environmental variable to `sccache` before invoking Cargo.
If you use bash, it makes sense to add `export RUSTC_WRAPPER=sccache` to
`.bashrc`. Refer to sccache documentation for more details.
`.bashrc`. Alternatively, you can set `build.rustc-wrapper` in the
[Cargo configuration][config]. Refer to sccache documentation for more
details.

[sccache]: https://github.com/mozilla/sccache


[config]: ../reference/config.md
2 changes: 2 additions & 0 deletions src/doc/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ debug = false
[build]
jobs = 1 # number of parallel jobs, defaults to # of CPUs
rustc = "rustc" # the rust compiler tool
rustc-wrapper = ".." # run this wrapper instead of `rustc`; useful to set up a
# build cache tool such as `sccache`
rustdoc = "rustdoc" # the doc generator tool
target = "triple" # build for the target triple (ignored by `cargo install`)
target-dir = "target" # path of where to place all generated artifacts
Expand Down
3 changes: 2 additions & 1 deletion src/doc/src/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ system:
compiler instead.
* `RUSTC_WRAPPER` — Instead of simply running `rustc`, Cargo will execute this
specified wrapper instead, passing as its commandline arguments the rustc
invocation, with the first argument being rustc.
invocation, with the first argument being `rustc`. Useful to set up a build
cache tool such as `sccache`.
* `RUSTDOC` — Instead of running `rustdoc`, Cargo will execute this specified
`rustdoc` instance instead.
* `RUSTDOCFLAGS` — A space-separated list of custom flags to pass to all `rustdoc`
Expand Down

0 comments on commit aa4820b

Please sign in to comment.