| ... | ... | @@ -44,7 +44,8 @@ const log = std.log.scoped(.fetch); |
| 44 | 44 | const assert = std.debug.assert; |
| 45 | 45 | const ascii = std.ascii; |
| 46 | 46 | const Allocator = std.mem.Allocator; |
| 47 | | const Cache = std.Build.Cache; |
| 47 | const Path = std.Build.Cache.Path; |
| 48 | const Directory = std.Build.Cache.Directory; |
| 48 | 49 | const git = @import("Fetch/git.zig"); |
| 49 | 50 | const Package = @import("Package.zig"); |
| 50 | 51 | const Manifest = Package.Manifest; |
| ... | ... | @@ -58,8 +59,8 @@ name_tok: std.zig.Ast.TokenIndex, |
| 58 | 59 | lazy_status: LazyStatus, |
| 59 | 60 | /// Same as `parent_packge_root` except it is unchanged when recursing into |
| 60 | 61 | /// relative file paths (as opposed to URL). |
| 61 | | remote_package_root: Cache.Path, |
| 62 | | parent_package_root: Cache.Path, |
| 62 | remote_package_root: Path, |
| 63 | parent_package_root: Path, |
| 63 | 64 | parent_manifest_ast: ?*const std.zig.Ast, |
| 64 | 65 | prog_node: std.Progress.Node, |
| 65 | 66 | job_queue: *JobQueue, |
| ... | ... | @@ -77,7 +78,7 @@ use_latest_commit: bool, |
| 77 | 78 | // Below this are fields populated by `run`. |
| 78 | 79 | |
| 79 | 80 | /// Relative to the build root of the root package. |
| 80 | | package_root: Cache.Path, |
| 81 | package_root: Path, |
| 81 | 82 | error_bundle: ErrorBundle.Wip, |
| 82 | 83 | manifest: Manifest, |
| 83 | 84 | manifest_ast: std.zig.Ast, |
| ... | ... | @@ -111,9 +112,9 @@ pub const LazyStatus = enum { |
| 111 | 112 | }; |
| 112 | 113 | |
| 113 | 114 | pub const LocalStorage = struct { |
| 114 | | cache_root: Cache.Path, |
| 115 | cache_root: Path, |
| 115 | 116 | /// Path to "zig-pkg" inside the package in which the user ran `zig build`. |
| 116 | | pkg_root: Cache.Path, |
| 117 | pkg_root: Path, |
| 117 | 118 | }; |
| 118 | 119 | |
| 119 | 120 | /// Contains shared state among all `Fetch` tasks. |
| ... | ... | @@ -133,7 +134,7 @@ pub const JobQueue = struct { |
| 133 | 134 | http_client: *std.http.Client, |
| 134 | 135 | /// This tracks `Fetch` tasks as well as recompression tasks. |
| 135 | 136 | group: Io.Group = .init, |
| 136 | | global_cache: Cache.Directory, |
| 137 | global_cache: Directory, |
| 137 | 138 | /// If `null`, indicates fetch globally only. |
| 138 | 139 | local_storage: ?*const LocalStorage, |
| 139 | 140 | /// If true then, no fetching occurs, and: |
| ... | ... | @@ -170,7 +171,7 @@ pub const JobQueue = struct { |
| 170 | 171 | pub const ForkSet = std.array_hash_map.Custom(Fork, void, Fork.Context, false); |
| 171 | 172 | |
| 172 | 173 | pub const Fork = struct { |
| 173 | | path: Cache.Path, |
| 174 | path: Path, |
| 174 | 175 | manifest_ast: std.zig.Ast, |
| 175 | 176 | manifest: Package.Manifest, |
| 176 | 177 | uses: usize, |
| ... | ... | @@ -352,14 +353,14 @@ pub const JobQueue = struct { |
| 352 | 353 | ); |
| 353 | 354 | } |
| 354 | 355 | |
| 355 | | fn recompress(jq: *JobQueue, package_hash: Package.Hash, package_root: Cache.Path) Io.Cancelable!void { |
| 356 | fn recompress(jq: *JobQueue, package_hash: Package.Hash, package_root: Path) Io.Cancelable!void { |
| 356 | 357 | const pkg_hash_slice = package_hash.toSlice(); |
| 357 | 358 | |
| 358 | 359 | const prog_node = jq.prog_node.startFmt(0, "recompress {s}", .{pkg_hash_slice}); |
| 359 | 360 | defer prog_node.end(); |
| 360 | 361 | |
| 361 | 362 | var dest_sub_path_buf: ["p/".len + Package.Hash.max_len + ".tar.gz".len]u8 = undefined; |
| 362 | | const dest_path: Cache.Path = .{ |
| 363 | const dest_path: Path = .{ |
| 363 | 364 | .root_dir = jq.global_cache, |
| 364 | 365 | .sub_path = std.fmt.bufPrint(&dest_sub_path_buf, "p/{s}.tar.gz", .{pkg_hash_slice}) catch unreachable, |
| 365 | 366 | }; |
| ... | ... | @@ -381,9 +382,9 @@ pub const JobQueue = struct { |
| 381 | 382 | fn recompressFallible( |
| 382 | 383 | jq: *JobQueue, |
| 383 | 384 | arena: Allocator, |
| 384 | | dest_path: Cache.Path, |
| 385 | dest_path: Path, |
| 385 | 386 | pkg_hash_slice: []const u8, |
| 386 | | package_root: Cache.Path, |
| 387 | package_root: Path, |
| 387 | 388 | prog_node: std.Progress.Node, |
| 388 | 389 | ) !void { |
| 389 | 390 | const gpa = jq.http_client.allocator; |
| ... | ... | @@ -493,7 +494,7 @@ fn stringCmp(_: void, lhs: ScannedFile, rhs: ScannedFile) bool { |
| 493 | 494 | pub const Location = union(enum) { |
| 494 | 495 | remote: Remote, |
| 495 | 496 | /// A directory found inside the parent package. |
| 496 | | relative_path: Cache.Path, |
| 497 | relative_path: Path, |
| 497 | 498 | /// Recursive Fetch tasks will never use this Location, but it may be |
| 498 | 499 | /// passed in by the CLI. Indicates the file contents here should be copied |
| 499 | 500 | /// into the global package cache. It may be a file relative to the cwd or |
| ... | ... | @@ -641,7 +642,7 @@ pub fn run(f: *Fetch) RunError!void { |
| 641 | 642 | |
| 642 | 643 | // Check global cache before remote fetch. |
| 643 | 644 | const cached_tarball_sub_path = try std.fmt.allocPrint(arena, "p/{s}.tar.gz", .{expected_hash.toSlice()}); |
| 644 | | const cached_tarball_path: Cache.Path = .{ |
| 645 | const cached_tarball_path: Path = .{ |
| 645 | 646 | .root_dir = job_queue.global_cache, |
| 646 | 647 | .sub_path = cached_tarball_sub_path, |
| 647 | 648 | }; |
| ... | ... | @@ -716,7 +717,7 @@ fn runResource( |
| 716 | 717 | }; |
| 717 | 718 | const tmp_dir_sub_path = ".tmp-" ++ std.fmt.hex(rand_int); |
| 718 | 719 | const tmp_tmp_dir_sub_path = "tmp/" ++ tmp_dir_sub_path; |
| 719 | | const tmp_directory_path: Cache.Path = if (job_queue.local_storage) |ls| |
| 720 | const tmp_directory_path: Path = if (job_queue.local_storage) |ls| |
| 720 | 721 | try ls.pkg_root.join(arena, tmp_dir_sub_path) |
| 721 | 722 | else |
| 722 | 723 | .{ |
| ... | ... | @@ -725,7 +726,7 @@ fn runResource( |
| 725 | 726 | }; |
| 726 | 727 | |
| 727 | 728 | const package_sub_path = blk: { |
| 728 | | var tmp_directory: Cache.Directory = .{ |
| 729 | var tmp_directory: Directory = .{ |
| 729 | 730 | .path = tmp_directory_path.sub_path, |
| 730 | 731 | .handle = handle: { |
| 731 | 732 | const dir = tmp_directory_path.root_dir.handle.createDirPathOpen(io, tmp_directory_path.sub_path, .{ |
| ... | ... | @@ -746,7 +747,7 @@ fn runResource( |
| 746 | 747 | // Fetch and unpack a resource into a temporary directory. |
| 747 | 748 | var unpack_result = try unpackResource(f, resource, uri_path, tmp_directory); |
| 748 | 749 | |
| 749 | | const pkg_path: Cache.Path = .{ .root_dir = tmp_directory, .sub_path = unpack_result.root_dir }; |
| 750 | const pkg_path: Path = .{ .root_dir = tmp_directory, .sub_path = unpack_result.root_dir }; |
| 750 | 751 | |
| 751 | 752 | // Load, parse, and validate the unpacked build.zig.zon file. It is allowed |
| 752 | 753 | // for the file to be missing, in which case this fetched package is |
| ... | ... | @@ -874,7 +875,7 @@ fn checkBuildFileExistence(f: *Fetch) RunError!void { |
| 874 | 875 | } |
| 875 | 876 | |
| 876 | 877 | /// This function populates `f.manifest` or leaves it `null`. |
| 877 | | fn loadManifest(f: *Fetch, pkg_root: Cache.Path) RunError!void { |
| 878 | fn loadManifest(f: *Fetch, pkg_root: Path) RunError!void { |
| 878 | 879 | const io = f.job_queue.io; |
| 879 | 880 | const eb = &f.error_bundle; |
| 880 | 881 | const arena = f.arena.allocator(); |
| ... | ... | @@ -1038,7 +1039,7 @@ fn queueJobsForDeps(f: *Fetch) RunError!void { |
| 1038 | 1039 | } |
| 1039 | 1040 | } |
| 1040 | 1041 | |
| 1041 | | pub fn relativePathDigest(pkg_root: Cache.Path, cache_root: Cache.Directory) Package.Hash { |
| 1042 | pub fn relativePathDigest(pkg_root: Path, cache_root: Directory) Package.Hash { |
| 1042 | 1043 | return .initPath(pkg_root.sub_path, pkg_root.root_dir.eql(cache_root)); |
| 1043 | 1044 | } |
| 1044 | 1045 | |
| ... | ... | @@ -1331,7 +1332,7 @@ fn unpackResource( |
| 1331 | 1332 | f: *Fetch, |
| 1332 | 1333 | resource: *Resource, |
| 1333 | 1334 | uri_path: []const u8, |
| 1334 | | tmp_directory: Cache.Directory, |
| 1335 | tmp_directory: Directory, |
| 1335 | 1336 | ) RunError!UnpackResult { |
| 1336 | 1337 | const eb = &f.error_bundle; |
| 1337 | 1338 | const file_type = switch (resource.*) { |
| ... | ... | @@ -1667,7 +1668,7 @@ fn recursiveDirectoryCopy(f: *Fetch, dir: Io.Dir, tmp_dir: Io.Dir) anyerror!void |
| 1667 | 1668 | } |
| 1668 | 1669 | } |
| 1669 | 1670 | |
| 1670 | | pub fn renameTmpIntoCache(io: Io, tmp_path: Cache.Path, dest_path: Cache.Path) !void { |
| 1671 | pub fn renameTmpIntoCache(io: Io, tmp_path: Path, dest_path: Path) !void { |
| 1671 | 1672 | var handled_missing_dir = false; |
| 1672 | 1673 | while (true) { |
| 1673 | 1674 | Io.Dir.rename( |
| ... | ... | @@ -1711,7 +1712,7 @@ const ComputedHash = struct { |
| 1711 | 1712 | /// the hash are not present on the file system. Empty directories are *not |
| 1712 | 1713 | /// hashed* and must not be present on the file system when calling this |
| 1713 | 1714 | /// function. |
| 1714 | | fn computeHash(f: *Fetch, pkg_path: Cache.Path, filter: Filter) RunError!ComputedHash { |
| 1715 | fn computeHash(f: *Fetch, pkg_path: Path, filter: Filter) RunError!ComputedHash { |
| 1715 | 1716 | const io = f.job_queue.io; |
| 1716 | 1717 | // All the path name strings need to be in memory for sorting. |
| 1717 | 1718 | const arena = f.arena.allocator(); |
| ... | ... | @@ -2035,7 +2036,7 @@ const Filter = struct { |
| 2035 | 2036 | } |
| 2036 | 2037 | }; |
| 2037 | 2038 | |
| 2038 | | pub fn depDigest(pkg_root: Cache.Path, cache_root: Cache.Directory, dep: Manifest.Dependency) ?Package.Hash { |
| 2039 | pub fn depDigest(pkg_root: Path, cache_root: Directory, dep: Manifest.Dependency) ?Package.Hash { |
| 2039 | 2040 | if (dep.hash) |h| return .fromSlice(h); |
| 2040 | 2041 | |
| 2041 | 2042 | switch (dep.location) { |