| ... | ... | @@ -76,8 +76,9 @@ use_latest_commit: bool, |
| 76 | 76 | /// Relative to the build root of the root package. |
| 77 | 77 | package_root: Cache.Path, |
| 78 | 78 | error_bundle: ErrorBundle.Wip, |
| 79 | | manifest: ?Manifest, |
| 79 | manifest: Manifest, |
| 80 | 80 | manifest_ast: std.zig.Ast, |
| 81 | have_manifest: bool, |
| 81 | 82 | computed_hash: ComputedHash, |
| 82 | 83 | /// Fetch logic notices whether a package has a build.zig file and sets this flag. |
| 83 | 84 | has_build_zig: bool, |
| ... | ... | @@ -282,7 +283,8 @@ pub const JobQueue = struct { |
| 282 | 283 | , .{std.zig.fmtString(hash_slice)}); |
| 283 | 284 | } |
| 284 | 285 | |
| 285 | | if (fetch.manifest) |*manifest| { |
| 286 | if (fetch.have_manifest) { |
| 287 | const manifest = &fetch.manifest; |
| 286 | 288 | try buf.appendSlice( |
| 287 | 289 | \\ pub const deps: []const struct { []const u8, []const u8 } = &.{ |
| 288 | 290 | \\ |
| ... | ... | @@ -317,7 +319,8 @@ pub const JobQueue = struct { |
| 317 | 319 | ); |
| 318 | 320 | |
| 319 | 321 | const root_fetch = jq.all_fetches.items[0]; |
| 320 | | const root_manifest = &root_fetch.manifest.?; |
| 322 | assert(root_fetch.have_manifest); |
| 323 | const root_manifest = &root_fetch.manifest; |
| 321 | 324 | |
| 322 | 325 | for (root_manifest.dependencies.keys(), root_manifest.dependencies.values()) |name, dep| { |
| 323 | 326 | const h = depDigest(root_fetch.package_root, jq.global_cache, dep) orelse continue; |
| ... | ... | @@ -716,7 +719,7 @@ fn runResource( |
| 716 | 719 | try loadManifest(f, pkg_path); |
| 717 | 720 | |
| 718 | 721 | const filter: Filter = .{ |
| 719 | | .include_paths = if (f.manifest) |m| m.paths else .{}, |
| 722 | .include_paths = if (f.have_manifest) f.manifest.paths else .{}, |
| 720 | 723 | }; |
| 721 | 724 | |
| 722 | 725 | // Ignore errors that were excluded by manifest, such as failure to |
| ... | ... | @@ -809,7 +812,8 @@ fn runResource( |
| 809 | 812 | |
| 810 | 813 | pub fn computedPackageHash(f: *const Fetch) Package.Hash { |
| 811 | 814 | const saturated_size = std.math.cast(u32, f.computed_hash.total_size) orelse std.math.maxInt(u32); |
| 812 | | if (f.manifest) |man| { |
| 815 | if (f.have_manifest) { |
| 816 | const man = &f.manifest; |
| 813 | 817 | var version_buffer: [32]u8 = undefined; |
| 814 | 818 | const version: []const u8 = std.fmt.bufPrint(&version_buffer, "{f}", .{man.version}) catch &version_buffer; |
| 815 | 819 | return .init(f.computed_hash.digest, man.name, version, man.id, saturated_size); |
| ... | ... | @@ -846,15 +850,13 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { |
| 846 | 850 | const arena = f.arena.allocator(); |
| 847 | 851 | const manifest_path = try pkg_root.join(arena, Manifest.basename); |
| 848 | 852 | |
| 849 | | f.manifest = @as(Manifest, undefined); |
| 850 | | |
| 851 | 853 | Manifest.load( |
| 852 | 854 | io, |
| 853 | 855 | arena, |
| 854 | 856 | manifest_path, |
| 855 | 857 | &f.manifest_ast, |
| 856 | 858 | eb, |
| 857 | | &f.manifest.?, |
| 859 | &f.manifest, |
| 858 | 860 | f.allow_missing_paths_field, |
| 859 | 861 | ) catch |err| switch (err) { |
| 860 | 862 | error.FileNotFound => return, |
| ... | ... | @@ -867,6 +869,7 @@ fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { |
| 867 | 869 | return error.FetchFailed; |
| 868 | 870 | }, |
| 869 | 871 | }; |
| 872 | f.have_manifest = true; |
| 870 | 873 | } |
| 871 | 874 | |
| 872 | 875 | fn queueJobsForDeps(f: *Fetch) RunError!void { |
| ... | ... | @@ -875,7 +878,8 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 875 | 878 | assert(f.job_queue.recursive); |
| 876 | 879 | |
| 877 | 880 | // If the package does not have a build.zig.zon file then there are no dependencies. |
| 878 | | const manifest = f.manifest orelse return; |
| 881 | if (!f.have_manifest) return; |
| 882 | const manifest = &f.manifest; |
| 879 | 883 | |
| 880 | 884 | const new_fetches, const prog_names = nf: { |
| 881 | 885 | const parent_arena = f.arena.allocator(); |
| ... | ... | @@ -980,8 +984,9 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 980 | 984 | |
| 981 | 985 | .package_root = undefined, |
| 982 | 986 | .error_bundle = undefined, |
| 983 | | .manifest = null, |
| 987 | .manifest = undefined, |
| 984 | 988 | .manifest_ast = undefined, |
| 989 | .have_manifest = false, |
| 985 | 990 | .computed_hash = undefined, |
| 986 | 991 | .has_build_zig = false, |
| 987 | 992 | .oom_flag = false, |
| ... | ... | @@ -1958,7 +1963,7 @@ const Filter = struct { |
| 1958 | 1963 | include_paths: std.StringArrayHashMapUnmanaged(void) = .empty, |
| 1959 | 1964 | |
| 1960 | 1965 | /// sub_path is relative to the package root. |
| 1961 | | pub fn includePath(self: Filter, sub_path: []const u8) bool { |
| 1966 | pub fn includePath(self: *const Filter, sub_path: []const u8) bool { |
| 1962 | 1967 | if (self.include_paths.count() == 0) return true; |
| 1963 | 1968 | if (self.include_paths.contains("")) return true; |
| 1964 | 1969 | if (self.include_paths.contains(".")) return true; |
| ... | ... | @@ -2349,8 +2354,9 @@ const TestFetchBuilder = struct { |
| 2349 | 2354 | |
| 2350 | 2355 | .package_root = undefined, |
| 2351 | 2356 | .error_bundle = undefined, |
| 2352 | | .manifest = null, |
| 2357 | .manifest = undefined, |
| 2353 | 2358 | .manifest_ast = undefined, |
| 2359 | .have_manifest = false, |
| 2354 | 2360 | .computed_hash = undefined, |
| 2355 | 2361 | .has_build_zig = false, |
| 2356 | 2362 | .oom_flag = false, |