| author | |
| committer | |
| log | 426ada3d7ce5491308a61eb366863ae236b19661 |
| tree | 63932c9da09403acd4de1043c96a4faf41551f6a |
| parent | 76cb08619f79c914baebd7d5c11d4b453702872d |
5 files changed, 19 insertions(+), 15 deletions(-)
src/cmd/ci.zig+2-2| ... | @@ -10,15 +10,15 @@ const common = @import("./../common.zig"); | ... | @@ -10,15 +10,15 @@ const common = @import("./../common.zig"); |
| 10 | pub fn execute(args: [][]u8) !void { | 10 | pub fn execute(args: [][]u8) !void { |
| 11 | _ = args; | 11 | _ = args; |
| 12 | 12 | ||
| 13 | const dir = std.fs.cwd(); | ||
| 14 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 13 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); |
| 14 | const dir = std.fs.cwd(); | ||
| 15 | 15 | ||
| 16 | var options = common.CollectOptions{ | 16 | var options = common.CollectOptions{ |
| 17 | .log = true, | 17 | .log = true, |
| 18 | .update = false, | 18 | .update = false, |
| 19 | .lock = try common.parse_lockfile(dir), | 19 | .lock = try common.parse_lockfile(dir), |
| 20 | }; | 20 | }; |
| 21 | const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); | 21 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 22 | 22 | ||
| 23 | var list = std.ArrayList(u.Module).init(gpa); | 23 | var list = std.ArrayList(u.Module).init(gpa); |
| 24 | try common.collect_pkgs(top_module, &list); | 24 | try common.collect_pkgs(top_module, &list); |
src/cmd/fetch.zig+2-1| ... | @@ -18,13 +18,14 @@ const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootst | ... | @@ -18,13 +18,14 @@ const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootst |
| 18 | pub fn execute(args: [][]u8) !void { | 18 | pub fn execute(args: [][]u8) !void { |
| 19 | // | 19 | // |
| 20 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 20 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); |
| 21 | const dir = std.fs.cwd(); | ||
| 21 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); | 22 | const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); |
| 22 | 23 | ||
| 23 | var options = common.CollectOptions{ | 24 | var options = common.CollectOptions{ |
| 24 | .log = should_update, | 25 | .log = should_update, |
| 25 | .update = should_update, | 26 | .update = should_update, |
| 26 | }; | 27 | }; |
| 27 | const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); | 28 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 28 | 29 | ||
| 29 | var list = std.ArrayList(u.Module).init(gpa); | 30 | var list = std.ArrayList(u.Module).init(gpa); |
| 30 | try common.collect_pkgs(top_module, &list); | 31 | try common.collect_pkgs(top_module, &list); |
src/cmd/license.zig+2-1| ... | @@ -18,12 +18,13 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -18,12 +18,13 @@ pub fn execute(args: [][]u8) !void { |
| 18 | _ = args; | 18 | _ = args; |
| 19 | 19 | ||
| 20 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 20 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); |
| 21 | const dir = std.fs.cwd(); | ||
| 21 | 22 | ||
| 22 | var options = common.CollectOptions{ | 23 | var options = common.CollectOptions{ |
| 23 | .log = false, | 24 | .log = false, |
| 24 | .update = false, | 25 | .update = false, |
| 25 | }; | 26 | }; |
| 26 | const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); | 27 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 27 | 28 | ||
| 28 | const master_list = &List.init(gpa); | 29 | const master_list = &List.init(gpa); |
| 29 | try common.collect_pkgs(top_module, master_list); | 30 | try common.collect_pkgs(top_module, master_list); |
src/cmd/sum.zig+3-2| ... | @@ -11,15 +11,16 @@ pub fn execute(args: [][]u8) !void { | ... | @@ -11,15 +11,16 @@ pub fn execute(args: [][]u8) !void { |
| 11 | _ = args; | 11 | _ = args; |
| 12 | 12 | ||
| 13 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); | 13 | const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); |
| 14 | const dir = std.fs.cwd(); | ||
| 14 | 15 | ||
| 15 | var options = common.CollectOptions{ | 16 | var options = common.CollectOptions{ |
| 16 | .log = false, | 17 | .log = false, |
| 17 | .update = false, | 18 | .update = false, |
| 18 | }; | 19 | }; |
| 19 | const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); | 20 | const top_module = try common.collect_deps_deep(cachepath, dir, &options); |
| 20 | 21 | ||
| 21 | // | 22 | // |
| 22 | const f = try std.fs.cwd().createFile("zigmod.sum", .{}); | 23 | const f = try dir.createFile("zigmod.sum", .{}); |
| 23 | defer f.close(); | 24 | defer f.close(); |
| 24 | const w = f.writer(); | 25 | const w = f.writer(); |
| 25 | 26 |
src/common.zig+10-9| ... | @@ -27,8 +27,8 @@ pub const CollectOptions = struct { | ... | @@ -27,8 +27,8 @@ pub const CollectOptions = struct { |
| 27 | } | 27 | } |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) !u.Module { | 30 | pub fn collect_deps_deep(cachepath: []const u8, mdir: std.fs.Dir, options: *CollectOptions) !u.Module { |
| 31 | const m = try u.ModFile.init(gpa, mpath); | 31 | const m = try u.ModFile.from_dir(gpa, mdir); |
| 32 | try options.init(); | 32 | try options.init(); |
| 33 | var moduledeps = std.ArrayList(u.Module).init(gpa); | 33 | var moduledeps = std.ArrayList(u.Module).init(gpa); |
| 34 | defer moduledeps.deinit(); | 34 | defer moduledeps.deinit(); |
| ... | @@ -36,7 +36,7 @@ pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *Col | ... | @@ -36,7 +36,7 @@ pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *Col |
| 36 | try std.fs.cwd().makePath(".zigmod/deps/files"); | 36 | try std.fs.cwd().makePath(".zigmod/deps/files"); |
| 37 | try moduledeps.append(try add_files_package("root", m.root_files, m.name)); | 37 | try moduledeps.append(try add_files_package("root", m.root_files, m.name)); |
| 38 | } | 38 | } |
| 39 | try moduledeps.append(try collect_deps(cachepath, mpath, options)); | 39 | try moduledeps.append(try collect_deps(cachepath, mdir, options)); |
| 40 | for (m.devdeps) |*d| { | 40 | for (m.devdeps) |*d| { |
| 41 | if (try get_module_from_dep(d, cachepath, m.name, options)) |founddep| { | 41 | if (try get_module_from_dep(d, cachepath, m.name, options)) |founddep| { |
| 42 | try moduledeps.append(founddep); | 42 | try moduledeps.append(founddep); |
| ... | @@ -54,8 +54,8 @@ pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *Col | ... | @@ -54,8 +54,8 @@ pub fn collect_deps_deep(cachepath: []const u8, mpath: []const u8, options: *Col |
| 54 | }; | 54 | }; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | pub fn collect_deps(cachepath: []const u8, mpath: []const u8, options: *CollectOptions) anyerror!u.Module { | 57 | pub fn collect_deps(cachepath: []const u8, mdir: std.fs.Dir, options: *CollectOptions) anyerror!u.Module { |
| 58 | const m = try u.ModFile.init(gpa, mpath); | 58 | const m = try u.ModFile.from_dir(gpa, mdir); |
| 59 | var moduledeps = std.ArrayList(u.Module).init(gpa); | 59 | var moduledeps = std.ArrayList(u.Module).init(gpa); |
| 60 | defer moduledeps.deinit(); | 60 | defer moduledeps.deinit(); |
| 61 | if (m.files.len > 0) { | 61 | if (m.files.len > 0) { |
| ... | @@ -92,9 +92,9 @@ pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void | ... | @@ -92,9 +92,9 @@ pub fn collect_pkgs(mod: u.Module, list: *std.ArrayList(u.Module)) anyerror!void |
| 92 | } | 92 | } |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | pub fn get_modpath(basedir: []const u8, d: u.Dep, parent_name: []const u8, options: *CollectOptions) ![]const u8 { | 95 | pub fn get_modpath(cachepath: []const u8, d: u.Dep, parent_name: []const u8, options: *CollectOptions) ![]const u8 { |
| 96 | const p = try std.fs.path.join(gpa, &.{ basedir, try d.clean_path() }); | 96 | const p = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path() }); |
| 97 | const pv = try std.fs.path.join(gpa, &.{ basedir, try d.clean_path_v() }); | 97 | const pv = try std.fs.path.join(gpa, &.{ cachepath, try d.clean_path_v() }); |
| 98 | 98 | ||
| 99 | const nocache = d.type == .local or d.type == .system_lib; | 99 | const nocache = d.type == .local or d.type == .system_lib; |
| 100 | if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; | 100 | if (!nocache and u.list_contains(options.already_fetched.items, p)) return p; |
| ... | @@ -209,6 +209,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []cons | ... | @@ -209,6 +209,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []cons |
| 209 | } | 209 | } |
| 210 | } | 210 | } |
| 211 | const modpath = try get_modpath(cachepath, d.*, parent_name, options); | 211 | const modpath = try get_modpath(cachepath, d.*, parent_name, options); |
| 212 | const moddir = try std.fs.cwd().openDir(modpath, .{}); | ||
| 212 | 213 | ||
| 213 | const nocache = d.type == .local or d.type == .system_lib; | 214 | const nocache = d.type == .local or d.type == .system_lib; |
| 214 | if (!nocache) try options.already_fetched.append(modpath); | 215 | if (!nocache) try options.already_fetched.append(modpath); |
| ... | @@ -229,7 +230,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []cons | ... | @@ -229,7 +230,7 @@ pub fn get_module_from_dep(d: *u.Dep, cachepath: []const u8, parent_name: []cons |
| 229 | }; | 230 | }; |
| 230 | }, | 231 | }, |
| 231 | else => { | 232 | else => { |
| 232 | var dd = try collect_deps(cachepath, try u.concat(&.{ modpath, "/zig.mod" }), options) catch |e| switch (e) { | 233 | var dd = try collect_deps(cachepath, moddir, options) catch |e| switch (e) { |
| 233 | error.FileNotFound => { | 234 | error.FileNotFound => { |
| 234 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { | 235 | if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 235 | var mod_from = try u.Module.from(d.*, cachepath, options); | 236 | var mod_from = try u.Module.from(d.*, cachepath, options); |