| author | |
| committer | |
| log | d680d06973dd0a13c9561ba7d01f1d7892653091 |
| tree | 54c7340d08237082161ee4c1eb3ea171bf3fa05d |
| parent | 3a142ec8ec15b9d20600e42f3a997f7f6056a9da |
5 files changed, 14 insertions(+), 18 deletions(-)
src/cmd/fetch.zig+1-1| ... | @@ -146,7 +146,7 @@ fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module) | ... | @@ -146,7 +146,7 @@ fn create_lockfile(alloc: std.mem.Allocator, list: *std.ArrayList(zigmod.Module) |
| 146 | if (m.dep) |md| { | 146 | if (m.dep) |md| { |
| 147 | if (md.type.isLocal()) continue; | 147 | if (md.type.isLocal()) continue; |
| 148 | const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path }); | 148 | const mpath = try std.fs.path.join(alloc, &.{ path, m.clean_path }); |
| 149 | const version = try md.exact_version(mpath); | 149 | const version = try md.exact_version(alloc, mpath); |
| 150 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); | 150 | try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); |
| 151 | } | 151 | } |
| 152 | } | 152 | } |
src/common.zig+4-6| ... | @@ -107,8 +107,8 @@ pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) any | ... | @@ -107,8 +107,8 @@ pub fn collect_pkgs(mod: zigmod.Module, list: *std.ArrayList(zigmod.Module)) any |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !string { | 109 | pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) !string { |
| 110 | const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path() }); | 110 | const p = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path(options.alloc) }); |
| 111 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v() }); | 111 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v(options.alloc) }); |
| 112 | 112 | ||
| 113 | const nocache = d.type.isLocal(); | 113 | const nocache = d.type.isLocal(); |
| 114 | if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; | 114 | if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; |
| ... | @@ -213,7 +213,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! | ... | @@ -213,7 +213,7 @@ pub fn get_modpath(cachepath: string, d: zigmod.Dep, options: *CollectOptions) ! |
| 213 | pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?zigmod.Module { | 213 | pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?zigmod.Module { |
| 214 | if (options.lock) |lock| { | 214 | if (options.lock) |lock| { |
| 215 | for (lock) |item| { | 215 | for (lock) |item| { |
| 216 | if (std.mem.eql(u8, item[0], try d.clean_path())) { | 216 | if (std.mem.eql(u8, item[0], try d.clean_path(options.alloc))) { |
| 217 | d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?; | 217 | d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?; |
| 218 | d.path = item[2]; | 218 | d.path = item[2]; |
| 219 | d.version = item[3]; | 219 | d.version = item[3]; |
| ... | @@ -334,7 +334,6 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name: | ... | @@ -334,7 +334,6 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name: |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | var d: zigmod.Dep = .{ | 336 | var d: zigmod.Dep = .{ |
| 337 | .alloc = alloc, | ||
| 338 | .type = .local, | 337 | .type = .local, |
| 339 | .path = "files", | 338 | .path = "files", |
| 340 | .id = "", | 339 | .id = "", |
| ... | @@ -379,7 +378,6 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str | ... | @@ -379,7 +378,6 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 379 | 2 => { | 378 | 2 => { |
| 380 | var iter = std.mem.split(u8, line, " "); | 379 | var iter = std.mem.split(u8, line, " "); |
| 381 | const asdep = zigmod.Dep{ | 380 | const asdep = zigmod.Dep{ |
| 382 | .alloc = alloc, | ||
| 383 | .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?, | 381 | .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?, |
| 384 | .path = iter.next().?, | 382 | .path = iter.next().?, |
| 385 | .version = iter.next().?, | 383 | .version = iter.next().?, |
| ... | @@ -390,7 +388,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str | ... | @@ -390,7 +388,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 390 | .deps = &.{}, | 388 | .deps = &.{}, |
| 391 | }; | 389 | }; |
| 392 | try list.append([4]string{ | 390 | try list.append([4]string{ |
| 393 | try asdep.clean_path(), | 391 | try asdep.clean_path(alloc), |
| 394 | @tagName(asdep.type), | 392 | @tagName(asdep.type), |
| 395 | asdep.path, | 393 | asdep.path, |
| 396 | asdep.version, | 394 | asdep.version, |
src/util/dep.zig+8-9| ... | @@ -12,7 +12,6 @@ const yaml = @import("./yaml.zig"); | ... | @@ -12,7 +12,6 @@ const yaml = @import("./yaml.zig"); |
| 12 | pub const Dep = struct { | 12 | pub const Dep = struct { |
| 13 | const Self = @This(); | 13 | const Self = @This(); |
| 14 | 14 | ||
| 15 | alloc: std.mem.Allocator, | ||
| 16 | type: zigmod.DepType, | 15 | type: zigmod.DepType, |
| 17 | path: string, | 16 | path: string, |
| 18 | id: string, | 17 | id: string, |
| ... | @@ -30,7 +29,7 @@ pub const Dep = struct { | ... | @@ -30,7 +29,7 @@ pub const Dep = struct { |
| 30 | vcpkg: bool = false, | 29 | vcpkg: bool = false, |
| 31 | for_build: bool = false, | 30 | for_build: bool = false, |
| 32 | 31 | ||
| 33 | pub fn clean_path(self: Dep) !string { | 32 | pub fn clean_path(self: Dep, alloc: std.mem.Allocator) !string { |
| 34 | if (self.type == .local) { | 33 | if (self.type == .local) { |
| 35 | return if (self.path.len == 0) "../.." else self.path; | 34 | return if (self.path.len == 0) "../.." else self.path; |
| 36 | } | 35 | } |
| ... | @@ -39,16 +38,16 @@ pub const Dep = struct { | ... | @@ -39,16 +38,16 @@ pub const Dep = struct { |
| 39 | p = u.trim_prefix(p, "https://"); | 38 | p = u.trim_prefix(p, "https://"); |
| 40 | p = u.trim_prefix(p, "git://"); | 39 | p = u.trim_prefix(p, "git://"); |
| 41 | p = u.trim_suffix(p, ".git"); | 40 | p = u.trim_suffix(p, ".git"); |
| 42 | p = try std.mem.join(self.alloc, "/", &.{ @tagName(self.type), p }); | 41 | p = try std.mem.join(alloc, "/", &.{ @tagName(self.type), p }); |
| 43 | return p; | 42 | return p; |
| 44 | } | 43 | } |
| 45 | 44 | ||
| 46 | pub fn clean_path_v(self: Dep) !string { | 45 | pub fn clean_path_v(self: Dep, alloc: std.mem.Allocator) !string { |
| 47 | if (self.type == .http and self.version.len > 0) { | 46 | if (self.type == .http and self.version.len > 0) { |
| 48 | const i = std.mem.indexOf(u8, self.version, "-").?; | 47 | const i = std.mem.indexOf(u8, self.version, "-").?; |
| 49 | return std.mem.join(self.alloc, "/", &.{ "v", try self.clean_path(), self.version[i + 1 .. 15] }); | 48 | return std.mem.join(alloc, "/", &.{ "v", try self.clean_path(alloc), self.version[i + 1 .. 15] }); |
| 50 | } | 49 | } |
| 51 | return std.mem.join(self.alloc, "/", &.{ "v", try self.clean_path(), self.version }); | 50 | return std.mem.join(alloc, "/", &.{ "v", try self.clean_path(alloc), self.version }); |
| 52 | } | 51 | } |
| 53 | 52 | ||
| 54 | pub fn is_for_this(self: Dep) bool { | 53 | pub fn is_for_this(self: Dep) bool { |
| ... | @@ -62,15 +61,15 @@ pub const Dep = struct { | ... | @@ -62,15 +61,15 @@ pub const Dep = struct { |
| 62 | return true; | 61 | return true; |
| 63 | } | 62 | } |
| 64 | 63 | ||
| 65 | pub fn exact_version(self: Dep, dpath: string) !string { | 64 | pub fn exact_version(self: Dep, alloc: std.mem.Allocator, dpath: string) !string { |
| 66 | if (self.version.len == 0) { | 65 | if (self.version.len == 0) { |
| 67 | return try self.type.exact_version(self.alloc, dpath); | 66 | return try self.type.exact_version(alloc, dpath); |
| 68 | } | 67 | } |
| 69 | return switch (self.type) { | 68 | return switch (self.type) { |
| 70 | .git => blk: { | 69 | .git => blk: { |
| 71 | const vers = try u.parse_split(zigmod.DepType.GitVersion, "-").do(self.version); | 70 | const vers = try u.parse_split(zigmod.DepType.GitVersion, "-").do(self.version); |
| 72 | if (vers.id.frozen()) break :blk self.version; | 71 | if (vers.id.frozen()) break :blk self.version; |
| 73 | break :blk try self.type.exact_version(self.alloc, dpath); | 72 | break :blk try self.type.exact_version(alloc, dpath); |
| 74 | }, | 73 | }, |
| 75 | else => self.version, | 74 | else => self.version, |
| 76 | }; | 75 | }; |
src/util/modfile.zig-1| ... | @@ -123,7 +123,6 @@ pub const ModFile = struct { | ... | @@ -123,7 +123,6 @@ pub const ModFile = struct { |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | try dep_list.append(zigmod.Dep{ | 125 | try dep_list.append(zigmod.Dep{ |
| 126 | .alloc = alloc, | ||
| 127 | .type = dep_type, | 126 | .type = dep_type, |
| 128 | .path = path, | 127 | .path = path, |
| 129 | .id = item.mapping.get_string("id"), | 128 | .id = item.mapping.get_string("id"), |
src/util/module.zig+1-1| ... | @@ -50,7 +50,7 @@ pub const Module = struct { | ... | @@ -50,7 +50,7 @@ pub const Module = struct { |
| 50 | .c_source_flags = dep.c_source_flags, | 50 | .c_source_flags = dep.c_source_flags, |
| 51 | .c_source_files = dep.c_source_files, | 51 | .c_source_files = dep.c_source_files, |
| 52 | .deps = moddeps.toOwnedSlice(), | 52 | .deps = moddeps.toOwnedSlice(), |
| 53 | .clean_path = try dep.clean_path(), | 53 | .clean_path = try dep.clean_path(alloc), |
| 54 | .only_os = dep.only_os, | 54 | .only_os = dep.only_os, |
| 55 | .except_os = dep.except_os, | 55 | .except_os = dep.except_os, |
| 56 | .yaml = dep.yaml, | 56 | .yaml = dep.yaml, |