Skip to content

Commit 4aac07d

Browse files
authored
fix: Remove build-plan (#16212)
### What does this PR try to resolve? Removes long-deprecated unstable functionality Closes #5579, #7614, #7068, #6954, #5855 ### How to test and review this PR?
2 parents 88c0fba + dda1d49 commit 4aac07d

File tree

21 files changed

+115
-813
lines changed

21 files changed

+115
-813
lines changed

src/bin/cargo/commands/build.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub fn cli() -> Command {
3535
.arg_target_triple("Build for the target triple")
3636
.arg_target_dir()
3737
.arg_artifact_dir()
38-
.arg_build_plan()
3938
.arg_unit_graph()
4039
.arg_timings()
4140
.arg_compile_time_deps()

src/cargo/core/compiler/build_config.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ pub struct BuildConfig {
2727
pub message_format: MessageFormat,
2828
/// Force Cargo to do a full rebuild and treat each target as changed.
2929
pub force_rebuild: bool,
30-
/// Output a build plan to stdout instead of actually compiling.
31-
pub build_plan: bool,
3230
/// Output the unit graph to stdout instead of actually compiling.
3331
pub unit_graph: bool,
3432
/// `true` to avoid really compiling.
@@ -123,7 +121,6 @@ impl BuildConfig {
123121
intent,
124122
message_format: MessageFormat::Human,
125123
force_rebuild: false,
126-
build_plan: false,
127124
unit_graph: false,
128125
dry_run: false,
129126
primary_unit_rustc: None,

src/cargo/core/compiler/build_plan.rs

Lines changed: 0 additions & 160 deletions
This file was deleted.

src/cargo/core/compiler/build_runner/mod.rs

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! [`BuildRunner`] is the mutable state used during the build process.
22
3-
use std::collections::{BTreeSet, HashMap, HashSet};
3+
use std::collections::{HashMap, HashSet};
44
use std::path::{Path, PathBuf};
55
use std::sync::{Arc, Mutex};
66

@@ -16,7 +16,6 @@ use filetime::FileTime;
1616
use itertools::Itertools;
1717
use jobserver::Client;
1818

19-
use super::build_plan::BuildPlan;
2019
use super::custom_build::{self, BuildDeps, BuildScriptOutputs, BuildScripts};
2120
use super::fingerprint::{Checksum, Fingerprint};
2221
use super::job_queue::JobQueue;
@@ -168,8 +167,6 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
168167
.gctx
169168
.acquire_package_cache_lock(CacheLockMode::Shared)?;
170169
let mut queue = JobQueue::new(self.bcx);
171-
let mut plan = BuildPlan::new();
172-
let build_plan = self.bcx.build_config.build_plan;
173170
self.lto = super::lto::generate(self.bcx)?;
174171
self.prepare_units()?;
175172
self.prepare()?;
@@ -191,7 +188,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
191188

192189
for unit in &self.bcx.roots {
193190
let force_rebuild = self.bcx.build_config.force_rebuild;
194-
super::compile(&mut self, &mut queue, &mut plan, unit, exec, force_rebuild)?;
191+
super::compile(&mut self, &mut queue, unit, exec, force_rebuild)?;
195192
}
196193

197194
// Now that we've got the full job queue and we've done all our
@@ -205,12 +202,7 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
205202
}
206203

207204
// Now that we've figured out everything that we're going to do, do it!
208-
queue.execute(&mut self, &mut plan)?;
209-
210-
if build_plan {
211-
plan.set_inputs(self.build_plan_inputs()?);
212-
plan.output_plan(self.bcx.gctx);
213-
}
205+
queue.execute(&mut self)?;
214206

215207
// Add `OUT_DIR` to env vars if unit has a build script.
216208
let units_with_build_script = &self
@@ -488,18 +480,6 @@ impl<'a, 'gctx> BuildRunner<'a, 'gctx> {
488480
self.primary_packages.contains(&unit.pkg.package_id())
489481
}
490482

491-
/// Returns the list of filenames read by cargo to generate the [`BuildContext`]
492-
/// (all `Cargo.toml`, etc.).
493-
pub fn build_plan_inputs(&self) -> CargoResult<Vec<PathBuf>> {
494-
// Keep sorted for consistency.
495-
let mut inputs = BTreeSet::new();
496-
// Note: dev-deps are skipped if they are not present in the unit graph.
497-
for unit in self.bcx.unit_graph.keys() {
498-
inputs.insert(unit.pkg.manifest_path().to_path_buf());
499-
}
500-
Ok(inputs.into_iter().collect())
501-
}
502-
503483
/// Returns a [`UnitOutput`] which represents some information about the
504484
/// output of a unit.
505485
pub fn unit_output(&self, unit: &Unit, path: &Path) -> UnitOutput {

src/cargo/core/compiler/custom_build.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ use super::{BuildRunner, Job, Unit, Work, fingerprint, get_dynamic_search_path};
3535
use crate::core::compiler::CompileMode;
3636
use crate::core::compiler::artifact;
3737
use crate::core::compiler::build_runner::UnitHash;
38-
use crate::core::compiler::fingerprint::DirtyReason;
3938
use crate::core::compiler::job_queue::JobState;
4039
use crate::core::{PackageId, Target, profiles::ProfileRoot};
4140
use crate::util::errors::CargoResult;
@@ -340,8 +339,6 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
340339
let script_dir = build_runner.files().build_script_dir(build_script_unit);
341340
let script_out_dir = build_runner.files().build_script_out_dir(unit);
342341
let script_run_dir = build_runner.files().build_script_run_dir(unit);
343-
let build_plan = bcx.build_config.build_plan;
344-
let invocation_name = unit.buildkey();
345342

346343
if let Some(deps) = unit.pkg.manifest().metabuild() {
347344
prepare_metabuild(build_runner, build_script_unit, deps)?;
@@ -527,7 +524,7 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
527524
// along to this custom build command. We're also careful to augment our
528525
// dynamic library search path in case the build script depended on any
529526
// native dynamic libraries.
530-
if !build_plan {
527+
{
531528
let build_script_outputs = build_script_outputs.lock().unwrap();
532529
for (name, dep_id, dep_metadata) in lib_deps {
533530
let script_output = build_script_outputs.get(dep_metadata).ok_or_else(|| {
@@ -554,11 +551,6 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
554551
}
555552
}
556553

557-
if build_plan {
558-
state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new()));
559-
return Ok(());
560-
}
561-
562554
// And now finally, run the build command itself!
563555
state.running(&cmd);
564556
let timestamp = paths::set_invocation_time(&script_run_dir)?;
@@ -706,11 +698,7 @@ fn build_work(build_runner: &mut BuildRunner<'_, '_>, unit: &Unit) -> CargoResul
706698
Ok(())
707699
});
708700

709-
let mut job = if build_runner.bcx.build_config.build_plan {
710-
Job::new_dirty(Work::noop(), DirtyReason::FreshBuild)
711-
} else {
712-
fingerprint::prepare_target(build_runner, unit, false)?
713-
};
701+
let mut job = fingerprint::prepare_target(build_runner, unit, false)?;
714702
if job.freshness().is_dirty() {
715703
job.before(dirty);
716704
} else {

src/cargo/core/compiler/job_queue/job_state.rs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use std::{cell::Cell, marker, sync::Arc};
55
use cargo_util::ProcessBuilder;
66

77
use crate::CargoResult;
8-
use crate::core::compiler::build_runner::OutputFile;
98
use crate::core::compiler::future_incompat::FutureBreakageItem;
109
use crate::core::compiler::timings::SectionTiming;
1110
use crate::util::Queue;
@@ -73,16 +72,6 @@ impl<'a, 'gctx> JobState<'a, 'gctx> {
7372
self.messages.push(Message::Run(self.id, cmd.to_string()));
7473
}
7574

76-
pub fn build_plan(
77-
&self,
78-
module_name: String,
79-
cmd: ProcessBuilder,
80-
filenames: Arc<Vec<OutputFile>>,
81-
) {
82-
self.messages
83-
.push(Message::BuildPlanMsg(module_name, cmd, filenames));
84-
}
85-
8675
pub fn stdout(&self, stdout: String) -> CargoResult<()> {
8776
if let Some(dedupe) = self.output {
8877
writeln!(dedupe.gctx.shell().out(), "{}", stdout)?;

0 commit comments

Comments
 (0)