Skip to content

Commit 4740f65

Browse files
committed
internal: Utilize cargo check --compile-time-deps
1 parent df50136 commit 4740f65

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

crates/project-model/src/build_dependencies.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ use toolchain::Tool;
2020

2121
use crate::{
2222
CargoConfig, CargoFeatures, CargoWorkspace, InvocationStrategy, ManifestPath, Package, Sysroot,
23-
TargetKind, utf8_stdout,
23+
TargetKind,
24+
toolchain_info::{QueryConfig, version},
25+
utf8_stdout,
2426
};
2527

2628
/// Output of the build script and proc-macro building steps for a workspace.
@@ -442,6 +444,27 @@ impl WorkspaceBuildScripts {
442444

443445
cmd.arg("--keep-going");
444446

447+
// If [`--compile-time-deps` flag](https://github.com/rust-lang/cargo/issues/14434) is
448+
// available in current toolchain's cargo, use it to build compile time deps only.
449+
const COMP_TIME_DEPS_MIN_TOOLCHAIN_VERSION: semver::Version = semver::Version {
450+
major: 1,
451+
minor: 90,
452+
patch: 0,
453+
pre: semver::Prerelease::EMPTY,
454+
build: semver::BuildMetadata::EMPTY,
455+
};
456+
457+
let query_config = QueryConfig::Cargo(sysroot, manifest_path);
458+
let toolchain = version::get(query_config, &config.extra_env).ok().flatten();
459+
let cargo_comp_time_deps_available =
460+
toolchain.is_some_and(|v| v >= COMP_TIME_DEPS_MIN_TOOLCHAIN_VERSION);
461+
462+
if cargo_comp_time_deps_available {
463+
cmd.env("__CARGO_TEST_CHANNEL_OVERRIDE_DO_NOT_USE_THIS", "nightly");
464+
cmd.arg("-Zunstable-options");
465+
cmd.arg("--compile-time-deps");
466+
}
467+
445468
cmd
446469
}
447470
};

0 commit comments

Comments
 (0)