CLI: implement 'zig build' lazy dependency fetching

This makes `zig build` notice when lazy dependencies were missing, fetch
them, and then rebuild the build runner and run it again.
This commit is contained in:
Andrew Kelley 2024-02-02 17:15:24 -07:00
parent 252f4ab2a5
commit d753c3a121
2 changed files with 531 additions and 495 deletions

View File

@ -106,8 +106,12 @@ pub const JobQueue = struct {
/// If this is true, `recursive` must be false.
debug_hash: bool,
work_around_btrfs_bug: bool,
/// Set of hashes that will be additionally fetched even if they are marked
/// as lazy.
unlazy_set: UnlazySet = .{},
pub const Table = std.AutoArrayHashMapUnmanaged(Manifest.MultiHashHexDigest, *Fetch);
pub const UnlazySet = std.AutoArrayHashMapUnmanaged(Manifest.MultiHashHexDigest, void);
pub fn deinit(jq: *JobQueue) void {
if (jq.all_fetches.items.len == 0) return;
@ -375,7 +379,7 @@ pub fn run(f: *Fetch) RunError!void {
error.FileNotFound => {
switch (f.lazy_status) {
.eager => {},
.available => {
.available => if (!f.job_queue.unlazy_set.contains(expected_hash)) {
f.lazy_status = .unavailable;
return;
},

File diff suppressed because it is too large Load Diff