mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Rollup merge of #127697 - onur-ozkan:use-std-filetimes, r=Kobzol
use std for file mtime and atime modifications Since 1.75 std provides an interface to set access and modified times on files. This change replaces the external dependency previously used for these operations with the corresponding std functions.
This commit is contained in:
commit
bef29c0a8f
@ -48,7 +48,6 @@ dependencies = [
|
||||
"clap_complete",
|
||||
"cmake",
|
||||
"fd-lock",
|
||||
"filetime",
|
||||
"home",
|
||||
"ignore",
|
||||
"junction",
|
||||
|
@ -44,7 +44,6 @@ build_helper = { path = "../tools/build_helper" }
|
||||
clap = { version = "4.4", default-features = false, features = ["std", "usage", "help", "derive", "error-context"] }
|
||||
clap_complete = "4.4"
|
||||
fd-lock = "4.0"
|
||||
filetime = "0.2"
|
||||
home = "0.5"
|
||||
ignore = "0.4"
|
||||
libc = "0.2"
|
||||
|
@ -33,7 +33,6 @@ use crate::utils::helpers::{
|
||||
};
|
||||
use crate::LLVM_TOOLS;
|
||||
use crate::{CLang, Compiler, DependencyType, GitRepo, Mode};
|
||||
use filetime::FileTime;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
pub struct Std {
|
||||
@ -2161,9 +2160,11 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
|
||||
return;
|
||||
}
|
||||
|
||||
let previous_mtime = FileTime::from_last_modification_time(&path.metadata().unwrap());
|
||||
let previous_mtime = t!(t!(path.metadata()).modified());
|
||||
command("strip").capture().arg("--strip-debug").arg(path).run(builder);
|
||||
|
||||
let file = t!(fs::File::open(path));
|
||||
|
||||
// After running `strip`, we have to set the file modification time to what it was before,
|
||||
// otherwise we risk Cargo invalidating its fingerprint and rebuilding the world next time
|
||||
// bootstrap is invoked.
|
||||
@ -2176,5 +2177,5 @@ pub fn strip_debug(builder: &Builder<'_>, target: TargetSelection, path: &Path)
|
||||
// In the second invocation of bootstrap, Cargo will see that the mtime of librustc_driver.so
|
||||
// is greater than the mtime of rustc-main, and will rebuild rustc-main. That will then cause
|
||||
// everything else (standard library, future stages...) to be rebuilt.
|
||||
t!(filetime::set_file_mtime(path, previous_mtime));
|
||||
t!(file.set_modified(previous_mtime));
|
||||
}
|
||||
|
@ -702,9 +702,13 @@ download-rustc = false
|
||||
// time `rustc_llvm` build script ran. However, the timestamps of the
|
||||
// files in the tarball are in the past, so it doesn't trigger a
|
||||
// rebuild.
|
||||
let now = filetime::FileTime::from_system_time(std::time::SystemTime::now());
|
||||
let now = std::time::SystemTime::now();
|
||||
let file_times = fs::FileTimes::new().set_accessed(now).set_modified(now);
|
||||
|
||||
let llvm_config = llvm_root.join("bin").join(exe("llvm-config", self.build));
|
||||
t!(filetime::set_file_times(llvm_config, now, now));
|
||||
let llvm_config_file = t!(File::open(llvm_config));
|
||||
|
||||
t!(llvm_config_file.set_times(file_times));
|
||||
|
||||
if self.should_fix_bins_and_dylibs() {
|
||||
let llvm_lib = llvm_root.join("lib");
|
||||
|
@ -30,7 +30,6 @@ use std::time::SystemTime;
|
||||
|
||||
use build_helper::ci::{gha, CiEnv};
|
||||
use build_helper::exit;
|
||||
use filetime::FileTime;
|
||||
use sha2::digest::Digest;
|
||||
use termcolor::{ColorChoice, StandardStream, WriteColor};
|
||||
use utils::channel::GitInfo;
|
||||
@ -1708,9 +1707,13 @@ Executed at: {executed_at}"#,
|
||||
panic!("failed to copy `{}` to `{}`: {}", src.display(), dst.display(), e)
|
||||
}
|
||||
t!(fs::set_permissions(dst, metadata.permissions()));
|
||||
let atime = FileTime::from_last_access_time(&metadata);
|
||||
let mtime = FileTime::from_last_modification_time(&metadata);
|
||||
t!(filetime::set_file_times(dst, atime, mtime));
|
||||
|
||||
let file_times = fs::FileTimes::new()
|
||||
.set_accessed(t!(metadata.accessed()))
|
||||
.set_modified(t!(metadata.modified()));
|
||||
|
||||
let dst_file = t!(fs::File::open(dst));
|
||||
t!(dst_file.set_times(file_times));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user