mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #13648 - RalfJung:RUSTC_WORKSPACE_WRAPPER, r=weihanglo
RUSTC_WORKSPACE_WRAPPER: clarify docs Follow-up to [Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/Question.20about.20RUSTC_WORKSPACE_WRAPPER)
This commit is contained in:
commit
acd673bcc4
@ -415,10 +415,14 @@ wrapper is the path to the actual executable to use
|
||||
* Default: none
|
||||
* Environment: `CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER` or `RUSTC_WORKSPACE_WRAPPER`
|
||||
|
||||
Sets a wrapper to execute instead of `rustc`, for workspace members only.
|
||||
The first argument passed to the wrapper is the path to the actual
|
||||
executable to use (i.e., `build.rustc`, if that is set, or `"rustc"` otherwise).
|
||||
It affects the filename hash so that artifacts produced by the wrapper are cached separately.
|
||||
Sets a wrapper to execute instead of `rustc`, for workspace members only. When building a
|
||||
single-package project without workspaces, that package is considered to be the workspace. The first
|
||||
argument passed to the wrapper is the path to the actual executable to use (i.e., `build.rustc`, if
|
||||
that is set, or `"rustc"` otherwise). It affects the filename hash so that artifacts produced by the
|
||||
wrapper are cached separately.
|
||||
|
||||
If both `rustc-wrapper` and `rustc-workspace-wrapper` are set, then they will be nested:
|
||||
the final invocation is `$RUSTC_WRAPPER $RUSTC_WORKSPACE_WRAPPER $RUSTC`.
|
||||
|
||||
#### `build.rustdoc`
|
||||
* Type: string (program path)
|
||||
|
@ -37,13 +37,15 @@ system:
|
||||
Useful to set up a build cache tool such as `sccache`. See
|
||||
[`build.rustc-wrapper`] to set via config. Setting this to the empty string
|
||||
overwrites the config and resets cargo to not use a wrapper.
|
||||
* `RUSTC_WORKSPACE_WRAPPER` --- Instead of simply running `rustc`, for workspace
|
||||
members Cargo will execute this specified wrapper, passing
|
||||
as its command-line arguments the rustc invocation, with the first argument
|
||||
being the path to the actual rustc. It affects the filename hash
|
||||
so that artifacts produced by the wrapper are cached separately.
|
||||
See [`build.rustc-workspace-wrapper`] to set via config. Setting this to the empty string
|
||||
overwrites the config and resets cargo to not use a wrapper for workspace members.
|
||||
* `RUSTC_WORKSPACE_WRAPPER` --- Instead of simply running `rustc`, for workspace members Cargo will
|
||||
execute this specified wrapper, passing as its command-line arguments the rustc invocation, with
|
||||
the first argument being the path to the actual rustc. When building a single-package project
|
||||
without workspaces, that package is considered to be the workspace. It affects the filename hash
|
||||
so that artifacts produced by the wrapper are cached separately. See
|
||||
[`build.rustc-workspace-wrapper`] to set via config. Setting this to the empty string overwrites
|
||||
the config and resets cargo to not use a wrapper for workspace members. If both `RUSTC_WRAPPER`
|
||||
and `RUSTC_WORKSPACE_WRAPPER` are set, then they will be nested: the final invocation is
|
||||
`$RUSTC_WRAPPER $RUSTC_WORKSPACE_WRAPPER $RUSTC`.
|
||||
* `RUSTDOC` --- Instead of running `rustdoc`, Cargo will execute this specified
|
||||
`rustdoc` instance instead. See [`build.rustdoc`] to set via config.
|
||||
* `RUSTDOCFLAGS` --- A space-separated list of custom flags to pass to all `rustdoc`
|
||||
|
@ -5210,6 +5210,27 @@ fn rustc_wrapper() {
|
||||
.run();
|
||||
}
|
||||
|
||||
/// Checks what happens when both rust-wrapper and rustc-workspace-wrapper are set.
|
||||
#[cargo_test]
|
||||
fn rustc_wrapper_precendence() {
|
||||
let p = project().file("src/lib.rs", "").build();
|
||||
let rustc_wrapper = tools::echo_wrapper();
|
||||
let ws_wrapper = rustc_wrapper.with_file_name("rustc-ws-wrapper");
|
||||
assert_ne!(rustc_wrapper, ws_wrapper);
|
||||
std::fs::hard_link(&rustc_wrapper, &ws_wrapper).unwrap();
|
||||
|
||||
let running = format!(
|
||||
"[RUNNING] `{} {} rustc --crate-name foo [..]",
|
||||
rustc_wrapper.display(),
|
||||
ws_wrapper.display(),
|
||||
);
|
||||
p.cargo("build -v")
|
||||
.env("RUSTC_WRAPPER", &rustc_wrapper)
|
||||
.env("RUSTC_WORKSPACE_WRAPPER", &ws_wrapper)
|
||||
.with_stderr_contains(running)
|
||||
.run();
|
||||
}
|
||||
|
||||
#[cargo_test]
|
||||
fn rustc_wrapper_relative() {
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
|
Loading…
x
Reference in New Issue
Block a user