This commit is contained in:
Eric Huss 2018-04-21 12:16:03 -07:00
parent accc9b2867
commit a4947c2b47
15 changed files with 132 additions and 142 deletions

View File

@ -7,8 +7,8 @@ use std::sync::Arc;
use lazycell::LazyCell; use lazycell::LazyCell;
use core::{TargetKind, Workspace};
use super::{Context, FileFlavor, Kind, Layout, Unit}; use super::{Context, FileFlavor, Kind, Layout, Unit};
use core::{TargetKind, Workspace};
use util::{self, CargoResult}; use util::{self, CargoResult};
#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)] #[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]

View File

@ -7,27 +7,27 @@ use std::sync::Arc;
use jobserver::Client; use jobserver::Client;
use core::{Package, PackageId, PackageSet, Resolve, Target};
use core::{Dependency, Workspace};
use core::profiles::{Profile, Profiles}; use core::profiles::{Profile, Profiles};
use core::{Dependency, Workspace};
use core::{Package, PackageId, PackageSet, Resolve, Target};
use ops::CompileMode; use ops::CompileMode;
use util::{internal, profile, Cfg, CfgExpr, Config};
use util::errors::{CargoResult, CargoResultExt}; use util::errors::{CargoResult, CargoResultExt};
use util::{internal, profile, Cfg, CfgExpr, Config};
use super::TargetConfig;
use super::custom_build::{self, BuildDeps, BuildScripts, BuildState}; use super::custom_build::{self, BuildDeps, BuildScripts, BuildState};
use super::fingerprint::Fingerprint; use super::fingerprint::Fingerprint;
use super::job_queue::JobQueue; use super::job_queue::JobQueue;
use super::layout::Layout; use super::layout::Layout;
use super::links::Links; use super::links::Links;
use super::TargetConfig;
use super::{BuildConfig, Compilation, Executor, Kind}; use super::{BuildConfig, Compilation, Executor, Kind};
mod unit_dependencies; mod unit_dependencies;
use self::unit_dependencies::build_unit_dependencies; use self::unit_dependencies::build_unit_dependencies;
mod compilation_files; mod compilation_files;
use self::compilation_files::{CompilationFiles, OutputFile};
pub use self::compilation_files::Metadata; pub use self::compilation_files::Metadata;
use self::compilation_files::{CompilationFiles, OutputFile};
mod target_info; mod target_info;
pub use self::target_info::{FileFlavor, TargetInfo}; pub use self::target_info::{FileFlavor, TargetInfo};

View File

@ -1,15 +1,15 @@
use std::collections::{BTreeSet, HashSet};
use std::collections::hash_map::{Entry, HashMap}; use std::collections::hash_map::{Entry, HashMap};
use std::collections::{BTreeSet, HashSet};
use std::fs; use std::fs;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str; use std::str;
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use core::PackageId; use core::PackageId;
use util::{Cfg, Freshness};
use util::errors::{CargoResult, CargoResultExt}; use util::errors::{CargoResult, CargoResultExt};
use util::{self, internal, paths, profile};
use util::machine_message; use util::machine_message;
use util::{self, internal, paths, profile};
use util::{Cfg, Freshness};
use super::job::Work; use super::job::Work;
use super::{fingerprint, Context, Kind, Unit}; use super::{fingerprint, Context, Kind, Unit};

View File

