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

Allow build plan to also emit file inputs per invocation #6213

Closed
wants to merge 15 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Clean up and rustfmt
  • Loading branch information
Xanewok committed Nov 14, 2018
commit 14739f3673c5094793d27d2c1282d4148628a6bf
19 changes: 8 additions & 11 deletions src/bin/cargo/command_prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,17 +292,14 @@ pub trait ArgMatchesExt {
let mut build_config = BuildConfig::new(config, self.jobs()?, &self.target(), mode)?;
build_config.message_format = message_format;
build_config.release = self._is_present("release");
build_config.build_plan = match (self._is_present("build-plan"), self._value_of("build-plan")) {
(false, _) => BuildPlanMode::NoEmit,
(true, Some(val)) if val.eq_ignore_ascii_case("detailed") => {
config.shell().warn(format!("REMOVEME: Detailed"))?;
BuildPlanMode::Detailed
},
(true, _) => {
config.shell().warn(format!("REMOVEME: Commands only"))?;
BuildPlanMode::CommandsOnly
},
};
build_config.build_plan =
match (self._is_present("build-plan"), self._value_of("build-plan")) {
(false, _) => BuildPlanMode::NoEmit,
(true, Some(val)) if val.eq_ignore_ascii_case("detailed") => {
BuildPlanMode::Detailed
}
(true, _) => BuildPlanMode::CommandsOnly,
};

if build_config.build_plan.should_emit() && !config.cli_unstable().unstable_options {
Err(format_err!(
Expand Down
16 changes: 11 additions & 5 deletions src/cargo/core/compiler/build_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,11 @@ impl BuildPlan {
Ok(())
}

pub fn update_file_deps<'a, 'b>(&mut self, cx: &mut Context<'a, 'b>, units: &[Unit<'a>]) -> CargoResult<()> {
pub fn update_file_deps<'a, 'b>(
&mut self,
cx: &mut Context<'a, 'b>,
units: &[Unit<'a>],
) -> CargoResult<()> {
for unit in units {
{
let mut invocation = self.get_invocation_mut(&unit.buildkey())?;
Expand Down Expand Up @@ -171,10 +175,12 @@ impl BuildPlan {

fn get_invocation_mut(&mut self, buildkey: impl AsRef<str>) -> CargoResult<&mut Invocation> {
let id = self.invocation_map[buildkey.as_ref()];
self.plan
.invocations
.get_mut(id)
.ok_or_else(|| internal(format!("couldn't find invocation for {}", buildkey.as_ref())))
self.plan.invocations.get_mut(id).ok_or_else(|| {
internal(format!(
"couldn't find invocation for {}",
buildkey.as_ref()
))
})
}
}

Expand Down
11 changes: 7 additions & 4 deletions src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::collections::{BTreeSet, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::str;
use std::sync::{Arc, Mutex};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};

use core::PackageId;
use util::errors::{CargoResult, CargoResultExt};
Expand Down Expand Up @@ -370,9 +370,12 @@ fn build_work<'a, 'cfg>(
} else if plan_can_skip {
let output = match prev_output_clone {
Some(output) => output,
None => {
BuildOutput::parse_file(&output_file, &pkg_name, &prev_root_output_clone, &root_output)?
}
None => BuildOutput::parse_file(
&output_file,
&pkg_name,
&prev_root_output_clone,
&root_output,
)?,
};

if json_messages {
Expand Down
10 changes: 7 additions & 3 deletions src/cargo/core/compiler/output_depinfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ fn dep_info_basedir(cx: &Context<'_, '_>) -> CargoResult<Option<String>> {
.map(|option| option.map(|o| o.val))
}

fn render_filename(path: impl AsRef<Path>, basedir: Option<impl AsRef<Path>>) -> CargoResult<String> {
fn render_filename(
path: impl AsRef<Path>,
basedir: Option<impl AsRef<Path>>,
) -> CargoResult<String> {
let (path, basedir) = (path.as_ref(), basedir.as_ref());
let relpath = match basedir {
None => path,
Expand Down Expand Up @@ -102,10 +105,11 @@ pub fn output_depinfo<'a, 'b>(cx: &mut Context<'a, 'b>, unit: &Unit<'a>) -> Carg

let (success, deps) = match dep_files_for_unit(cx, unit)? {
Ok(deps) => (true, deps),
_ => (false, vec![])
_ => (false, vec![]),
};

let deps = deps.iter()
let deps = deps
.iter()
.map(|f| render_filename(f, basedir.as_ref()))
.collect::<CargoResult<Vec<_>>>()?;

Expand Down