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