| 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 | 146 | if (m.dep) |md| { |
| 147 | 147 | if (md.type.isLocal()) continue; |
| 148 | 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 | 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 | 107 | } |
| 108 | 108 | |
| 109 | 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() }); | |
| 111 | const pv = try std.fs.path.join(options.alloc, &.{ cachepath, try d.clean_path_v() }); | |
| 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(options.alloc) }); | |
| 112 | 112 | |
| 113 | 113 | const nocache = d.type.isLocal(); |
| 114 | 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 | 213 | pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectOptions) anyerror!?zigmod.Module { |
| 214 | 214 | if (options.lock) |lock| { |
| 215 | 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 | 217 | d.type = std.meta.stringToEnum(zigmod.DepType, item[1]).?; |
| 218 | 218 | d.path = item[2]; |
| 219 | 219 | d.version = item[3]; |
| ... | ... | @@ -334,7 +334,6 @@ pub fn add_files_package(alloc: std.mem.Allocator, cachepath: string, pkg_name: |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | var d: zigmod.Dep = .{ |
| 337 | .alloc = alloc, | |
| 338 | 337 | .type = .local, |
| 339 | 338 | .path = "files", |
| 340 | 339 | .id = "", |
| ... | ... | @@ -379,7 +378,6 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 379 | 378 | 2 => { |
| 380 | 379 | var iter = std.mem.split(u8, line, " "); |
| 381 | 380 | const asdep = zigmod.Dep{ |
| 382 | .alloc = alloc, | |
| 383 | 381 | .type = std.meta.stringToEnum(zigmod.DepType, iter.next().?).?, |
| 384 | 382 | .path = iter.next().?, |
| 385 | 383 | .version = iter.next().?, |
| ... | ... | @@ -390,7 +388,7 @@ pub fn parse_lockfile(alloc: std.mem.Allocator, dir: std.fs.Dir) ![]const [4]str |
| 390 | 388 | .deps = &.{}, |
| 391 | 389 | }; |
| 392 | 390 | try list.append([4]string{ |
| 393 | try asdep.clean_path(), | |
| 391 | try asdep.clean_path(alloc), | |
| 394 | 392 | @tagName(asdep.type), |
| 395 | 393 | asdep.path, |
| 396 | 394 | asdep.version, |
src/util/dep.zig+8-9| ... | ... | @@ -12,7 +12,6 @@ const yaml = @import("./yaml.zig"); |
| 12 | 12 | pub const Dep = struct { |
| 13 | 13 | const Self = @This(); |
| 14 | 14 | |
| 15 | alloc: std.mem.Allocator, | |
| 16 | 15 | type: zigmod.DepType, |
| 17 | 16 | path: string, |
| 18 | 17 | id: string, |
| ... | ... | @@ -30,7 +29,7 @@ pub const Dep = struct { |
| 30 | 29 | vcpkg: bool = false, |
| 31 | 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 | 33 | if (self.type == .local) { |
| 35 | 34 | return if (self.path.len == 0) "../.." else self.path; |
| 36 | 35 | } |
| ... | ... | @@ -39,16 +38,16 @@ pub const Dep = struct { |
| 39 | 38 | p = u.trim_prefix(p, "https://"); |
| 40 | 39 | p = u.trim_prefix(p, "git://"); |
| 41 | 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 | 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 | 46 | if (self.type == .http and self.version.len > 0) { |
| 48 | 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 | 53 | pub fn is_for_this(self: Dep) bool { |
| ... | ... | @@ -62,15 +61,15 @@ pub const Dep = struct { |
| 62 | 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 | 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 | 68 | return switch (self.type) { |
| 70 | 69 | .git => blk: { |
| 71 | 70 | const vers = try u.parse_split(zigmod.DepType.GitVersion, "-").do(self.version); |
| 72 | 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 | 74 | else => self.version, |
| 76 | 75 | }; |
src/util/modfile.zig-1| ... | ... | @@ -123,7 +123,6 @@ pub const ModFile = struct { |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | try dep_list.append(zigmod.Dep{ |
| 126 | .alloc = alloc, | |
| 127 | 126 | .type = dep_type, |
| 128 | 127 | .path = path, |
| 129 | 128 | .id = item.mapping.get_string("id"), |
src/util/module.zig+1-1| ... | ... | @@ -50,7 +50,7 @@ pub const Module = struct { |
| 50 | 50 | .c_source_flags = dep.c_source_flags, |
| 51 | 51 | .c_source_files = dep.c_source_files, |
| 52 | 52 | .deps = moddeps.toOwnedSlice(), |
| 53 | .clean_path = try dep.clean_path(), | |
| 53 | .clean_path = try dep.clean_path(alloc), | |
| 54 | 54 | .only_os = dep.only_os, |
| 55 | 55 | .except_os = dep.except_os, |
| 56 | 56 | .yaml = dep.yaml, |