From 823581006ce13044536c86ed24c6c97be96c9093 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 18 Feb 2020 14:08:22 -0800 Subject: [PATCH] Remove the `--build-plan` option This commit removes the "build plan" feature from Cargo. More information can be found in #7614. --- src/bin/cargo/commands/build.rs | 1 - src/cargo/core/compiler/build_config.rs | 3 - src/cargo/core/compiler/build_plan.rs | 162 ----------------- src/cargo/core/compiler/context/mod.rs | 26 +-- src/cargo/core/compiler/custom_build.rs | 64 +++---- src/cargo/core/compiler/job_queue.rs | 37 +--- src/cargo/core/compiler/mod.rs | 58 +++--- src/cargo/core/compiler/unit.rs | 7 - src/cargo/ops/cargo_compile.rs | 5 - src/cargo/util/command_prelude.rs | 13 -- src/doc/man/cargo-build.adoc | 9 - src/doc/man/generated/cargo-build.html | 11 -- src/doc/src/reference/unstable.md | 12 -- src/etc/_cargo | 1 - src/etc/man/cargo-build.1 | 20 +-- src/etc/man/cargo-generate-lockfile.1 | 6 +- src/etc/man/cargo-locate-project.1 | 6 +- src/etc/man/cargo-pkgid.1 | 6 +- src/etc/man/cargo-update.1 | 6 +- src/etc/man/cargo-verify-project.1 | 6 +- tests/testsuite/build_plan.rs | 224 ------------------------ tests/testsuite/main.rs | 1 - tests/testsuite/metabuild.rs | 103 ----------- 23 files changed, 74 insertions(+), 713 deletions(-) delete mode 100644 src/cargo/core/compiler/build_plan.rs delete mode 100644 tests/testsuite/build_plan.rs diff --git a/src/bin/cargo/commands/build.rs b/src/bin/cargo/commands/build.rs index 1ab83848bc5..2efa9634f32 100644 --- a/src/bin/cargo/commands/build.rs +++ b/src/bin/cargo/commands/build.rs @@ -40,7 +40,6 @@ pub fn cli() -> App { ) .arg_manifest_path() .arg_message_format() - .arg_build_plan() .after_help( "\ All packages in the workspace are built if the `--workspace` flag is supplied. The diff --git a/src/cargo/core/compiler/build_config.rs b/src/cargo/core/compiler/build_config.rs index c5c37e611b6..93af784b539 100644 --- a/src/cargo/core/compiler/build_config.rs +++ b/src/cargo/core/compiler/build_config.rs @@ -20,8 +20,6 @@ pub struct BuildConfig { pub message_format: MessageFormat, /// Force Cargo to do a full rebuild and treat each target as changed. pub force_rebuild: bool, - /// Output a build plan to stdout instead of actually compiling. - pub build_plan: bool, /// An optional override of the rustc path for primary units only pub primary_unit_rustc: Option, pub rustfix_diagnostic_server: RefCell>, @@ -78,7 +76,6 @@ impl BuildConfig { mode, message_format: MessageFormat::Human, force_rebuild: false, - build_plan: false, primary_unit_rustc: None, rustfix_diagnostic_server: RefCell::new(None), }) diff --git a/src/cargo/core/compiler/build_plan.rs b/src/cargo/core/compiler/build_plan.rs deleted file mode 100644 index 48072ba7aeb..00000000000 --- a/src/cargo/core/compiler/build_plan.rs +++ /dev/null @@ -1,162 +0,0 @@ -//! A graph-like structure used to represent the rustc commands to build the package and the -//! interdependencies between them. -//! -//! The BuildPlan structure is used to store the dependency graph of a dry run so that it can be -//! shared with an external build system. Each Invocation in the BuildPlan comprises a single -//! subprocess and defines the build environment, the outputs produced by the subprocess, and the -//! dependencies on other Invocations. - -use std::collections::BTreeMap; -use std::path::PathBuf; - -use serde::Serialize; - -use super::context::OutputFile; -use super::{CompileKind, CompileMode, Context, Unit}; -use crate::core::TargetKind; -use crate::util::{internal, CargoResult, ProcessBuilder}; - -#[derive(Debug, Serialize)] -struct Invocation { - package_name: String, - package_version: semver::Version, - target_kind: TargetKind, - kind: CompileKind, - compile_mode: CompileMode, - deps: Vec, - outputs: Vec, - links: BTreeMap, - program: String, - args: Vec, - env: BTreeMap, - cwd: Option, -} - -#[derive(Debug)] -pub struct BuildPlan { - invocation_map: BTreeMap, - plan: SerializedBuildPlan, -} - -#[derive(Debug, Serialize)] -struct SerializedBuildPlan { - invocations: Vec, - inputs: Vec, -} - -impl Invocation { - pub fn new(unit: &Unit<'_>, deps: Vec) -> Invocation { - let id = unit.pkg.package_id(); - Invocation { - package_name: id.name().to_string(), - package_version: id.version().clone(), - kind: unit.kind, - target_kind: unit.target.kind().clone(), - compile_mode: unit.mode, - deps, - outputs: Vec::new(), - links: BTreeMap::new(), - program: String::new(), - args: Vec::new(), - env: BTreeMap::new(), - cwd: None, - } - } - - pub fn add_output(&mut self, path: &PathBuf, link: &Option) { - self.outputs.push(path.clone()); - if let Some(ref link) = *link { - self.links.insert(link.clone(), path.clone()); - } - } - - pub fn update_cmd(&mut self, cmd: &ProcessBuilder) -> CargoResult<()> { - self.program = cmd - .get_program() - .to_str() - .ok_or_else(|| anyhow::format_err!("unicode program string required"))? - .to_string(); - self.cwd = Some(cmd.get_cwd().unwrap().to_path_buf()); - for arg in cmd.get_args().iter() { - self.args.push( - arg.to_str() - .ok_or_else(|| anyhow::format_err!("unicode argument string required"))? - .to_string(), - ); - } - for (var, value) in cmd.get_envs() { - let value = match value { - Some(s) => s, - None => continue, - }; - self.env.insert( - var.clone(), - value - .to_str() - .ok_or_else(|| anyhow::format_err!("unicode environment value required"))? - .to_string(), - ); - } - Ok(()) - } -} - -impl BuildPlan { - pub fn new() -> BuildPlan { - BuildPlan { - invocation_map: BTreeMap::new(), - plan: SerializedBuildPlan::new(), - } - } - - pub fn add<'a>(&mut self, cx: &Context<'a, '_>, unit: &Unit<'a>) -> CargoResult<()> { - let id = self.plan.invocations.len(); - self.invocation_map.insert(unit.buildkey(), id); - let deps = cx - .unit_deps(unit) - .iter() - .map(|dep| self.invocation_map[&dep.unit.buildkey()]) - .collect(); - let invocation = Invocation::new(unit, deps); - self.plan.invocations.push(invocation); - Ok(()) - } - - pub fn update( - &mut self, - invocation_name: &str, - cmd: &ProcessBuilder, - outputs: &[OutputFile], - ) -> CargoResult<()> { - let id = self.invocation_map[invocation_name]; - let invocation = - self.plan.invocations.get_mut(id).ok_or_else(|| { - internal(format!("couldn't find invocation for {}", invocation_name)) - })?; - - invocation.update_cmd(cmd)?; - for output in outputs.iter() { - invocation.add_output(&output.path, &output.hardlink); - } - - Ok(()) - } - - pub fn set_inputs(&mut self, inputs: Vec) { - self.plan.inputs = inputs; - } - - pub fn output_plan(self) { - let encoded = serde_json::to_string(&self.plan).unwrap(); - println!("{}", encoded); - } -} - -impl SerializedBuildPlan { - pub fn new() -> SerializedBuildPlan { - SerializedBuildPlan { - invocations: Vec::new(), - inputs: Vec::new(), - } - } -} diff --git a/src/cargo/core/compiler/context/mod.rs b/src/cargo/core/compiler/context/mod.rs index 197dcaca17e..df940cf72fd 100644 --- a/src/cargo/core/compiler/context/mod.rs +++ b/src/cargo/core/compiler/context/mod.rs @@ -1,5 +1,5 @@ #![allow(deprecated)] -use std::collections::{BTreeSet, HashMap, HashSet}; +use std::collections::{HashMap, HashSet}; use std::path::PathBuf; use std::sync::{Arc, Mutex}; @@ -11,7 +11,6 @@ use crate::core::PackageId; use crate::util::errors::{CargoResult, CargoResultExt}; use crate::util::{profile, Config}; -use super::build_plan::BuildPlan; use super::custom_build::{self, BuildDeps, BuildScriptOutputs, BuildScripts}; use super::fingerprint::Fingerprint; use super::job_queue::JobQueue; @@ -131,8 +130,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { exec: &Arc, ) -> CargoResult> { let mut queue = JobQueue::new(self.bcx, units); - let mut plan = BuildPlan::new(); - let build_plan = self.bcx.build_config.build_plan; self.prepare_units(export_dir, units)?; self.prepare()?; custom_build::build_map(&mut self, units)?; @@ -145,7 +142,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { // function which will run everything in order with proper // parallelism. let force_rebuild = self.bcx.build_config.force_rebuild; - super::compile(&mut self, &mut queue, &mut plan, unit, exec, force_rebuild)?; + super::compile(&mut self, &mut queue, unit, exec, force_rebuild)?; } // Now that we've got the full job queue and we've done all our @@ -159,12 +156,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> { } // Now that we've figured out everything that we're going to do, do it! - queue.execute(&mut self, &mut plan)?; - - if build_plan { - plan.set_inputs(self.build_plan_inputs()?); - plan.output_plan(); - } + queue.execute(&mut self)?; // Collect the result of the build into `self.compilation`. for unit in units.iter() { @@ -384,18 +376,6 @@ impl<'a, 'cfg> Context<'a, 'cfg> { self.primary_packages.contains(&unit.pkg.package_id()) } - /// Returns the list of filenames read by cargo to generate the `BuildContext` - /// (all `Cargo.toml`, etc.). - pub fn build_plan_inputs(&self) -> CargoResult> { - // Keep sorted for consistency. - let mut inputs = BTreeSet::new(); - // Note: dev-deps are skipped if they are not present in the unit graph. - for unit in self.unit_dependencies.keys() { - inputs.insert(unit.pkg.manifest_path().to_path_buf()); - } - Ok(inputs.into_iter().collect()) - } - fn check_collistions(&self) -> CargoResult<()> { let mut output_collisions = HashMap::new(); let describe_collision = diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index be03e05b5da..c75eeb921b2 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -157,8 +157,6 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes let script_dir = cx.files().build_script_dir(build_script_unit); let script_out_dir = cx.files().build_script_out_dir(unit); let script_run_dir = cx.files().build_script_run_dir(unit); - let build_plan = bcx.build_config.build_plan; - let invocation_name = unit.buildkey(); if let Some(deps) = unit.pkg.manifest().metabuild() { prepare_metabuild(cx, build_script_unit, deps)?; @@ -299,40 +297,34 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes // along to this custom build command. We're also careful to augment our // dynamic library search path in case the build script depended on any // native dynamic libraries. - if !build_plan { - let build_script_outputs = build_script_outputs.lock().unwrap(); - for (name, dep_id, dep_metadata) in lib_deps { - let script_output = - build_script_outputs - .get(dep_id, dep_metadata) - .ok_or_else(|| { - internal(format!( - "failed to locate build state for env vars: {}/{}", - dep_id, dep_metadata - )) - })?; - let data = &script_output.metadata; - for &(ref key, ref value) in data.iter() { - cmd.env( - &format!("DEP_{}_{}", super::envify(&name), super::envify(key)), - value, - ); - } - } - if let Some(build_scripts) = build_scripts { - super::add_plugin_deps( - &mut cmd, - &build_script_outputs, - &build_scripts, - &host_target_root, - )?; + let outputs = build_script_outputs.lock().unwrap(); + for (name, dep_id, dep_metadata) in lib_deps { + let script_output = + outputs + .get(dep_id, dep_metadata) + .ok_or_else(|| { + internal(format!( + "failed to locate build state for env vars: {}/{}", + dep_id, dep_metadata + )) + })?; + let data = &script_output.metadata; + for &(ref key, ref value) in data.iter() { + cmd.env( + &format!("DEP_{}_{}", super::envify(&name), super::envify(key)), + value, + ); } } - - if build_plan { - state.build_plan(invocation_name, cmd.clone(), Arc::new(Vec::new())); - return Ok(()); + if let Some(build_scripts) = build_scripts { + super::add_plugin_deps( + &mut cmd, + &outputs, + &build_scripts, + &host_target_root, + )?; } + drop(outputs); // And now finally, run the build command itself! state.running(&cmd); @@ -406,11 +398,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes Ok(()) }); - let mut job = if cx.bcx.build_config.build_plan { - Job::new(Work::noop(), Freshness::Dirty) - } else { - fingerprint::prepare_target(cx, unit, false)? - }; + let mut job = fingerprint::prepare_target(cx, unit, false)?; if job.freshness() == Freshness::Dirty { job.before(dirty); } else { diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 60ecaa31750..c2b65cd8914 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -54,7 +54,6 @@ use std::collections::{BTreeMap, HashMap, HashSet}; use std::io; use std::marker; use std::mem; -use std::sync::Arc; use std::time::Duration; use anyhow::format_err; @@ -63,13 +62,12 @@ use crossbeam_utils::thread::Scope; use jobserver::{Acquired, Client, HelperThread}; use log::{debug, info, trace}; -use super::context::OutputFile; use super::job::{ Freshness::{self, Dirty, Fresh}, Job, }; use super::timings::Timings; -use super::{BuildContext, BuildPlan, CompileMode, Context, Unit}; +use super::{BuildContext, CompileMode, Context, Unit}; use crate::core::{PackageId, TargetKind}; use crate::util; use crate::util::diagnostic_server::{self, DiagnosticPrinter}; @@ -183,7 +181,6 @@ enum Artifact { enum Message { Run(JobId, String), - BuildPlanMsg(String, ProcessBuilder, Arc>), Stdout(String), Stderr(String), FixDiagnostic(diagnostic_server::Message), @@ -202,17 +199,6 @@ impl<'a> JobState<'a> { let _ = self.tx.send(Message::Run(self.id, cmd.to_string())); } - pub fn build_plan( - &self, - module_name: String, - cmd: ProcessBuilder, - filenames: Arc>, - ) { - let _ = self - .tx - .send(Message::BuildPlanMsg(module_name, cmd, filenames)); - } - pub fn stdout(&self, stdout: String) { drop(self.tx.send(Message::Stdout(stdout))); } @@ -336,7 +322,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> { /// This function will spawn off `config.jobs()` workers to build all of the /// necessary dependencies, in order. Freshness is propagated as far as /// possible along each dependency chain. - pub fn execute(mut self, cx: &mut Context<'a, '_>, plan: &mut BuildPlan) -> CargoResult<()> { + pub fn execute(mut self, cx: &mut Context<'a, '_>) -> CargoResult<()> { let _p = profile::start("executing the job graph"); self.queue.queue_finished(); @@ -384,7 +370,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> { .take() .map(move |srv| srv.start(move |msg| drop(tx.send(Message::FixDiagnostic(msg))))); - crossbeam_utils::thread::scope(move |scope| state.drain_the_queue(cx, plan, scope, &helper)) + crossbeam_utils::thread::scope(move |scope| state.drain_the_queue(cx, scope, &helper)) .expect("child threads shouldn't panic") } } @@ -468,7 +454,6 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { &mut self, cx: &mut Context<'a, '_>, jobserver_helper: &HelperThread, - plan: &mut BuildPlan, event: Message, ) -> CargoResult> { match event { @@ -479,9 +464,6 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { .verbose(|c| c.status("Running", &cmd))?; self.timings.unit_start(id, self.active[&id]); } - Message::BuildPlanMsg(module_name, cmd, filenames) => { - plan.update(&module_name, &cmd, &filenames)?; - } Message::Stdout(out) => { cx.bcx.config.shell().stdout_println(out); } @@ -615,7 +597,6 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { fn drain_the_queue( mut self, cx: &mut Context<'a, '_>, - plan: &mut BuildPlan, scope: &Scope<'a>, jobserver_helper: &HelperThread, ) -> CargoResult<()> { @@ -649,7 +630,7 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { // don't actually use, and if this happens just relinquish it back // to the jobserver itself. for event in self.wait_for_events() { - if let Some(err) = self.handle_event(cx, jobserver_helper, plan, event)? { + if let Some(err) = self.handle_event(cx, jobserver_helper, event)? { error = Some(err); } } @@ -684,9 +665,7 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { "{} [{}] target(s) in {}", profile_name, opt_type, time_elapsed ); - if !cx.bcx.build_config.build_plan { - cx.bcx.config.shell().status("Finished", message)?; - } + cx.bcx.config.shell().status("Finished", message)?; Ok(()) } else { debug!("queue: {:#?}", self.queue); @@ -760,10 +739,8 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> { let fresh = job.freshness(); let rmeta_required = cx.rmeta_required(unit); - if !cx.bcx.build_config.build_plan { - // Print out some nice progress information. - self.note_working_on(cx.bcx.config, unit, fresh)?; - } + // Print out some nice progress information. + self.note_working_on(cx.bcx.config, unit, fresh)?; let doit = move || { let state = JobState { diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 096b185f13e..227802aae00 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -1,6 +1,5 @@ mod build_config; mod build_context; -mod build_plan; mod compilation; mod compile_kind; mod context; @@ -29,7 +28,6 @@ use log::debug; pub use self::build_config::{BuildConfig, CompileMode, MessageFormat}; pub use self::build_context::{BuildContext, FileFlavor, TargetInfo}; -use self::build_plan::BuildPlan; pub use self::compilation::{Compilation, Doctest}; pub use self::compile_kind::{CompileKind, CompileTarget}; pub use self::context::{Context, Metadata}; @@ -100,13 +98,10 @@ impl Executor for DefaultExecutor { fn compile<'a, 'cfg: 'a>( cx: &mut Context<'a, 'cfg>, jobs: &mut JobQueue<'a, 'cfg>, - plan: &mut BuildPlan, unit: &Unit<'a>, exec: &Arc, force_rebuild: bool, ) -> CargoResult<()> { - let bcx = cx.bcx; - let build_plan = bcx.build_config.build_plan; if !cx.compiled.insert(*unit) { return Ok(()); } @@ -121,8 +116,6 @@ fn compile<'a, 'cfg: 'a>( } else if unit.mode.is_doc_test() { // We run these targets later, so this is just a no-op for now. Job::new(Work::noop(), Freshness::Fresh) - } else if build_plan { - Job::new(rustc(cx, unit, &exec.clone())?, Freshness::Dirty) } else { let force = exec.force_rebuild(unit) || force_rebuild; let mut job = fingerprint::prepare_target(cx, unit, force)?; @@ -157,10 +150,7 @@ fn compile<'a, 'cfg: 'a>( // Be sure to compile all dependencies of this target as well. let deps = Vec::from(cx.unit_deps(unit)); // Create vec due to mutable borrow. for dep in deps { - compile(cx, jobs, plan, &dep.unit, exec, false)?; - } - if build_plan { - plan.add(cx, unit)?; + compile(cx, jobs, &dep.unit, exec, false)?; } Ok(()) @@ -172,10 +162,8 @@ fn rustc<'a, 'cfg>( exec: &Arc, ) -> CargoResult { let mut rustc = prepare_rustc(cx, &unit.target.rustc_crate_types(), unit)?; - let build_plan = cx.bcx.build_config.build_plan; let name = unit.pkg.name().to_string(); - let buildkey = unit.buildkey(); add_cap_lints(cx.bcx, unit, &mut rustc); @@ -236,17 +224,15 @@ fn rustc<'a, 'cfg>( // previous build scripts, we include them in the rustc invocation. if let Some(build_scripts) = build_scripts { let script_outputs = build_script_outputs.lock().unwrap(); - if !build_plan { - add_native_deps( - &mut rustc, - &script_outputs, - &build_scripts, - pass_l_flag, - pass_cdylib_link_args, - current_id, - )?; - add_plugin_deps(&mut rustc, &script_outputs, &build_scripts, &root_output)?; - } + add_native_deps( + &mut rustc, + &script_outputs, + &build_scripts, + pass_l_flag, + pass_cdylib_link_args, + current_id, + )?; + add_plugin_deps(&mut rustc, &script_outputs, &build_scripts, &root_output)?; add_custom_env(&mut rustc, &script_outputs, current_id, script_metadata)?; } @@ -277,20 +263,16 @@ fn rustc<'a, 'cfg>( state.running(&rustc); let timestamp = paths::set_invocation_time(&fingerprint_dir)?; - if build_plan { - state.build_plan(buildkey, rustc.clone(), outputs.clone()); - } else { - exec.exec( - rustc, - package_id, - &target, - mode, - &mut |line| on_stdout_line(state, line, package_id, &target), - &mut |line| on_stderr_line(state, line, package_id, &target, &mut output_options), - ) - .map_err(verbose_if_simple_exit_code) - .chain_err(|| format!("could not compile `{}`.", name))?; - } + exec.exec( + rustc, + package_id, + &target, + mode, + &mut |line| on_stdout_line(state, line, package_id, &target), + &mut |line| on_stderr_line(state, line, package_id, &target, &mut output_options), + ) + .map_err(verbose_if_simple_exit_code) + .chain_err(|| format!("could not compile `{}`.", name))?; if do_rename && real_name != crate_name { let dst = &outputs[0].path; diff --git a/src/cargo/core/compiler/unit.rs b/src/cargo/core/compiler/unit.rs index 205d351e0a6..864f86b0929 100644 --- a/src/cargo/core/compiler/unit.rs +++ b/src/cargo/core/compiler/unit.rs @@ -1,6 +1,5 @@ use crate::core::compiler::{CompileKind, CompileMode}; use crate::core::{profiles::Profile, Package, Target}; -use crate::util::hex::short_hash; use std::cell::RefCell; use std::collections::HashSet; use std::fmt; @@ -67,12 +66,6 @@ impl UnitInner<'_> { } } -impl<'a> Unit<'a> { - pub fn buildkey(&self) -> String { - format!("{}-{}", self.pkg.name(), short_hash(self)) - } -} - // Just hash the pointer for fast hashing impl<'a> Hash for Unit<'a> { fn hash(&self, hasher: &mut H) { diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 99b5c050177..a98873a5eb7 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -318,11 +318,6 @@ pub fn compile_ws<'a>( } = resolve; let std_resolve = if let Some(crates) = &config.cli_unstable().build_std { - if build_config.build_plan { - config - .shell() - .warn("-Zbuild-std does not currently fully support --build-plan")?; - } if build_config.requested_kind.is_host() { // TODO: This should eventually be fixed. Unfortunately it is not // easy to get the host triple in BuildConfig. Consider changing diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index a3477b4575a..cca3fbfe811 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -143,13 +143,6 @@ pub trait AppExt: Sized { self._arg(multi_opt("message-format", "FMT", "Error format")) } - fn arg_build_plan(self) -> Self { - self._arg(opt( - "build-plan", - "Output the build plan in JSON (unstable)", - )) - } - fn arg_new_opts(self) -> Self { self._arg( opt( @@ -437,12 +430,6 @@ pub trait ArgMatchesExt { let mut build_config = BuildConfig::new(config, self.jobs()?, &self.target(), mode)?; build_config.message_format = message_format.unwrap_or(MessageFormat::Human); build_config.requested_profile = self.get_profile_name(config, "dev", profile_checking)?; - build_config.build_plan = self._is_present("build-plan"); - if build_config.build_plan { - config - .cli_unstable() - .fail_if_stable_opt("--build-plan", 5579)?; - }; let opts = CompileOptions { config, diff --git a/src/doc/man/cargo-build.adoc b/src/doc/man/cargo-build.adoc index a7b20d7de64..e8f64699652 100644 --- a/src/doc/man/cargo-build.adoc +++ b/src/doc/man/cargo-build.adoc @@ -55,15 +55,6 @@ include::options-display.adoc[] include::options-message-format.adoc[] -*--build-plan*:: - Outputs a series of JSON messages to stdout that indicate the commands to - run the build. -+ -This option is unstable and available only on the -link:https://doc.rust-lang.org/book/appendix-07-nightly-rust.html[nightly channel] -and requires the `-Z unstable-options` flag to enable. -See https://github.com/rust-lang/cargo/issues/5579 for more information. - === Manifest Options include::options-manifest-path.adoc[] diff --git a/src/doc/man/generated/cargo-build.html b/src/doc/man/generated/cargo-build.html index 4ea50b0acc1..b6244c25f89 100644 --- a/src/doc/man/generated/cargo-build.html +++ b/src/doc/man/generated/cargo-build.html @@ -283,17 +283,6 @@