@ -5,19 +5,19 @@ use std::path::{Path, PathBuf};
use std::sync::{Arc, Mutex}; use std::sync::{Arc, Mutex};
use filetime::FileTime; use filetime::FileTime;
use serde::ser::{self, Serialize};
use serde::de::{self, Deserialize}; use serde::de::{self, Deserialize};
use serde::ser::{self, Serialize};
use serde_json; use serde_json;
use core::{Edition, Package, TargetKind}; use core::{Edition, Package, TargetKind};
use util; use util;
use util::{internal, profile, Dirty, Fresh, Freshness};
use util::errors::{CargoResult, CargoResultExt}; use util::errors::{CargoResult, CargoResultExt};
use util::paths; use util::paths;
use util::{internal, profile, Dirty, Fresh, Freshness};
use super::job::Work;
use super::context::{Context, FileFlavor, Unit}; use super::context::{Context, FileFlavor, Unit};
use super::custom_build::BuildDeps; use super::custom_build::BuildDeps;
use super::job::Work;
/// A tuple result of the `prepare_foo` functions in this module. /// A tuple result of the `prepare_foo` functions in this module.
/// ///
@ -353,14 +353,7 @@ impl hash::Hash for Fingerprint {
.. ..
} = *self; } = *self;
( (
rustc, rustc, features, target, path, profile, local, edition, rustflags,
features,
target,
path,
profile,
local,
edition,
rustflags,
).hash(h); ).hash(h);
h.write_usize(deps.len()); h.write_usize(deps.len());

View File

@ -1,5 +1,5 @@
use std::collections::HashSet;
use std::collections::hash_map::HashMap; use std::collections::hash_map::HashMap;
use std::collections::HashSet;
use std::fmt; use std::fmt;
use std::io; use std::io;
use std::mem; use std::mem;
@ -8,15 +8,15 @@ use std::sync::mpsc::{channel, Receiver, Sender};
use crossbeam::{self, Scope}; use crossbeam::{self, Scope};
use jobserver::{Acquired, HelperThread}; use jobserver::{Acquired, HelperThread};
use core::{PackageId, Target};
use core::profiles::Profile; use core::profiles::Profile;
use ops::CompileMode; use core::{PackageId, Target};
use util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
use util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
use handle_error; use handle_error;
use ops::CompileMode;
use util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
use util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
use super::{Context, Kind, Unit};
use super::job::Job; use super::job::Job;
use super::{Context, Kind, Unit};
/// A management structure of the entire dependency graph to compile. /// A management structure of the entire dependency graph to compile.
/// ///

View File

