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

Apply new fingerprinting to build dir outputs #3310

Merged
merged 2 commits into from
Dec 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 7 additions & 20 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use rustc_serialize::{Encoder, Encodable};

use core::{Dependency, PackageId, Summary, SourceId, PackageIdSpec};
use core::WorkspaceConfig;
use core::package_id::Metadata;

pub enum EitherManifest {
Real(Manifest),
Expand Down Expand Up @@ -159,7 +158,6 @@ pub struct Target {
kind: TargetKind,
name: String,
src_path: PathBuf,
metadata: Option<Metadata>,
tested: bool,
benched: bool,
doc: bool,
Expand Down Expand Up @@ -279,7 +277,6 @@ impl Target {
kind: TargetKind::Bin,
name: String::new(),
src_path: PathBuf::new(),
metadata: None,
doc: false,
doctest: false,
harness: true,
Expand All @@ -289,40 +286,35 @@ impl Target {
}
}

pub fn lib_target(name: &str, crate_targets: Vec<LibKind>,
src_path: &Path,
metadata: Metadata) -> Target {
pub fn lib_target(name: &str,
crate_targets: Vec<LibKind>,
src_path: &Path) -> Target {
Target {
kind: TargetKind::Lib(crate_targets),
name: name.to_string(),
src_path: src_path.to_path_buf(),
metadata: Some(metadata),
doctest: true,
doc: true,
..Target::blank()
}
}

pub fn bin_target(name: &str, src_path: &Path,
metadata: Option<Metadata>) -> Target {
pub fn bin_target(name: &str, src_path: &Path) -> Target {
Target {
kind: TargetKind::Bin,
name: name.to_string(),
src_path: src_path.to_path_buf(),
metadata: metadata,
doc: true,
..Target::blank()
}
}

/// Builds a `Target` corresponding to the `build = "build.rs"` entry.
pub fn custom_build_target(name: &str, src_path: &Path,
metadata: Option<Metadata>) -> Target {
pub fn custom_build_target(name: &str, src_path: &Path) -> Target {
Target {
kind: TargetKind::CustomBuild,
name: name.to_string(),
src_path: src_path.to_path_buf(),
metadata: metadata,
for_host: true,
benched: false,
tested: false,
Expand All @@ -340,25 +332,21 @@ impl Target {
}
}

pub fn test_target(name: &str, src_path: &Path,
metadata: Metadata) -> Target {
pub fn test_target(name: &str, src_path: &Path) -> Target {
Target {
kind: TargetKind::Test,
name: name.to_string(),
src_path: src_path.to_path_buf(),
metadata: Some(metadata),
benched: false,
..Target::blank()
}
}

pub fn bench_target(name: &str, src_path: &Path,
metadata: Metadata) -> Target {
pub fn bench_target(name: &str, src_path: &Path) -> Target {
Target {
kind: TargetKind::Bench,
name: name.to_string(),
src_path: src_path.to_path_buf(),
metadata: Some(metadata),
tested: false,
..Target::blank()
}
Expand All @@ -367,7 +355,6 @@ impl Target {
pub fn name(&self) -> &str { &self.name }
pub fn crate_name(&self) -> String { self.name.replace("-", "_") }
pub fn src_path(&self) -> &Path { &self.src_path }
pub fn metadata(&self) -> Option<&Metadata> { self.metadata.as_ref() }
pub fn kind(&self) -> &TargetKind { &self.kind }
pub fn tested(&self) -> bool { self.tested }
pub fn harness(&self) -> bool { self.harness }
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ pub use self::dependency::{Dependency, DependencyInner};
pub use self::manifest::{Manifest, Target, TargetKind, Profile, LibKind, Profiles};
pub use self::manifest::{EitherManifest, VirtualManifest};
pub use self::package::{Package, PackageSet};
pub use self::package_id::{PackageId, Metadata};
pub use self::package_id::PackageId;
pub use self::package_id_spec::PackageIdSpec;
pub use self::registry::Registry;
pub use self::resolver::Resolve;
Expand Down
6 changes: 1 addition & 5 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::path::{Path, PathBuf};
use semver::Version;

use core::{Dependency, Manifest, PackageId, SourceId, Target, TargetKind};
use core::{Summary, Metadata, SourceMap};
use core::{Summary, SourceMap};
use ops;
use util::{CargoResult, Config, LazyCell, ChainError, internal, human, lev_distance};
use rustc_serialize::{Encoder,Encodable};
Expand Down Expand Up @@ -94,10 +94,6 @@ impl Package {
self.targets().iter().any(|t| t.is_custom_build())
}

pub fn generate_metadata(&self) -> Metadata {
self.package_id().generate_metadata()
}

pub fn find_closest_target(&self, target: &str, kind: TargetKind) -> Option<&Target> {
let targets = self.targets();

Expand Down
23 changes: 1 addition & 22 deletions src/cargo/core/package_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use regex::Regex;
use rustc_serialize::{Encodable, Encoder, Decodable, Decoder};
use semver;

use util::{CargoResult, CargoError, short_hash, ToSemver};
use util::{CargoResult, CargoError, ToSemver};
use core::source::SourceId;

/// Identifier for a specific version of a package in a specific source.
Expand Down Expand Up @@ -118,12 +118,6 @@ impl From<PackageIdError> for Box<CargoError> {
fn from(t: PackageIdError) -> Box<CargoError> { Box::new(t) }
}

#[derive(PartialEq, Eq, Hash, Clone, RustcEncodable, Debug)]
pub struct Metadata {
pub metadata: String,
pub extra_filename: String
}

impl PackageId {
pub fn new<T: ToSemver>(name: &str, version: T,
sid: &SourceId) -> CargoResult<PackageId> {
Expand All @@ -141,13 +135,6 @@ impl PackageId {
pub fn version(&self) -> &semver::Version { &self.inner.version }
pub fn source_id(&self) -> &SourceId { &self.inner.source_id }

pub fn generate_metadata(&self) -> Metadata {
let metadata = short_hash(self);
let extra_filename = format!("-{}", metadata);

Metadata { metadata: metadata, extra_filename: extra_filename }
}

pub fn with_precise(&self, precise: Option<String>) -> PackageId {
PackageId {
inner: Arc::new(PackageIdInner {
Expand All @@ -169,14 +156,6 @@ impl PackageId {
}
}

impl Metadata {
pub fn mix<T: Hash>(&mut self, t: &T) {
let new_metadata = short_hash(&(&self.metadata, t));
self.extra_filename = format!("-{}", new_metadata);
self.metadata = new_metadata;
}
}

impl fmt::Display for PackageId {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "{} v{}", self.inner.name, self.inner.version)?;
Expand Down
14 changes: 10 additions & 4 deletions src/cargo/ops/cargo_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,17 @@ pub fn clean(ws: &Workspace, opts: &CleanOptions) -> CargoResult<()> {
cx.probe_target_info(&units)?;

for unit in units.iter() {
let layout = cx.layout(unit);
rm_rf(&layout.proxy().fingerprint(&unit.pkg))?;
rm_rf(&layout.build(&unit.pkg))?;
rm_rf(&cx.fingerprint_dir(unit))?;
if unit.target.is_custom_build() {
if unit.profile.run_custom_build {
rm_rf(&cx.build_script_out_dir(unit))?;
} else {
rm_rf(&cx.build_script_dir(unit))?;
}
continue
}

for (src, link_dst, _) in cx.target_filenames(&unit)? {
for (src, link_dst, _) in cx.target_filenames(unit)? {
rm_rf(&src)?;
if let Some(dst) = link_dst {
rm_rf(&dst)?;
Expand Down
Loading