From: Igor Matuszewski Date: Sat, 19 Aug 2017 20:47:19 +0000 (+0200) Subject: Expose `Target` and `Unit` params to appropriate `Executor` callbacks X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~7^2~11^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=2fd78db36136534e09d9cb8b66cdced985eb9798;p=cargo.git Expose `Target` and `Unit` params to appropriate `Executor` callbacks --- diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index ce5cdc456..febeb1c54 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -66,11 +66,18 @@ pub type PackagesToBuild<'a> = [(&'a Package, Vec<(&'a Target, &'a Profile)>)]; /// directly, we'll use an Executor, giving clients an opportunity to intercept /// the build calls. pub trait Executor: Send + Sync + 'static { - fn init(&self, _cx: &Context) {} - - /// If execution succeeds, the ContinueBuild value indicates whether Cargo - /// should continue with the build process for this package. - fn exec(&self, cmd: ProcessBuilder, _id: &PackageId) -> CargoResult<()> { + /// Called after a rustc process invocation is prepared up-front for a given + /// unit of work (may still be modified for runtime-known dependencies, when + /// the work is actually executed). + fn init(&self, _cx: &Context, _unit: &Unit) {} + + /// In case of an `Err`, Cargo will not continue with the build process for + /// this package. + fn exec(&self, + cmd: ProcessBuilder, + _id: &PackageId, + _target: &Target) + -> CargoResult<()> { cmd.exec()?; Ok(()) } @@ -78,6 +85,7 @@ pub trait Executor: Send + Sync + 'static { fn exec_json(&self, cmd: ProcessBuilder, _id: &PackageId, + _target: &Target, handle_stdout: &mut FnMut(&str) -> CargoResult<()>, handle_stderr: &mut FnMut(&str) -> CargoResult<()>) -> CargoResult<()> { @@ -315,7 +323,7 @@ fn rustc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, let package_id = unit.pkg.package_id().clone(); let target = unit.target.clone(); - exec.init(cx); + exec.init(cx, &unit); let exec = exec.clone(); let root_output = cx.target_root().to_path_buf(); @@ -358,7 +366,7 @@ fn rustc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, state.running(&rustc); if json_messages { - exec.exec_json(rustc, &package_id, + exec.exec_json(rustc, &package_id, &target, &mut |line| if !line.is_empty() { Err(internal(&format!("compiler stdout is not empty: `{}`", line))) } else { @@ -387,7 +395,7 @@ fn rustc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, format!("Could not compile `{}`.", name) })?; } else { - exec.exec(rustc, &package_id).map_err(|e| e.into_internal()).chain_err(|| { + exec.exec(rustc, &package_id, &target).map_err(|e| e.into_internal()).chain_err(|| { format!("Could not compile `{}`.", name) })?; }