mirror of
https://gitlab.redox-os.org/redox-os/redox.git
synced 2026-06-24 22:04:19 +08:00
Update sysroot when deps reduced
This commit is contained in:
parent
9004c052db
commit
6cf581e939
@ -518,9 +518,20 @@ fn build_deps_dir(
|
||||
let sysroot_modified = modified_dir(&tags_dir).unwrap_or(SystemTime::UNIX_EPOCH);
|
||||
if sysroot_modified < source_modified
|
||||
|| sysroot_modified < deps_modified
|
||||
|| dep_pkgars
|
||||
.iter()
|
||||
.any(|(pkg, _)| !tags_dir.join(pkg.as_str()).is_file())
|
||||
|| !check_files_present(
|
||||
&tags_dir,
|
||||
&dep_pkgars
|
||||
.iter()
|
||||
.map(|(name, _)| {
|
||||
// TODO: without_host should just return as_str
|
||||
if name.is_host() {
|
||||
&name.as_str()["host:".len()..]
|
||||
} else {
|
||||
name.as_str()
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
)?
|
||||
{
|
||||
log_to_pty!(logger, "DEBUG: updating '{}'", deps_dir.display());
|
||||
remove_all(deps_dir)?;
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
use serde::Serialize;
|
||||
use std::{
|
||||
collections::BTreeSet,
|
||||
fs,
|
||||
io::{self, Write},
|
||||
path::{Path, PathBuf},
|
||||
@ -189,6 +190,32 @@ pub fn modified_dir_ignore_git(dir: &Path) -> Result<SystemTime, String> {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn check_files_present(dir: &Path, expected_files: &BTreeSet<&str>) -> Result<bool, String> {
|
||||
let entries = fs::read_dir(dir)
|
||||
.map_err(|err| format!("failed to get list files of '{}': {:?}", dir.display(), err))?;
|
||||
|
||||
let mut matches = 0;
|
||||
for entry_res in entries {
|
||||
let entry = entry_res
|
||||
.map_err(|err| format!("failed to get file entry of '{}': {:?}", dir.display(), err))?;
|
||||
|
||||
let filename = entry.file_name();
|
||||
let Some(filename) = filename.to_str() else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if expected_files.contains(&filename) {
|
||||
matches += 1
|
||||
} else if filename.starts_with('.') {
|
||||
continue;
|
||||
} else {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(matches == expected_files.len())
|
||||
}
|
||||
|
||||
pub fn rename(src: &Path, dst: &Path) -> Result<(), String> {
|
||||
fs::rename(src, dst).map_err(|err| {
|
||||
format!(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user