@ -9,14 +9,14 @@ use std::sync::Arc;
use same_file::is_same_file; use same_file::is_same_file;
use serde_json; use serde_json;
use core::{Feature, PackageId, Target};
use core::profiles::{Lto, Profile}; use core::profiles::{Lto, Profile};
use core::shell::ColorChoice; use core::shell::ColorChoice;
use core::{Feature, PackageId, Target};
use ops::CompileMode; use ops::CompileMode;
use util::errors::{CargoResult, CargoResultExt, Internal};
use util::paths;
use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc}; use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc};
use util::{internal, join_paths, profile}; use util::{internal, join_paths, profile};
use util::paths;
use util::errors::{CargoResult, CargoResultExt, Internal};
use self::job::{Job, Work}; use self::job::{Job, Work};
use self::job_queue::JobQueue; use self::job_queue::JobQueue;
@ -631,10 +631,10 @@ fn hardlink_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
} }
let link_result = if src.is_dir() { let link_result = if src.is_dir() {
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(target_os = "redox")] #[cfg(target_os = "redox")]
use std::os::redox::fs::symlink; use std::os::redox::fs::symlink;
#[cfg(unix)]
use std::os::unix::fs::symlink;
#[cfg(windows)] #[cfg(windows)]
use std::os::windows::fs::symlink_dir as symlink; use std::os::windows::fs::symlink_dir as symlink;

View File

@ -1,11 +1,11 @@
use std::collections::{BTreeSet, HashSet}; use std::collections::{BTreeSet, HashSet};
use std::io::{BufWriter, Write};
use std::fs::File; use std::fs::File;
use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use super::{fingerprint, Context, Unit}; use super::{fingerprint, Context, Unit};
use util::{internal, CargoResult};
use util::paths; use util::paths;
use util::{internal, CargoResult};
fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> { fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> {
let path = path.as_ref(); let path = path.as_ref();

View File

@ -133,8 +133,12 @@ macro_rules! features {
} }
macro_rules! stab { macro_rules! stab {
(stable) => (Status::Stable); (stable) => {
(unstable) => (Status::Unstable); Status::Stable
};
(unstable) => {
Status::Unstable
};
} }
/// A listing of all features in Cargo /// A listing of all features in Cargo

View File

@ -1,21 +1,21 @@
use std::collections::{BTreeMap, HashMap}; use std::collections::{BTreeMap, HashMap};
use std::fmt; use std::fmt;
use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::rc::Rc; use std::rc::Rc;
use std::hash::{Hash, Hasher};
use semver::Version; use semver::Version;
use serde::ser; use serde::ser;
use toml; use toml;
use url::Url; use url::Url;
use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
use core::profiles::Profiles;
use core::{Edition, Feature, Features, WorkspaceConfig};
use core::interning::InternedString; use core::interning::InternedString;
use util::Config; use core::profiles::Profiles;
use util::toml::TomlManifest; use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
use core::{Edition, Feature, Features, WorkspaceConfig};
use util::errors::*; use util::errors::*;
use util::toml::TomlManifest;
use util::Config;
pub enum EitherManifest { pub enum EitherManifest {
Real(Manifest), Real(Manifest),

View File

@ -12,18 +12,18 @@ pub use self::source::{GitReference, Source, SourceId, SourceMap};
pub use self::summary::{FeatureMap, FeatureValue, Summary}; pub use self::summary::{FeatureMap, FeatureValue, Summary};
pub use self::workspace::{Members, Workspace, WorkspaceConfig, WorkspaceRootConfig}; pub use self::workspace::{Members, Workspace, WorkspaceConfig, WorkspaceRootConfig};
pub mod source; pub mod compiler;
pub mod dependency;
mod features;
mod interning;
pub mod manifest;
pub mod package; pub mod package;
pub mod package_id; pub mod package_id;
pub mod dependency;
pub mod manifest;
pub mod resolver;
pub mod summary;
pub mod shell;
pub mod registry;
pub mod compiler;
pub mod profiles;
mod interning;
mod package_id_spec; mod package_id_spec;
pub mod profiles;
pub mod registry;
pub mod resolver;
pub mod shell;
pub mod source;
pub mod summary;
mod workspace; mod workspace;
mod features;

View File

@ -1,12 +1,12 @@
use std::{cmp, fmt, hash};
use std::collections::HashSet; use std::collections::HashSet;
use std::{cmp, fmt, hash};
use core::Shell;
use core::interning::InternedString; use core::interning::InternedString;
use core::Shell;
use ops::CompileMode; use ops::CompileMode;
use util::CargoResult;
use util::lev_distance::lev_distance; use util::lev_distance::lev_distance;
use util::toml::{StringOrBool, TomlProfile, U32OrBool}; use util::toml::{StringOrBool, TomlProfile, U32OrBool};
use util::CargoResult;
/// Collection of all user profiles. /// Collection of all user profiles.
#[derive(Clone, Debug)] #[derive(Clone, Debug)]

View File

@ -1,16 +1,16 @@
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::BTreeMap;
use std::collections::hash_map::{Entry, HashMap}; use std::collections::hash_map::{Entry, HashMap};
use std::collections::BTreeMap;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::slice; use std::slice;
use glob::glob; use glob::glob;
use url::Url; use url::Url;
use core::profiles::Profiles;
use core::registry::PackageRegistry; use core::registry::PackageRegistry;
use core::{Dependency, PackageIdSpec}; use core::{Dependency, PackageIdSpec};
use core::{EitherManifest, Package, SourceId, VirtualManifest}; use core::{EitherManifest, Package, SourceId, VirtualManifest};
use core::profiles::Profiles;
use ops; use ops;
use sources::PathSource; use sources::PathSource;
use util::errors::{CargoResult, CargoResultExt}; use util::errors::{CargoResult, CargoResultExt};

View File

@ -1,13 +1,13 @@
use std::fs; use std::fs;
use std::path::Path; use std::path::Path;
use core::Workspace;
use core::compiler::{BuildConfig, Context, Kind, Unit}; use core::compiler::{BuildConfig, Context, Kind, Unit};
use core::profiles::ProfileFor; use core::profiles::ProfileFor;
use util::Config; use core::Workspace;
use ops::{self, CompileMode};
use util::errors::{CargoResult, CargoResultExt}; use util::errors::{CargoResult, CargoResultExt};
use util::paths; use util::paths;
use ops::{self, CompileMode}; use util::Config;
pub struct CleanOptions<'a> { pub struct CleanOptions<'a> {
pub config: &'a Config, pub config: &'a Config,

View File

@ -575,64 +575,68 @@ fn generate_targets<'a>(
let mut units = Vec::new(); let mut units = Vec::new();
// Helper for creating a Unit struct. // Helper for creating a Unit struct.
let new_unit = let new_unit = |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| {
|pkg: &'a Package, target: &'a Target, target_mode: CompileMode| { let profile_for = if mode.is_any_test() {
let profile_for = if mode.is_any_test() { // NOTE: The ProfileFor here is subtle. If you have a profile
// NOTE: The ProfileFor here is subtle. If you have a profile // with `panic` set, the `panic` flag is cleared for
// with `panic` set, the `panic` flag is cleared for // tests/benchmarks and their dependencies. If we left this
// tests/benchmarks and their dependencies. If we left this // as an "Any" profile, then the lib would get compiled three
// as an "Any" profile, then the lib would get compiled three // times (once with panic, once without, and once with
// times (once with panic, once without, and once with // --test).
// --test). //
// // This would cause a problem for Doc tests, which would fail
// This would cause a problem for Doc tests, which would fail // because `rustdoc` would attempt to link with both libraries
// because `rustdoc` would attempt to link with both libraries // at the same time. Also, it's probably not important (or
// at the same time. Also, it's probably not important (or // even desirable?) for rustdoc to link with a lib with
// even desirable?) for rustdoc to link with a lib with // `panic` set.
// `panic` set. //
// // As a consequence, Examples and Binaries get compiled
// As a consequence, Examples and Binaries get compiled // without `panic` set. This probably isn't a bad deal.
// without `panic` set. This probably isn't a bad deal. //
// // Forcing the lib to be compiled three times during `cargo
// Forcing the lib to be compiled three times during `cargo // test` is probably also not desirable.
// test` is probably also not desirable. ProfileFor::TestDependency
ProfileFor::TestDependency } else {
} else { ProfileFor::Any
ProfileFor::Any
};
let target_mode = match target_mode {
CompileMode::Test => {
if target.is_example() {
// Examples are included as regular binaries to verify
// that they compile.
CompileMode::Build
} else {
CompileMode::Test
}
}
CompileMode::Build => match *target.kind() {
TargetKind::Test => CompileMode::Test,
TargetKind::Bench => CompileMode::Bench,
_ => CompileMode::Build,
},
_ => target_mode,
};
// Plugins or proc-macro should be built for the host.
let kind = if target.for_host() {
Kind::Host
} else {
default_arch_kind
};
let profile =
profiles.get_profile(&pkg.name(), ws.is_member(pkg), profile_for, target_mode, release);
Unit {
pkg,
target,
profile,
kind,
mode: target_mode,
}
}; };
let target_mode = match target_mode {
CompileMode::Test => {
if target.is_example() {
// Examples are included as regular binaries to verify
// that they compile.
CompileMode::Build
} else {
CompileMode::Test
}
}
CompileMode::Build => match *target.kind() {
TargetKind::Test => CompileMode::Test,
TargetKind::Bench => CompileMode::Bench,
_ => CompileMode::Build,
},
_ => target_mode,
};
// Plugins or proc-macro should be built for the host.
let kind = if target.for_host() {
Kind::Host
} else {
default_arch_kind
};
let profile = profiles.get_profile(
&pkg.name(),
ws.is_member(pkg),
profile_for,
target_mode,
release,
);
Unit {
pkg,
target,
profile,
kind,
mode: target_mode,
}
};
for pkg in packages { for pkg in packages {
let features = resolve_all_features(resolve, pkg.package_id()); let features = resolve_all_features(resolve, pkg.package_id());
@ -650,21 +654,13 @@ fn generate_targets<'a>(
} => { } => {
let default_units = generate_default_targets(pkg.targets(), mode) let default_units = generate_default_targets(pkg.targets(), mode)
.iter() .iter()
.map(|t| { .map(|t| (new_unit(pkg, t, mode), !required_features_filterable))
(
new_unit(pkg, t, mode),
!required_features_filterable,
)
})
.collect::<Vec<_>>(); .collect::<Vec<_>>();
proposals.extend(default_units); proposals.extend(default_units);
if mode == CompileMode::Test { if mode == CompileMode::Test {
// Include the lib as it will be required for doctests. // Include the lib as it will be required for doctests.
if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) { if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) {
proposals.push(( proposals.push((new_unit(pkg, t, CompileMode::Build), false));
new_unit(pkg, t, CompileMode::Build),
false,
));
} }
} }
} }
@ -713,23 +709,17 @@ fn generate_targets<'a>(
.chain( .chain(
list_rule_targets(pkg, examples, "example", Target::is_example)? list_rule_targets(pkg, examples, "example", Target::is_example)?
.into_iter() .into_iter()
.map(|(t, required)| { .map(|(t, required)| (new_unit(pkg, t, mode), required)),
(new_unit(pkg, t, mode), required)
}),
) )
.chain( .chain(
list_rule_targets(pkg, tests, "test", test_filter)? list_rule_targets(pkg, tests, "test", test_filter)?
.into_iter() .into_iter()
.map(|(t, required)| { .map(|(t, required)| (new_unit(pkg, t, test_mode), required)),
(new_unit(pkg, t, test_mode), required)
}),
) )
.chain( .chain(
list_rule_targets(pkg, benches, "bench", bench_filter)? list_rule_targets(pkg, benches, "bench", bench_filter)?
.into_iter() .into_iter()
.map(|(t, required)| { .map(|(t, required)| (new_unit(pkg, t, bench_mode), required)),
(new_unit(pkg, t, bench_mode), required)
}),
) )
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
); );
@ -800,7 +790,10 @@ fn resolve_all_features(
fn generate_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target> { fn generate_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target> {
match mode { match mode {
CompileMode::Bench => targets.iter().filter(|t| t.benched()).collect(), CompileMode::Bench => targets.iter().filter(|t| t.benched()).collect(),
CompileMode::Test => targets.iter().filter(|t| t.tested() || t.is_example()).collect(), CompileMode::Test => targets
.iter()
.filter(|t| t.tested() || t.is_example())
.collect(),
CompileMode::Build | CompileMode::Check { .. } => targets CompileMode::Build | CompileMode::Check { .. } => targets
.iter() .iter()
.filter(|t| t.is_bin() || t.is_lib()) .filter(|t| t.is_bin() || t.is_lib())

View File

@ -6,22 +6,22 @@ use std::rc::Rc;
use std::str; use std::str;
use semver::{self, VersionReq}; use semver::{self, VersionReq};
use serde::ser;
use serde::de::{self, Deserialize}; use serde::de::{self, Deserialize};
use serde::ser;
use serde_ignored; use serde_ignored;
use toml; use toml;
use url::Url; use url::Url;
use core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, WorkspaceRootConfig};
use core::{Dependency, Manifest, PackageId, Summary, Target};
use core::{Edition, EitherManifest, Feature, Features, VirtualManifest};
use core::dependency::{Kind, Platform}; use core::dependency::{Kind, Platform};
use core::manifest::{LibKind, ManifestMetadata}; use core::manifest::{LibKind, ManifestMetadata};
use core::profiles::Profiles; use core::profiles::Profiles;
use core::{Dependency, Manifest, PackageId, Summary, Target};
use core::{Edition, EitherManifest, Feature, Features, VirtualManifest};
use core::{GitReference, PackageIdSpec, SourceId, WorkspaceConfig, WorkspaceRootConfig};
use sources::CRATES_IO; use sources::CRATES_IO;
use util::errors::{CargoError, CargoResult, CargoResultExt};
use util::paths; use util::paths;
use util::{self, Config, ToUrl}; use util::{self, Config, ToUrl};
use util::errors::{CargoError, CargoResult, CargoResultExt};
mod targets; mod targets;
use self::targets::targets; use self::targets::targets;