Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document rustc wrapper #7499

Merged
merged 2 commits into from
Oct 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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