Save source metadata to cache file. Args: build_dir: Meson build directory src_hash: Hash of source file metadata metadata: Source metadata output from discovery script
(build_dir: Path, src_hash: str, metadata: str)
| 115 | |
| 116 | |
| 117 | def save_cache(build_dir: Path, src_hash: str, metadata: str) -> None: |
| 118 | """ |
| 119 | Save source metadata to cache file. |
| 120 | |
| 121 | Args: |
| 122 | build_dir: Meson build directory |
| 123 | src_hash: Hash of source file metadata |
| 124 | metadata: Source metadata output from discovery script |
| 125 | """ |
| 126 | import time |
| 127 | |
| 128 | cache_file = build_dir / CACHE_FILENAME |
| 129 | build_dir.mkdir(parents=True, exist_ok=True) |
| 130 | |
| 131 | cache = { |
| 132 | "version": CACHE_VERSION, |
| 133 | "hash": src_hash, |
| 134 | "timestamp": time.time(), |
| 135 | "metadata": metadata, |
| 136 | } |
| 137 | |
| 138 | with open(cache_file, "w", encoding="utf-8") as f: |
| 139 | json.dump(cache, f, indent=2) |
| 140 | |
| 141 | |
| 142 | def main(argv: list[str] | None = None) -> None: |