Display Options

-
--build-plan
-
-

Outputs a series of JSON messages to stdout that indicate the commands to -run the build.

-
-

This option is unstable and available only on the -nightly channel -and requires the -Z unstable-options flag to enable. -See https://github.com/rust-lang/cargo/issues/5579 for more information.

-
-
diff --git a/src/doc/src/reference/unstable.md b/src/doc/src/reference/unstable.md index bb0f8d8b889..e080f492097 100644 --- a/src/doc/src/reference/unstable.md +++ b/src/doc/src/reference/unstable.md @@ -186,18 +186,6 @@ a feature of the same name as a dependency is defined, that feature must include the dependency as a requirement, as `foo = ["crate:foo"]`. -### Build-plan -* Tracking Issue: [#5579](https://github.com/rust-lang/cargo/issues/5579) - -The `--build-plan` argument for the `build` command will output JSON with -information about which commands would be run without actually executing -anything. This can be useful when integrating with another build tool. -Example: - -``` -cargo +nightly build --build-plan -Z unstable-options -``` - ### Metabuild * Tracking Issue: [rust-lang/rust#49803](https://github.com/rust-lang/rust/issues/49803) * RFC: [#2196](https://github.com/rust-lang/rfcs/blob/master/text/2196-metabuild.md) diff --git a/src/etc/_cargo b/src/etc/_cargo index 12694901ed0..a04090b60ac 100644 --- a/src/etc/_cargo +++ b/src/etc/_cargo @@ -83,7 +83,6 @@ _cargo() { "${command_scope_spec[@]}" \ '(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \ '--release[build in release mode]' \ - '--build-plan[output the build plan in JSON]' \ ;; check) diff --git a/src/etc/man/cargo-build.1 b/src/etc/man/cargo-build.1 index 17ed8d17913..c6c8262a1d5 100644 --- a/src/etc/man/cargo-build.1 +++ b/src/etc/man/cargo-build.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-build .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2020-02-18 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-BUILD" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-BUILD" "1" "2020-02-18" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -349,20 +349,6 @@ JSON diagnostics coming from rustc. Cargo\(cqs own JSON diagnostics and others coming from rustc are still emitted. .RE .RE -.sp -\fB\-\-build\-plan\fP -.RS 4 -Outputs a series of JSON messages to stdout that indicate the commands to -run the build. -.sp -This option is unstable and available only on the -\c -.URL "https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html" "nightly channel" -and requires the \fB\-Z unstable\-options\fP flag to enable. -See \c -.URL "https://github.com/rust\-lang/cargo/issues/5579" "" " " -for more information. -.RE .SS "Manifest Options" .sp \fB\-\-manifest\-path\fP \fIPATH\fP diff --git a/src/etc/man/cargo-generate-lockfile.1 b/src/etc/man/cargo-generate-lockfile.1 index 1c890c2bbbb..83e412603a1 100644 --- a/src/etc/man/cargo-generate-lockfile.1 +++ b/src/etc/man/cargo-generate-lockfile.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-generate-lockfile .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2019-06-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-GENERATE\-LOCKFILE" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-GENERATE\-LOCKFILE" "1" "2019-06-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/src/etc/man/cargo-locate-project.1 b/src/etc/man/cargo-locate-project.1 index 7868e618ec6..cdcb798c984 100644 --- a/src/etc/man/cargo-locate-project.1 +++ b/src/etc/man/cargo-locate-project.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-locate-project .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2019-06-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-LOCATE\-PROJECT" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-LOCATE\-PROJECT" "1" "2019-06-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/src/etc/man/cargo-pkgid.1 b/src/etc/man/cargo-pkgid.1 index 4a3e50f0777..b7acbaefd16 100644 --- a/src/etc/man/cargo-pkgid.1 +++ b/src/etc/man/cargo-pkgid.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-pkgid .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2019-06-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-PKGID" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-PKGID" "1" "2019-06-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/src/etc/man/cargo-update.1 b/src/etc/man/cargo-update.1 index 91595807ff4..96adb2c4aed 100644 --- a/src/etc/man/cargo-update.1 +++ b/src/etc/man/cargo-update.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-update .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2019-06-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-UPDATE" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-UPDATE" "1" "2019-06-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/src/etc/man/cargo-verify-project.1 b/src/etc/man/cargo-verify-project.1 index d2f05cbfdfc..251c59f2460 100644 --- a/src/etc/man/cargo-verify-project.1 +++ b/src/etc/man/cargo-verify-project.1 @@ -1,13 +1,13 @@ '\" t .\" Title: cargo-verify-project .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.10 -.\" Date: 2019-09-05 +.\" Generator: Asciidoctor 2.0.8 +.\" Date: 2019-06-07 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "CARGO\-VERIFY\-PROJECT" "1" "2019-09-05" "\ \&" "\ \&" +.TH "CARGO\-VERIFY\-PROJECT" "1" "2019-06-07" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 diff --git a/tests/testsuite/build_plan.rs b/tests/testsuite/build_plan.rs deleted file mode 100644 index 6161dd83c7e..00000000000 --- a/tests/testsuite/build_plan.rs +++ /dev/null @@ -1,224 +0,0 @@ -//! Tests for --build-plan feature. - -use cargo_test_support::registry::Package; -use cargo_test_support::{basic_bin_manifest, basic_manifest, main_file, project}; - -#[cargo_test] -fn cargo_build_plan_simple() { - let p = project() - .file("Cargo.toml", &basic_bin_manifest("foo")) - .file("src/foo.rs", &main_file(r#""i am foo""#, &[])) - .build(); - - p.cargo("build --build-plan -Zunstable-options") - .masquerade_as_nightly_cargo() - .with_json( - r#" - { - "inputs": [ - "[..]/foo/Cargo.toml" - ], - "invocations": [ - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": "{...}", - "package_name": "foo", - "package_version": "0.5.0", - "program": "rustc", - "target_kind": ["bin"], - "compile_mode": "build" - } - ] - } - "#, - ) - .run(); - assert!(!p.bin("foo").is_file()); -} - -#[cargo_test] -fn cargo_build_plan_single_dep() { - let p = project() - .file( - "Cargo.toml", - r#" - [package] - name = "foo" - authors = [] - version = "0.5.0" - - [dependencies] - bar = { path = "bar" } - "#, - ) - .file( - "src/lib.rs", - r#" - extern crate bar; - pub fn foo() { bar::bar(); } - - #[test] - fn test() { foo(); } - "#, - ) - .file("bar/Cargo.toml", &basic_manifest("bar", "0.0.1")) - .file("bar/src/lib.rs", "pub fn bar() {}") - .build(); - p.cargo("build --build-plan -Zunstable-options") - .masquerade_as_nightly_cargo() - .with_json( - r#" - { - "inputs": [ - "[..]/foo/Cargo.toml", - "[..]/foo/bar/Cargo.toml" - ], - "invocations": [ - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": [ - "[..]/foo/target/debug/deps/libbar-[..].rlib", - "[..]/foo/target/debug/deps/libbar-[..].rmeta" - ], - "package_name": "bar", - "package_version": "0.0.1", - "program": "rustc", - "target_kind": ["lib"], - "compile_mode": "build" - }, - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [0], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": [ - "[..]/foo/target/debug/deps/libfoo-[..].rlib", - "[..]/foo/target/debug/deps/libfoo-[..].rmeta" - ], - "package_name": "foo", - "package_version": "0.5.0", - "program": "rustc", - "target_kind": ["lib"], - "compile_mode": "build" - } - ] - } - "#, - ) - .run(); -} - -#[cargo_test] -fn cargo_build_plan_build_script() { - let p = project() - .file( - "Cargo.toml", - r#" - [project] - - name = "foo" - version = "0.5.0" - authors = ["wycats@example.com"] - build = "build.rs" - "#, - ) - .file("src/main.rs", r#"fn main() {}"#) - .file("build.rs", r#"fn main() {}"#) - .build(); - - p.cargo("build --build-plan -Zunstable-options") - .masquerade_as_nightly_cargo() - .with_json( - r#" - { - "inputs": [ - "[..]/foo/Cargo.toml" - ], - "invocations": [ - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": [ - "[..]/foo/target/debug/build/[..]/build_script_build-[..]" - ], - "package_name": "foo", - "package_version": "0.5.0", - "program": "rustc", - "target_kind": ["custom-build"], - "compile_mode": "build" - }, - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [0], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": [], - "package_name": "foo", - "package_version": "0.5.0", - "program": "[..]/build-script-build", - "target_kind": ["custom-build"], - "compile_mode": "run-custom-build" - }, - { - "args": "{...}", - "cwd": "[..]/cit/[..]/foo", - "deps": [1], - "env": "{...}", - "kind": "Host", - "links": "{...}", - "outputs": "{...}", - "package_name": "foo", - "package_version": "0.5.0", - "program": "rustc", - "target_kind": ["bin"], - "compile_mode": "build" - } - ] - } - "#, - ) - .run(); -} - -#[cargo_test] -fn build_plan_with_dev_dep() { - Package::new("bar", "0.1.0").publish(); - - let p = project() - .file( - "Cargo.toml", - r#" - [project] - name = "foo" - version = "0.5.0" - authors = [] - - [dev-dependencies] - bar = "*" - "#, - ) - .file("src/lib.rs", "") - .build(); - - p.cargo("build --build-plan -Zunstable-options") - .masquerade_as_nightly_cargo() - .run(); -} diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index fa22a1e7658..f95b509d048 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -17,7 +17,6 @@ mod bad_config; mod bad_manifest_path; mod bench; mod build; -mod build_plan; mod build_script; mod build_script_env; mod cache_messages; diff --git a/tests/testsuite/metabuild.rs b/tests/testsuite/metabuild.rs index 004a39e569e..87f04b98a3a 100644 --- a/tests/testsuite/metabuild.rs +++ b/tests/testsuite/metabuild.rs @@ -446,109 +446,6 @@ fn metabuild_metadata() { assert_eq!(mb_info, ["mb", "mb-other"]); } -#[cargo_test] -fn metabuild_build_plan() { - let p = basic_project(); - - p.cargo("build --build-plan -Zunstable-options") - .masquerade_as_nightly_cargo() - .with_json( - r#" -{ - "invocations": [ - { - "package_name": "mb", - "package_version": "0.5.0", - "target_kind": ["lib"], - "compile_mode": "build", - "kind": "Host", - "deps": [], - "outputs": [ - "[..]/target/debug/deps/libmb-[..].rlib", - "[..]/target/debug/deps/libmb-[..].rmeta" - ], - "links": {}, - "program": "rustc", - "args": "{...}", - "env": "{...}", - "cwd": "[..]" - }, - { - "package_name": "mb-other", - "package_version": "0.0.1", - "target_kind": ["lib"], - "compile_mode": "build", - "kind": "Host", - "deps": [], - "outputs": [ - "[..]/target/debug/deps/libmb_other-[..].rlib", - "[..]/target/debug/deps/libmb_other-[..].rmeta" - ], - "links": {}, - "program": "rustc", - "args": "{...}", - "env": "{...}", - "cwd": "[..]" - }, - { - "package_name": "foo", - "package_version": "0.0.1", - "target_kind": ["custom-build"], - "compile_mode": "build", - "kind": "Host", - "deps": [0, 1], - "outputs": ["[..]/target/debug/build/foo-[..]/metabuild_foo-[..][EXE]"], - "links": "{...}", - "program": "rustc", - "args": "{...}", - "env": "{...}", - "cwd": "[..]" - }, - { - "package_name": "foo", - "package_version": "0.0.1", - "target_kind": ["custom-build"], - "compile_mode": "run-custom-build", - "kind": "Host", - "deps": [2], - "outputs": [], - "links": {}, - "program": "[..]/foo/target/debug/build/foo-[..]/metabuild-foo", - "args": [], - "env": "{...}", - "cwd": "[..]" - }, - { - "package_name": "foo", - "package_version": "0.0.1", - "target_kind": ["lib"], - "compile_mode": "build", - "kind": "Host", - "deps": [3], - "outputs": [ - "[..]/foo/target/debug/deps/libfoo-[..].rlib", - "[..]/foo/target/debug/deps/libfoo-[..].rmeta" - ], - "links": "{...}", - "program": "rustc", - "args": "{...}", - "env": "{...}", - "cwd": "[..]" - } - ], - "inputs": [ - "[..]/foo/Cargo.toml", - "[..]/foo/mb/Cargo.toml", - "[..]/foo/mb-other/Cargo.toml" - ] -} -"#, - ) - .run(); - - assert_eq!(p.glob("target/.metabuild/metabuild-foo-*.rs").count(), 1); -} - #[cargo_test] fn metabuild_two_versions() { // Two versions of a metabuild dep with the same name.