Merge branch 'sysroot-reduced' into 'master'

Update sysroot when deps reduced

See merge request redox-os/redox!1861
This commit is contained in:
Jeremy Soller 2026-02-03 06:03:38 -07:00
commit 38d9a374f7
2 changed files with 53 additions and 8 deletions

View File

@ -222,12 +222,19 @@ pub fn build(
};
}
if !check_source && stage_pkgars.iter().all(|file| file.is_file()) {
if cli_verbose {
log_to_pty!(logger, "DEBUG: using cached build, not checking source");
if !check_source {
let stage_present = if cook_config.clean_target {
stage_pkgars.iter().all(|file| file.is_file())
} else {
stage_dirs.iter().all(|file| file.is_dir())
};
if stage_present {
if cli_verbose {
log_to_pty!(logger, "DEBUG: using cached build, not checking source");
}
let auto_deps = make_auto_deps!()?;
return Ok((stage_dirs, auto_deps));
}
let auto_deps = make_auto_deps!()?;
return Ok((stage_dirs, auto_deps));
}
let mut source_modified = modified_dir_ignore_git(source_dir).unwrap_or(SystemTime::UNIX_EPOCH);
@ -518,9 +525,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)?;

View File

@ -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!(