mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
feat(compile-time-deps): Add cli flag --compile-time-deps
and adjust docs
This commit is contained in:
parent
5b178a8d05
commit
072b345bbf
@ -38,6 +38,7 @@ pub fn cli() -> Command {
|
||||
.arg_build_plan()
|
||||
.arg_unit_graph()
|
||||
.arg_timings()
|
||||
.arg_compile_time_deps()
|
||||
.arg_manifest_path()
|
||||
.arg_lockfile_path()
|
||||
.arg_ignore_rust_version()
|
||||
|
@ -35,6 +35,7 @@ pub fn cli() -> Command {
|
||||
.arg_target_dir()
|
||||
.arg_unit_graph()
|
||||
.arg_timings()
|
||||
.arg_compile_time_deps()
|
||||
.arg_manifest_path()
|
||||
.arg_lockfile_path()
|
||||
.arg_ignore_rust_version()
|
||||
|
@ -521,6 +521,10 @@ pub trait CommandExt: Sized {
|
||||
.hide(true),
|
||||
)
|
||||
}
|
||||
|
||||
fn arg_compile_time_deps(self) -> Self {
|
||||
self._arg(flag("compile-time-deps", "").hide(true))
|
||||
}
|
||||
}
|
||||
|
||||
impl CommandExt for Command {
|
||||
@ -806,6 +810,7 @@ Run `{cmd}` to see possible targets."
|
||||
build_config.build_plan = self.flag("build-plan");
|
||||
build_config.unit_graph = self.flag("unit-graph");
|
||||
build_config.future_incompat_report = self.flag("future-incompat-report");
|
||||
build_config.compile_time_deps_only = self.flag("compile-time-deps");
|
||||
|
||||
if self._contains("timings") {
|
||||
for timing_output in self._values_of("timings") {
|
||||
@ -840,6 +845,10 @@ Run `{cmd}` to see possible targets."
|
||||
gctx.cli_unstable()
|
||||
.fail_if_stable_opt("--unit-graph", 8002)?;
|
||||
}
|
||||
if build_config.compile_time_deps_only {
|
||||
gctx.cli_unstable()
|
||||
.fail_if_stable_opt("--compile-time-deps", 14434)?;
|
||||
}
|
||||
|
||||
let opts = CompileOptions {
|
||||
build_config,
|
||||
|
@ -2190,3 +2190,17 @@ More information can be found in the [config chapter](config.md#cache).
|
||||
## doctest-xcompile
|
||||
|
||||
Doctest cross-compiling is now unconditionally enabled starting in Rust 1.89. Running doctests with `cargo test` will now honor the `--target` flag.
|
||||
|
||||
## compile-time-deps
|
||||
|
||||
This permanently-unstable flag to only build proc-macros and build scripts (and their required dependencies),
|
||||
as well as run the build scripts.
|
||||
|
||||
It is intended for use by tools like rust-analyzer and will never be stabilized.
|
||||
|
||||
Example:
|
||||
|
||||
```console
|
||||
cargo +nightly build --compile-time-deps -Z unstable-options
|
||||
cargo +nightly check --compile-time-deps --all-targets -Z unstable-options
|
||||
```
|
||||
|
@ -8,13 +8,11 @@ fn gated_by_unstable_opts() {
|
||||
.build();
|
||||
|
||||
p.cargo("check --compile-time-deps")
|
||||
.with_status(1)
|
||||
.with_status(101)
|
||||
.with_stderr_data(str![[r#"
|
||||
[ERROR] unexpected argument '--compile-time-deps' found
|
||||
|
||||
Usage: cargo check [OPTIONS]
|
||||
|
||||
For more information, try '--help'.
|
||||
[ERROR] the `--compile-time-deps` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
|
||||
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
|
||||
See https://github.com/rust-lang/cargo/issues/14434 for more information about the `--compile-time-deps` flag.
|
||||
|
||||
"#]])
|
||||
.run();
|
||||
@ -55,11 +53,10 @@ fn non_comp_time_dep() {
|
||||
.file("bar/src/lib.rs", r#"pub fn bar() {}"#)
|
||||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
p.cargo("-Zunstable-options check --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 1 package to latest compatible version
|
||||
[CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -151,11 +148,11 @@ fn proc_macro_dep() {
|
||||
.file("baz/src/lib.rs", r#"pub fn baz() {}"#)
|
||||
.build();
|
||||
|
||||
p.cargo("check --package foo")
|
||||
p.cargo("-Zunstable-options check --package foo --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[COMPILING] baz v0.0.1 ([ROOT]/foo/baz)
|
||||
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -163,10 +160,9 @@ fn proc_macro_dep() {
|
||||
|
||||
p.cargo("clean").run();
|
||||
|
||||
p.cargo("check --package bar")
|
||||
p.cargo("-Zunstable-options check --package bar --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] baz v0.0.1 ([ROOT]/foo/baz)
|
||||
[CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -174,10 +170,11 @@ fn proc_macro_dep() {
|
||||
|
||||
p.cargo("clean").run();
|
||||
|
||||
p.cargo("check --package bar --all-targets")
|
||||
p.cargo("-Zunstable-options check --package bar --all-targets --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] baz v0.0.1 ([ROOT]/foo/baz)
|
||||
[CHECKING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[COMPILING] baz v0.0.1 ([ROOT]/foo/baz)
|
||||
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -241,7 +238,8 @@ fn build_dep() {
|
||||
.file("bar/baz/src/lib.rs", r#"pub fn baz() {}"#)
|
||||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
p.cargo("-Zunstable-options check --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[COMPILING] baz v0.0.1 ([ROOT]/foo/bar/baz)
|
||||
@ -314,12 +312,12 @@ fn indirect_comp_time_dep() {
|
||||
.file("bar/baz/src/lib.rs", r#"pub fn baz() {}"#)
|
||||
.build();
|
||||
|
||||
p.cargo("check")
|
||||
p.cargo("-Zunstable-options check --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 2 packages to latest compatible versions
|
||||
[COMPILING] baz v0.0.1 ([ROOT]/foo/bar/baz)
|
||||
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
@ -379,21 +377,21 @@ fn tests_target() {
|
||||
)
|
||||
.build();
|
||||
|
||||
p.cargo("check --tests")
|
||||
p.cargo("-Zunstable-options check --tests --compile-time-deps")
|
||||
.with_stderr_data(str![[r#"
|
||||
[LOCKING] 1 package to latest compatible version
|
||||
[COMPILING] bar v0.0.1 ([ROOT]/foo/bar)
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.run();
|
||||
|
||||
p.cargo("clean").run();
|
||||
|
||||
p.cargo("check")
|
||||
p.cargo("-Zunstable-options check --compile-time-deps")
|
||||
.masquerade_as_nightly_cargo(&["compile-time-deps"])
|
||||
.with_stderr_data(str![[r#"
|
||||
[CHECKING] foo v0.0.1 ([ROOT]/foo)
|
||||
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
|
||||
|
||||
"#]])
|
||||
|
Loading…
x
Reference in New Issue
Block a user