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

Stabilize RUSTC_WORKSPACE_WRAPPER #8976

Merged
merged 1 commit into from
Dec 21, 2020
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
4 changes: 0 additions & 4 deletions src/cargo/util/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,10 +327,6 @@ impl Config {
&self.build_config()?.rustc_workspace_wrapper,
);

if !self.cli_unstable().unstable_options && rustc_workspace_wrapper.is_some() {
bail!("Usage of `RUSTC_WORKSPACE_WRAPPER` requires `-Z unstable-options`")
}

Rustc::new(
self.get_tool("rustc", &self.build_config()?.rustc),
wrapper,
Expand Down
32 changes: 21 additions & 11 deletions src/doc/src/reference/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,18 @@ rr = "run --release"
space_example = ["run", "--release", "--", "\"command list\""]

[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`
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
rustflags = ["…", "…"] # custom flags to pass to all compiler invocations
rustdocflags = ["…", "…"] # custom flags to pass to rustdoc
incremental = true # whether or not to enable incremental compilation
dep-info-basedir = "…" # path for the base directory for targets in depfiles
pipelining = true # rustc pipelining
jobs = 1 # number of parallel jobs, defaults to # of CPUs
rustc = "rustc" # the rust compiler tool
rustc-wrapper = "…" # run this wrapper instead of `rustc`
rustc-workspace-wrapper = "…" # run this wrapper instead of `rustc` for workspace members
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
rustflags = ["…", "…"] # custom flags to pass to all compiler invocations
rustdocflags = ["…", "…"] # custom flags to pass to rustdoc
incremental = true # whether or not to enable incremental compilation
dep-info-basedir = "…" # path for the base directory for targets in depfiles
pipelining = true # rustc pipelining

[cargo-new]
name = "Your Name" # name to use in `authors` field
Expand Down Expand Up @@ -282,6 +283,15 @@ Sets the executable to use for `rustc`.
Sets a wrapper to execute instead of `rustc`. The first argument passed to the
wrapper is the path to the actual `rustc`.

##### `build.rustc-workspace-wrapper`
* Type: string (program path)
* 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 `rustc`.
It affects the filename hash so that artifacts produced by the wrapper are cached separately.

##### `build.rustdoc`
* Type: string (program path)
* Default: "rustdoc"
Expand Down
8 changes: 8 additions & 0 deletions src/doc/src/reference/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ system:
specified wrapper instead, passing as its commandline arguments the rustc
invocation, with the first argument being `rustc`. Useful to set up a build
cache tool such as `sccache`. See [`build.rustc-wrapper`] to set via config.
* `RUSTC_WORKSPACE_WRAPPER` — Instead of simply running `rustc`, Cargo will
execute this specified wrapper instead for workspace members only, passing
as its commandline arguments the rustc invocation, with the first argument
being `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.
* `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`
Expand Down Expand Up @@ -63,6 +69,7 @@ supported environment variables are:
* `CARGO_BUILD_JOBS` — Number of parallel jobs, see [`build.jobs`].
* `CARGO_BUILD_RUSTC` — The `rustc` executable, see [`build.rustc`].
* `CARGO_BUILD_RUSTC_WRAPPER` — The `rustc` wrapper, see [`build.rustc-wrapper`].
* `CARGO_BUILD_RUSTC_WORKSPACE_WRAPPER` — The `rustc` wrapper for workspace members only, see [`build.rustc-workspace-wrapper`].
* `CARGO_BUILD_RUSTDOC` — The `rustdoc` executable, see [`build.rustdoc`].
* `CARGO_BUILD_TARGET` — The default target platform, see [`build.target`].
* `CARGO_BUILD_TARGET_DIR` — The default output directory, see [`build.target-dir`].
Expand Down Expand Up @@ -121,6 +128,7 @@ supported environment variables are:
[`build.jobs`]: config.md#buildjobs
[`build.rustc`]: config.md#buildrustc
[`build.rustc-wrapper`]: config.md#buildrustc-wrapper
[`build.rustc-workspace-wrapper`]: config.md#buildrustc-workspace-wrapper
[`build.rustdoc`]: config.md#buildrustdoc
[`build.target`]: config.md#buildtarget
[`build.target-dir`]: config.md#buildtarget-dir
Expand Down
9 changes: 3 additions & 6 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4023,9 +4023,8 @@ fn rustc_wrapper_from_path() {
#[cfg(not(windows))]
fn rustc_workspace_wrapper() {
let p = project().file("src/lib.rs", "").build();
p.cargo("build -v -Zunstable-options")
p.cargo("build -v")
.env("RUSTC_WORKSPACE_WRAPPER", "/usr/bin/env")
.masquerade_as_nightly_cargo()
.with_stderr_contains("[RUNNING] `/usr/bin/env rustc --crate-name foo [..]")
.run();
}
Expand All @@ -4034,9 +4033,8 @@ fn rustc_workspace_wrapper() {
#[cfg(not(windows))]
fn rustc_workspace_wrapper_relative() {
let p = project().file("src/lib.rs", "").build();
p.cargo("build -v -Zunstable-options")
p.cargo("build -v")
.env("RUSTC_WORKSPACE_WRAPPER", "./sccache")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains("[..]/foo/./sccache rustc[..]")
.run();
Expand All @@ -4046,9 +4044,8 @@ fn rustc_workspace_wrapper_relative() {
#[cfg(not(windows))]
fn rustc_workspace_wrapper_from_path() {
let p = project().file("src/lib.rs", "").build();
p.cargo("build -v -Zunstable-options")
p.cargo("build -v")
.env("RUSTC_WORKSPACE_WRAPPER", "wannabe_sccache")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains("[..]`wannabe_sccache rustc [..]")
.run();
Expand Down
6 changes: 2 additions & 4 deletions tests/testsuite/cache_messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,9 +469,8 @@ fn rustc_workspace_wrapper() {
)
.build();

p.cargo("check -Zunstable-options -v")
p.cargo("check -v")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name foo src/lib.rs [..]")
.run();

Expand All @@ -488,9 +487,8 @@ fn rustc_workspace_wrapper() {
.run();

// Again, reading from the cache.
p.cargo("check -Zunstable-options -v")
p.cargo("check -v")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("[FRESH] foo [..]")
.with_stdout_does_not_contain("WRAPPER CALLED: rustc --crate-name foo src/lib.rs [..]")
.run();
Expand Down
17 changes: 5 additions & 12 deletions tests/testsuite/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,7 @@ fn does_not_use_empty_rustc_wrapper() {
#[cargo_test]
fn does_not_use_empty_rustc_workspace_wrapper() {
let p = project().file("src/lib.rs", "").build();
p.cargo("check -Zunstable-options")
.masquerade_as_nightly_cargo()
.env("RUSTC_WORKSPACE_WRAPPER", "")
.run();
p.cargo("check").env("RUSTC_WORKSPACE_WRAPPER", "").run();
}

#[cargo_test]
Expand Down Expand Up @@ -905,9 +902,8 @@ fn rustc_workspace_wrapper_affects_all_workspace_members() {
.file("baz/src/lib.rs", "pub fn baz() {}")
.build();

p.cargo("check -Zunstable-options")
p.cargo("check")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name bar [..]")
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name baz [..]")
.run();
Expand Down Expand Up @@ -939,9 +935,8 @@ fn rustc_workspace_wrapper_includes_path_deps() {
.file("baz/src/lib.rs", "pub fn baz() {}")
.build();

p.cargo("check --workspace -Zunstable-options")
p.cargo("check --workspace")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name foo [..]")
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name bar [..]")
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name baz [..]")
Expand All @@ -965,9 +960,8 @@ fn rustc_workspace_wrapper_respects_primary_units() {
.file("baz/src/lib.rs", "pub fn baz() {}")
.build();

p.cargo("check -p bar -Zunstable-options")
p.cargo("check -p bar")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name bar [..]")
.with_stdout_does_not_contain("WRAPPER CALLED: rustc --crate-name baz [..]")
.run();
Expand Down Expand Up @@ -999,9 +993,8 @@ fn rustc_workspace_wrapper_excludes_published_deps() {

Package::new("baz", "1.0.0").publish();

p.cargo("check --workspace -v -Zunstable-options")
p.cargo("check --workspace -v")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name foo [..]")
.with_stderr_contains("WRAPPER CALLED: rustc --crate-name bar [..]")
.with_stderr_contains("[CHECKING] baz [..]")
Expand Down
6 changes: 2 additions & 4 deletions tests/testsuite/fix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1096,9 +1096,8 @@ fn does_not_crash_with_rustc_workspace_wrapper() {
.file("src/lib.rs", "")
.build();

p.cargo("fix --allow-no-vcs --verbose -Zunstable-options")
p.cargo("fix --allow-no-vcs --verbose")
.env("RUSTC_WORKSPACE_WRAPPER", "/usr/bin/env")
.masquerade_as_nightly_cargo()
.run();
}

Expand All @@ -1117,9 +1116,8 @@ fn uses_workspace_wrapper_and_primary_wrapper_override() {
.file("src/lib.rs", "")
.build();

p.cargo("fix --allow-no-vcs --verbose -Zunstable-options")
p.cargo("fix --allow-no-vcs --verbose")
.env("RUSTC_WORKSPACE_WRAPPER", paths::echo_wrapper())
.masquerade_as_nightly_cargo()
.with_stderr_contains("WRAPPER CALLED: rustc src/lib.rs --crate-name foo [..]")
.run();
}
Expand Down