Use Unit type as interface to compilation
authorDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 11 Apr 2018 22:37:30 +0000 (00:37 +0200)
committerDirkjan Ochtman <dirkjan@ochtman.nl>
Wed, 11 Apr 2018 22:37:30 +0000 (00:37 +0200)
src/cargo/ops/cargo_compile.rs
src/cargo/ops/cargo_rustc/context/mod.rs
src/cargo/ops/cargo_rustc/mod.rs

index fc2c1c3d7974947cd72a04df043a7e20c692cb46..17d370eda3c8b7b61d28168a29b0894b3cf24c53 100644 (file)
@@ -29,7 +29,7 @@ use std::sync::Arc;
 use core::{Package, Source, Target};
 use core::{PackageId, PackageIdSpec, Profile, Profiles, TargetKind, Workspace};
 use core::resolver::{Method, Resolve};
-use ops::{self, BuildOutput, Context, DefaultExecutor, Executor};
+use ops::{self, BuildOutput, Context, DefaultExecutor, Executor, Kind, Unit};
 use util::config::Config;
 use util::{profile, CargoResult, CargoResultExt};
 
@@ -355,7 +355,27 @@ pub fn compile_ws<'a>(
             build_config,
             profiles,
         )?;
-        cx.compile(&package_targets, export_dir.clone(), &exec)?
+        let units = package_targets
+            .iter()
+            .flat_map(|&(pkg, ref targets)| {
+                let default_kind = if cx.build_config.requested_target.is_some() {
+                    Kind::Target
+                } else {
+                    Kind::Host
+                };
+                targets.iter().map(move |&(target, profile)| Unit {
+                    pkg,
+                    target,
+                    profile,
+                    kind: if target.for_host() {
+                        Kind::Host
+                    } else {
+                        default_kind
+                    },
+                })
+            })
+            .collect::<Vec<_>>();
+        cx.compile(&units, export_dir.clone(), &exec)?
     };
 
     ret.to_doc_test = to_builds.into_iter().cloned().collect();
index 757c25587c73bf44eb838aed3b29a2e23732093d..2d317f8c15a2af53df33959f288765e840e25f3f 100644 (file)
@@ -19,7 +19,7 @@ use super::fingerprint::Fingerprint;
 use super::job_queue::JobQueue;
 use super::layout::Layout;
 use super::links::Links;
-use super::{BuildConfig, Compilation, Executor, Kind, PackagesToBuild};
+use super::{BuildConfig, Compilation, Executor, Kind};
 
 mod unit_dependencies;
 use self::unit_dependencies::build_unit_dependencies;
@@ -158,33 +158,12 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
     // where the compiled libraries are all located.
     pub fn compile(
         mut self,
-        pkg_targets: &'a PackagesToBuild<'a>,
+        units: &[Unit<'a>],
         export_dir: Option<PathBuf>,
         exec: &Arc<Executor>,
     ) -> CargoResult<Compilation<'cfg>> {
-        let units = pkg_targets
-            .iter()
-            .flat_map(|&(pkg, ref targets)| {
-                let default_kind = if self.build_config.requested_target.is_some() {
-                    Kind::Target
-                } else {
-                    Kind::Host
-                };
-                targets.iter().map(move |&(target, profile)| Unit {
-                    pkg,
-                    target,
-                    profile,
-                    kind: if target.for_host() {
-                        Kind::Host
-                    } else {
-                        default_kind
-                    },
-                })
-            })
-            .collect::<Vec<_>>();
-
         let mut queue = JobQueue::new(&self);
-        self.prepare_units(export_dir, &units)?;
+        self.prepare_units(export_dir, units)?;
         self.prepare()?;
         self.build_used_in_plugin_map(&units)?;
         custom_build::build_map(&mut self, &units)?;
index 5380f70bda8f5781d31cfbd123368af53f87af6f..47c1237a145ac3b0f396abc21a786aeb27968e87 100644 (file)
@@ -9,7 +9,7 @@ use std::sync::Arc;
 use same_file::is_same_file;
 use serde_json;
 
-use core::{Feature, Package, PackageId, Profile, Target};
+use core::{Feature, PackageId, Profile, Target};
 use core::manifest::Lto;
 use core::shell::ColorChoice;
 use util::{self, machine_message, ProcessBuilder};
@@ -102,8 +102,6 @@ pub struct TargetConfig {
     pub overrides: HashMap<String, BuildOutput>,
 }
 
-pub type PackagesToBuild<'a> = [(&'a Package, Vec<(&'a Target, &'a Profile)>)];
-
 /// A glorified callback for executing calls to rustc. Rather than calling rustc
 /// directly, we'll use an Executor, giving clients an opportunity to intercept
 /// the build calls.