| ... | ... | @@ -10,7 +10,7 @@ const u = @import("./util/index.zig"); |
| 10 | 10 | pub fn execute(args: [][]u8) !void { |
| 11 | 11 | // |
| 12 | 12 | const home = try known_folders.getPath(gpa, .home); |
| 13 | | const dir = try std.fmt.allocPrint(gpa, "{}{}", .{home, "/.cache/zigmod/deps"}); |
| 13 | const dir = try std.fmt.allocPrint(gpa, "{}{}", .{home, "/.cache/zigmod"}); |
| 14 | 14 | |
| 15 | 15 | const top_module = try fetch_deps(dir, "./zig.mod"); |
| 16 | 16 | |
| ... | ... | @@ -62,13 +62,16 @@ pub fn execute(args: [][]u8) !void { |
| 62 | 62 | fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 63 | 63 | const m = try u.ModFile.init(gpa, mpath); |
| 64 | 64 | const moduledeps = &std.ArrayList(u.Module).init(gpa); |
| 65 | var moddir: []const u8 = undefined; |
| 65 | 66 | for (m.deps) |d| { |
| 66 | 67 | const p = try u.concat(&[_][]const u8{dir, "/deps/", try d.clean_path()}); |
| 67 | 68 | const pv = try u.concat(&[_][]const u8{dir, "/v/", try d.clean_path(), "/", d.version}); |
| 68 | 69 | u.print("fetch: {}: {}: {}", .{m.name, @tagName(d.type), d.path}); |
| 70 | moddir = p; |
| 69 | 71 | switch (d.type) { |
| 70 | 72 | .git => blk: { |
| 71 | 73 | if (try u.does_file_exist(pv)) { |
| 74 | moddir = pv; |
| 72 | 75 | break :blk; |
| 73 | 76 | } |
| 74 | 77 | if (!try u.does_file_exist(p)) { |
| ... | ... | @@ -90,6 +93,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 90 | 93 | _ = try run_cmd(pv, &[_][]const u8{"git", "checkout", ref}); |
| 91 | 94 | const pvd = try std.fs.openDirAbsolute(pv, .{}); |
| 92 | 95 | try pvd.deleteTree(".git"); |
| 96 | moddir = pv; |
| 93 | 97 | } |
| 94 | 98 | else { |
| 95 | 99 | u.assert(false, "fetch: git: version type: '{}' on {} is invalid.", .{v_type_s, d.path}); |
| ... | ... | @@ -109,12 +113,14 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { |
| 109 | 113 | else => { |
| 110 | 114 | if (d.main.len == 0) { |
| 111 | 115 | if (d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { |
| 112 | | try moduledeps.append(try u.Module.from(d)); |
| 116 | var mod_from = try u.Module.from(d); |
| 117 | mod_from.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 118 | try moduledeps.append(mod_from); |
| 113 | 119 | } |
| 114 | 120 | break; |
| 115 | 121 | } |
| 116 | | var dd = try fetch_deps(dir, try u.concat(&[_][]const u8{p, "/zig.mod"})); |
| 117 | | dd.clean_path = try d.clean_path(); |
| 122 | var dd = try fetch_deps(dir, try u.concat(&[_][]const u8{moddir, "/zig.mod"})); |
| 123 | dd.clean_path = u.trim_prefix(moddir, dir)[1..]; |
| 118 | 124 | |
| 119 | 125 | if (d.name.len > 0) dd.name = d.name; |
| 120 | 126 | if (d.main.len > 0) dd.main = d.main; |