Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
//! project's build directory, then hydrates these archives again; `--clean-all`
//! explicitly evicts this cache entry.

use std::path::{Path, PathBuf};
use std::path::Path;

use fbuild_core::BuildProfile;
use fbuild_core::path::NormalizedPath;
use sha2::{Digest, Sha256};
use walkdir::WalkDir;

const CACHE_VERSION: &str = "fbuild-esp32-framework-libraries-v1";

pub(super) struct FrameworkLibraryCache {
path: PathBuf,
path: NormalizedPath,
}

impl FrameworkLibraryCache {
Expand All @@ -27,7 +28,9 @@ impl FrameworkLibraryCache {
let path = fbuild_packages::Cache::new(project_dir)
.framework_library_artifacts_dir()
.join(key);
Self { path }
Self {
path: NormalizedPath::new(path),
}
}

#[cfg(test)]
Expand All @@ -42,7 +45,9 @@ impl FrameworkLibraryCache {
let path = fbuild_packages::Cache::with_cache_root(project_dir, cache_root)
.framework_library_artifacts_dir()
.join(key);
Self { path }
Self {
path: NormalizedPath::new(path),
}
}

pub(super) fn hydrate(&self, target_dir: &Path) -> std::io::Result<usize> {
Expand Down Expand Up @@ -97,7 +102,7 @@ impl FrameworkLibraryCache {
Ok(())
}

fn failure_path(&self, library_name: &str) -> PathBuf {
fn failure_path(&self, library_name: &str) -> NormalizedPath {
self.path.join("failed").join(library_name)
}
}
Expand Down Expand Up @@ -138,17 +143,17 @@ fn hash_tree(hasher: &mut Sha256, root: &Path, headers_only: bool) {
hasher.update(b"missing");
return;
}
let mut files: Vec<PathBuf> = WalkDir::new(root)
let mut files: Vec<NormalizedPath> = WalkDir::new(root)
.into_iter()
.flatten()
.filter(|entry| entry.file_type().is_file())
.map(|entry| entry.into_path())
.filter(|path| !headers_only || is_header(path))
.map(|entry| NormalizedPath::new(entry.into_path()))
.filter(|path| !headers_only || is_header(path.as_path()))
.collect();
files.sort();
for path in files {
let relative = path.strip_prefix(root).unwrap_or(&path);
hasher.update(relative.to_string_lossy().replace('\\', "/").as_bytes());
let relative = path.as_path().strip_prefix(root).unwrap_or(path.as_path());
hasher.update(NormalizedPath::new(relative).display_slash().as_bytes());
Comment thread
coderabbitai[bot] marked this conversation as resolved.
hasher.update([0]);
match std::fs::read(&path) {
Ok(bytes) => hasher.update(bytes),
Expand Down
Loading