use lazycell::LazyCell;
-use core::{TargetKind, Workspace};
use super::{Context, FileFlavor, Kind, Layout, Unit};
+use core::{TargetKind, Workspace};
use util::{self, CargoResult};
#[derive(Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
use jobserver::Client;
-use core::{Package, PackageId, PackageSet, Resolve, Target};
-use core::{Dependency, Workspace};
use core::profiles::{Profile, Profiles};
+use core::{Dependency, Workspace};
+use core::{Package, PackageId, PackageSet, Resolve, Target};
use ops::CompileMode;
-use util::{internal, profile, Cfg, CfgExpr, Config};
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::fingerprint::Fingerprint;
use super::job_queue::JobQueue;
use super::layout::Layout;
use super::links::Links;
+use super::TargetConfig;
use super::{BuildConfig, Compilation, Executor, Kind};
mod unit_dependencies;
use self::unit_dependencies::build_unit_dependencies;
mod compilation_files;
-use self::compilation_files::{CompilationFiles, OutputFile};
pub use self::compilation_files::Metadata;
+use self::compilation_files::{CompilationFiles, OutputFile};
mod target_info;
pub use self::target_info::{FileFlavor, TargetInfo};
-use std::collections::{BTreeSet, HashSet};
use std::collections::hash_map::{Entry, HashMap};
+use std::collections::{BTreeSet, HashSet};
use std::fs;
use std::path::{Path, PathBuf};
use std::str;
use std::sync::{Arc, Mutex};
use core::PackageId;
-use util::{Cfg, Freshness};
use util::errors::{CargoResult, CargoResultExt};
-use util::{self, internal, paths, profile};
use util::machine_message;
+use util::{self, internal, paths, profile};
+use util::{Cfg, Freshness};
use super::job::Work;
use super::{fingerprint, Context, Kind, Unit};
use std::sync::{Arc, Mutex};
use filetime::FileTime;
-use serde::ser::{self, Serialize};
use serde::de::{self, Deserialize};
+use serde::ser::{self, Serialize};
use serde_json;
use core::{Edition, Package, TargetKind};
use util;
-use util::{internal, profile, Dirty, Fresh, Freshness};
use util::errors::{CargoResult, CargoResultExt};
use util::paths;
+use util::{internal, profile, Dirty, Fresh, Freshness};
-use super::job::Work;
use super::context::{Context, FileFlavor, Unit};
use super::custom_build::BuildDeps;
+use super::job::Work;
/// A tuple result of the `prepare_foo` functions in this module.
///
..
} = *self;
(
- rustc,
- features,
- target,
- path,
- profile,
- local,
- edition,
- rustflags,
+ rustc, features, target, path, profile, local, edition, rustflags,
).hash(h);
h.write_usize(deps.len());
-use std::collections::HashSet;
use std::collections::hash_map::HashMap;
+use std::collections::HashSet;
use std::fmt;
use std::io;
use std::mem;
use crossbeam::{self, Scope};
use jobserver::{Acquired, HelperThread};
-use core::{PackageId, Target};
use core::profiles::Profile;
+use core::{PackageId, Target};
+use handle_error;
use ops::CompileMode;
-use util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
use util::{internal, profile, CargoResult, CargoResultExt, ProcessBuilder};
-use handle_error;
+use util::{Config, DependencyQueue, Dirty, Fresh, Freshness};
-use super::{Context, Kind, Unit};
use super::job::Job;
+use super::{Context, Kind, Unit};
/// A management structure of the entire dependency graph to compile.
///
use same_file::is_same_file;
use serde_json;
-use core::{Feature, PackageId, Target};
use core::profiles::{Lto, Profile};
use core::shell::ColorChoice;
+use core::{Feature, PackageId, Target};
use ops::CompileMode;
+use util::errors::{CargoResult, CargoResultExt, Internal};
+use util::paths;
use util::{self, machine_message, Config, Freshness, ProcessBuilder, Rustc};
use util::{internal, join_paths, profile};
-use util::paths;
-use util::errors::{CargoResult, CargoResultExt, Internal};
use self::job::{Job, Work};
use self::job_queue::JobQueue;
}
let link_result = if src.is_dir() {
- #[cfg(unix)]
- use std::os::unix::fs::symlink;
#[cfg(target_os = "redox")]
use std::os::redox::fs::symlink;
+ #[cfg(unix)]
+ use std::os::unix::fs::symlink;
#[cfg(windows)]
use std::os::windows::fs::symlink_dir as symlink;
use std::collections::{BTreeSet, HashSet};
-use std::io::{BufWriter, Write};
use std::fs::File;
+use std::io::{BufWriter, Write};
use std::path::{Path, PathBuf};
use super::{fingerprint, Context, Unit};
-use util::{internal, CargoResult};
use util::paths;
+use util::{internal, CargoResult};
fn render_filename<P: AsRef<Path>>(path: P, basedir: Option<&str>) -> CargoResult<String> {
let path = path.as_ref();
}
macro_rules! stab {
- (stable) => (Status::Stable);
- (unstable) => (Status::Unstable);
+ (stable) => {
+ Status::Stable
+ };
+ (unstable) => {
+ Status::Unstable
+ };
}
/// A listing of all features in Cargo
use std::collections::{BTreeMap, HashMap};
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::path::{Path, PathBuf};
use std::rc::Rc;
-use std::hash::{Hash, Hasher};
use semver::Version;
use serde::ser;
use toml;
use url::Url;
-use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
+use core::interning::InternedString;
use core::profiles::Profiles;
+use core::{Dependency, PackageId, PackageIdSpec, SourceId, Summary};
use core::{Edition, Feature, Features, WorkspaceConfig};
-use core::interning::InternedString;
-use util::Config;
-use util::toml::TomlManifest;
use util::errors::*;
+use util::toml::TomlManifest;
+use util::Config;
pub enum EitherManifest {
Real(Manifest),
pub use self::summary::{FeatureMap, FeatureValue, Summary};
pub use self::workspace::{Members, Workspace, WorkspaceConfig, WorkspaceRootConfig};
-pub mod source;
-pub mod package;
-pub mod package_id;
+pub mod compiler;
pub mod dependency;
+mod features;
+mod interning;
pub mod manifest;
+pub mod package;
+pub mod package_id;
+mod package_id_spec;
+pub mod profiles;
+pub mod registry;
pub mod resolver;
-pub mod summary;
pub mod shell;
-pub mod registry;
-pub mod compiler;
-pub mod profiles;
-mod interning;
-mod package_id_spec;
+pub mod source;
+pub mod summary;
mod workspace;
-mod features;
-use std::{cmp, fmt, hash};
use std::collections::HashSet;
+use std::{cmp, fmt, hash};
-use core::Shell;
use core::interning::InternedString;
+use core::Shell;
use ops::CompileMode;
-use util::CargoResult;
use util::lev_distance::lev_distance;
use util::toml::{StringOrBool, TomlProfile, U32OrBool};
+use util::CargoResult;
/// Collection of all user profiles.
#[derive(Clone, Debug)]
use std::cell::RefCell;
-use std::collections::BTreeMap;
use std::collections::hash_map::{Entry, HashMap};
+use std::collections::BTreeMap;
use std::path::{Path, PathBuf};
use std::slice;
use glob::glob;
use url::Url;
+use core::profiles::Profiles;
use core::registry::PackageRegistry;
use core::{Dependency, PackageIdSpec};
use core::{EitherManifest, Package, SourceId, VirtualManifest};
-use core::profiles::Profiles;
use ops;
use sources::PathSource;
use util::errors::{CargoResult, CargoResultExt};
use std::fs;
use std::path::Path;
-use core::Workspace;
use core::compiler::{BuildConfig, Context, Kind, Unit};
use core::profiles::ProfileFor;
-use util::Config;
+use core::Workspace;
+use ops::{self, CompileMode};
use util::errors::{CargoResult, CargoResultExt};
use util::paths;
-use ops::{self, CompileMode};
+use util::Config;
pub struct CleanOptions<'a> {
pub config: &'a Config,
let mut units = Vec::new();
// Helper for creating a Unit struct.
- let new_unit =
- |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| {
- let profile_for = if mode.is_any_test() {
- // NOTE: The ProfileFor here is subtle. If you have a profile
- // with `panic` set, the `panic` flag is cleared for
- // tests/benchmarks and their dependencies. If we left this
- // as an "Any" profile, then the lib would get compiled three
- // times (once with panic, once without, and once with
- // --test).
- //
- // This would cause a problem for Doc tests, which would fail
- // because `rustdoc` would attempt to link with both libraries
- // at the same time. Also, it's probably not important (or
- // even desirable?) for rustdoc to link with a lib with
- // `panic` set.
- //
- // As a consequence, Examples and Binaries get compiled
- // without `panic` set. This probably isn't a bad deal.
- //
- // Forcing the lib to be compiled three times during `cargo
- // test` is probably also not desirable.
- ProfileFor::TestDependency
- } else {
- 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
- }
+ let new_unit = |pkg: &'a Package, target: &'a Target, target_mode: CompileMode| {
+ let profile_for = if mode.is_any_test() {
+ // NOTE: The ProfileFor here is subtle. If you have a profile
+ // with `panic` set, the `panic` flag is cleared for
+ // tests/benchmarks and their dependencies. If we left this
+ // as an "Any" profile, then the lib would get compiled three
+ // times (once with panic, once without, and once with
+ // --test).
+ //
+ // This would cause a problem for Doc tests, which would fail
+ // because `rustdoc` would attempt to link with both libraries
+ // at the same time. Also, it's probably not important (or
+ // even desirable?) for rustdoc to link with a lib with
+ // `panic` set.
+ //
+ // As a consequence, Examples and Binaries get compiled
+ // without `panic` set. This probably isn't a bad deal.
+ //
+ // Forcing the lib to be compiled three times during `cargo
+ // test` is probably also not desirable.
+ ProfileFor::TestDependency
+ } else {
+ 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,
}
+ 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 {
let features = resolve_all_features(resolve, pkg.package_id());
} => {
let default_units = generate_default_targets(pkg.targets(), mode)
.iter()
- .map(|t| {
- (
- new_unit(pkg, t, mode),
- !required_features_filterable,
- )
- })
+ .map(|t| (new_unit(pkg, t, mode), !required_features_filterable))
.collect::<Vec<_>>();
proposals.extend(default_units);
if mode == CompileMode::Test {
// Include the lib as it will be required for doctests.
if let Some(t) = pkg.targets().iter().find(|t| t.is_lib() && t.doctested()) {
- proposals.push((
- new_unit(pkg, t, CompileMode::Build),
- false,
- ));
+ proposals.push((new_unit(pkg, t, CompileMode::Build), false));
}
}
}
.chain(
list_rule_targets(pkg, examples, "example", Target::is_example)?
.into_iter()
- .map(|(t, required)| {
- (new_unit(pkg, t, mode), required)
- }),
+ .map(|(t, required)| (new_unit(pkg, t, mode), required)),
)
.chain(
list_rule_targets(pkg, tests, "test", test_filter)?
.into_iter()
- .map(|(t, required)| {
- (new_unit(pkg, t, test_mode), required)
- }),
+ .map(|(t, required)| (new_unit(pkg, t, test_mode), required)),
)
.chain(
list_rule_targets(pkg, benches, "bench", bench_filter)?
.into_iter()
- .map(|(t, required)| {
- (new_unit(pkg, t, bench_mode), required)
- }),
+ .map(|(t, required)| (new_unit(pkg, t, bench_mode), required)),
)
.collect::<Vec<_>>(),
);
fn generate_default_targets(targets: &[Target], mode: CompileMode) -> Vec<&Target> {
match mode {
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
.iter()
.filter(|t| t.is_bin() || t.is_lib())
use std::str;
use semver::{self, VersionReq};
-use serde::ser;
use serde::de::{self, Deserialize};
+use serde::ser;
use serde_ignored;
use toml;
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::manifest::{LibKind, ManifestMetadata};
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 util::errors::{CargoError, CargoResult, CargoResultExt};
use util::paths;
use util::{self, Config, ToUrl};
-use util::errors::{CargoError, CargoResult, CargoResultExt};
mod targets;
use self::targets::targets;