From 6cf581e9392d83cccc49d28e6c7919b085a02f47 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 3 Feb 2026 17:41:30 +0700 Subject: [PATCH 1/2] Update sysroot when deps reduced --- src/cook/cook_build.rs | 17 ++++++++++++++--- src/cook/fs.rs | 27 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index 5468451a3..e6fdf524d 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -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)?; diff --git a/src/cook/fs.rs b/src/cook/fs.rs index a75c8bdab..3d81d77de 100644 --- a/src/cook/fs.rs +++ b/src/cook/fs.rs @@ -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 { }) } +pub fn check_files_present(dir: &Path, expected_files: &BTreeSet<&str>) -> Result { + 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!( From aa9a654ef6ff736377f09afd8e4ffdd4c8c64038 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 3 Feb 2026 17:42:26 +0700 Subject: [PATCH 2/2] Fix build failure due to changing clean target flag --- src/cook/cook_build.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/cook/cook_build.rs b/src/cook/cook_build.rs index e6fdf524d..8bc86f6c5 100644 --- a/src/cook/cook_build.rs +++ b/src/cook/cook_build.rs @@ -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);