@@ -58,6 +58,12 @@ has_build_zig: bool,
58
58
/// Indicates whether the task aborted due to an out-of-memory condition.
59
59
oom_flag : bool ,
60
60
61
+ // This field is used by the CLI only, untouched by this file.
62
+
63
+ /// The module for this `Fetch` tasks's package, which exposes `build.zig` as
64
+ /// the root source file.
65
+ module : ? * Package.Module ,
66
+
61
67
/// Contains shared state among all `Fetch` tasks.
62
68
pub const JobQueue = struct {
63
69
mutex : std.Thread.Mutex = .{},
@@ -147,10 +153,10 @@ pub const JobQueue = struct {
147
153
\\
148
154
);
149
155
for (manifest .dependencies .keys (), manifest .dependencies .values ()) | name , dep | {
150
- const h = dep . hash orelse continue ;
156
+ const h = depDigest ( fetch . package_root , jq . global_cache , dep ) orelse continue ;
151
157
try buf .writer ().print (
152
158
" .{{ \" {}\" , \" {}\" }},\n " ,
153
- .{ std .zig .fmtEscapes (name ), std .zig .fmtEscapes (h ) },
159
+ .{ std .zig .fmtEscapes (name ), std .zig .fmtEscapes (& h ) },
154
160
);
155
161
}
156
162
@@ -179,10 +185,10 @@ pub const JobQueue = struct {
179
185
const root_manifest = & root_fetch .manifest .? ;
180
186
181
187
for (root_manifest .dependencies .keys (), root_manifest .dependencies .values ()) | name , dep | {
182
- const h = dep . hash orelse continue ;
188
+ const h = depDigest ( root_fetch . package_root , jq . global_cache , dep ) orelse continue ;
183
189
try buf .writer ().print (
184
190
" .{{ \" {}\" , \" {}\" }},\n " ,
185
- .{ std .zig .fmtEscapes (name ), std .zig .fmtEscapes (h ) },
191
+ .{ std .zig .fmtEscapes (name ), std .zig .fmtEscapes (& h ) },
186
192
);
187
193
}
188
194
try buf .appendSlice ("};\n " );
@@ -258,7 +264,7 @@ pub fn run(f: *Fetch) RunError!void {
258
264
}
259
265
f .package_root = pkg_root ;
260
266
try loadManifest (f , pkg_root );
261
- try checkBuildFileExistence (f );
267
+ if ( ! f . has_build_zig ) try checkBuildFileExistence (f );
262
268
if (! f .job_queue .recursive ) return ;
263
269
return queueJobsForDeps (f );
264
270
},
@@ -604,6 +610,8 @@ fn queueJobsForDeps(f: *Fetch) RunError!void {
604
610
.actual_hash = undefined ,
605
611
.has_build_zig = false ,
606
612
.oom_flag = false ,
613
+
614
+ .module = null ,
607
615
};
608
616
}
609
617
@@ -1400,6 +1408,25 @@ const Filter = struct {
1400
1408
}
1401
1409
};
1402
1410
1411
+ pub fn depDigest (
1412
+ pkg_root : Package.Path ,
1413
+ cache_root : Cache.Directory ,
1414
+ dep : Manifest.Dependency ,
1415
+ ) ? Manifest.MultiHashHexDigest {
1416
+ if (dep .hash ) | h | return h [0.. Manifest .multihash_hex_digest_len ].* ;
1417
+
1418
+ switch (dep .location ) {
1419
+ .url = > return null ,
1420
+ .path = > | rel_path | {
1421
+ var buf : [fs .MAX_PATH_BYTES ]u8 = undefined ;
1422
+ var fba = std .heap .FixedBufferAllocator .init (& buf );
1423
+ const new_root = pkg_root .resolvePosix (fba .allocator (), rel_path ) catch
1424
+ return null ;
1425
+ return relativePathDigest (new_root , cache_root );
1426
+ },
1427
+ }
1428
+ }
1429
+
1403
1430
// These are random bytes.
1404
1431
const package_hash_prefix_cached = [8 ]u8 { 0x53 , 0x7e , 0xfa , 0x94 , 0x65 , 0xe9 , 0xf8 , 0x73 };
1405
1432
const package_hash_prefix_project = [8 ]u8 { 0xe1 , 0x25 , 0xee , 0xfa , 0xa6 , 0x17 , 0x38 , 0xcc };
0 commit comments