fix(cook): copy source only if newer

Fixes the bug where libgcc was unnecessarily building multiple times.
Which in turn caused other packages to rebuild.

Example: The source path is set to `prefix/${TARGET}/sysroot`. Currently
the way `cook` handles `source.path` ends up messing the timestamp of
`recipes/libs/libgcc/source` as it just performs `copy_dir_all(path,
&source_dir)` without checking if the timestamp of the source path
specified in the recipe was changed. This would consequently update the
timestamp of the source and cause it to rebuild.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
This commit is contained in:
Anhad Singh 2025-01-31 18:39:52 +11:00
parent 3d492f9ae3
commit eede787cbf
No known key found for this signature in database
GPG Key ID: 80E0357347554B89

View File

@ -228,14 +228,17 @@ fn fetch(recipe_dir: &Path, source: &Option<SourceRecipe>) -> Result<PathBuf, St
}
}
Some(SourceRecipe::Path { path }) => {
copy_dir_all(path, &source_dir).map_err(|e| {
format!(
"Couldn't copy source from {} to {}: {}",
path,
source_dir.display(),
e
)
})?;
if modified_dir(Path::new(path))? > modified_dir(&source_dir)? {
eprintln!("[DEBUG]: {} is newer than {}", path, source_dir.display());
copy_dir_all(path, &source_dir).map_err(|e| {
format!(
"Couldn't copy source from {} to {}: {}",
path,
source_dir.display(),
e
)
})?;
}
}
Some(SourceRecipe::Git {
git,