MCPcopy Create free account
hub / github.com/FastLED/FastLED / compute_src_files_hash

Function compute_src_files_hash

ci/meson/src_metadata_cache.py:45–73  ·  view source on GitHub ↗

Compute a hash of all source file metadata (path + mtime + size). This provides a fast way to detect if any source files have been added, deleted, or modified without re-parsing all source files. Args: src_dir: Root directory containing source files pattern: File p

(src_dir: Path, pattern: str)

Source from the content-addressed store, hash-verified

43
44
45def compute_src_files_hash(src_dir: Path, pattern: str) -> str:
46 """
47 Compute a hash of all source file metadata (path + mtime + size).
48
49 This provides a fast way to detect if any source files have been added,
50 deleted, or modified without re-parsing all source files.
51
52 Args:
53 src_dir: Root directory containing source files
54 pattern: File pattern to match (default: "*.cpp")
55
56 Returns:
57 SHA256 hash of all source file metadata
58 """
59 # Find all files matching pattern recursively
60 source_files = sorted(src_dir.rglob(pattern))
61
62 # Create hash input from file metadata
63 hash_input: list[str] = []
64 for f in source_files:
65 if f.is_file():
66 stat: stat_result = f.stat()
67 rel_path: str = f.relative_to(src_dir).as_posix()
68 # Include path, mtime, and size in hash
69 hash_input.append(f"{rel_path}:{stat.st_mtime:.6f}:{stat.st_size}")
70
71 # Compute SHA256 hash
72 hash_str = "\n".join(hash_input)
73 return hashlib.sha256(hash_str.encode()).hexdigest()
74
75
76def load_cache(build_dir: Path) -> CacheEntry | None:

Callers 1

mainFunction · 0.85

Calls 1

appendMethod · 0.45

Tested by

no test coverage detected