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

Remove filetime dep from build_helper #49549

Merged
merged 1 commit into from
Apr 1, 2018
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
3 changes: 0 additions & 3 deletions src/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,7 @@ pub fn run_cargo(build: &Build, cargo: &mut Command, stamp: &Path, is_check: boo
let max = max.unwrap();
let max_path = max_path.unwrap();
if stamp_contents == new_contents && max <= stamp_mtime {
build.verbose(&format!("not updating {:?}; contents equal and {} <= {}",
build.verbose(&format!("not updating {:?}; contents equal and {:?} <= {:?}",
stamp, max, stamp_mtime));
return deps
}
Expand Down
3 changes: 0 additions & 3 deletions src/build_helper/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,3 @@ authors = ["The Rust Project Developers"]
[lib]
name = "build_helper"
path = "lib.rs"

[dependencies]
filetime = "0.1"
19 changes: 7 additions & 12 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,11 @@

#![deny(warnings)]

extern crate filetime;

use std::fs::File;
use std::path::{Path, PathBuf};
use std::process::{Command, Stdio};
use std::{fs, env};

use filetime::FileTime;
use std::time::{SystemTime, UNIX_EPOCH};

/// A helper macro to `unwrap` a result except also print out details like:
///
Expand Down Expand Up @@ -137,10 +134,8 @@ pub fn rerun_if_changed_anything_in_dir(dir: &Path) {
}

/// Returns the last-modified time for `path`, or zero if it doesn't exist.
pub fn mtime(path: &Path) -> FileTime {
fs::metadata(path).map(|f| {
FileTime::from_last_modification_time(&f)
}).unwrap_or(FileTime::zero())
pub fn mtime(path: &Path) -> SystemTime {
fs::metadata(path).and_then(|f| f.modified()).unwrap_or(UNIX_EPOCH)
}

/// Returns whether `dst` is up to date given that the file or files in `src`
Expand All @@ -157,9 +152,9 @@ pub fn up_to_date(src: &Path, dst: &Path) -> bool {
Err(e) => panic!("source {:?} failed to get metadata: {}", src, e),
};
if meta.is_dir() {
dir_up_to_date(src, &threshold)
dir_up_to_date(src, threshold)
} else {
FileTime::from_last_modification_time(&meta) <= threshold
meta.modified().unwrap_or(UNIX_EPOCH) <= threshold
}
}

Expand Down Expand Up @@ -226,13 +221,13 @@ pub fn sanitizer_lib_boilerplate(sanitizer_name: &str) -> Result<NativeLibBoiler
search_path)
}

fn dir_up_to_date(src: &Path, threshold: &FileTime) -> bool {
fn dir_up_to_date(src: &Path, threshold: SystemTime) -> bool {
t!(fs::read_dir(src)).map(|e| t!(e)).all(|e| {
let meta = t!(e.metadata());
if meta.is_dir() {
dir_up_to_date(&e.path(), threshold)
} else {
FileTime::from_last_modification_time(&meta) < *threshold
meta.modified().unwrap_or(UNIX_EPOCH) < threshold
}
})
}
Expand Down