| author | |
| committer | |
| log | 772f3943a0a4e60e7f1108f96a0356f1a201a164 |
| tree | e02fcd9e5fcbba095a4114f3e411007afa1653a6 |
| parent | 3cf3d42217b5cd8ee166f981e6f16c958f88ed86 |
| signature |
5 files changed, 40 insertions(+), 6 deletions(-)
src/cmd/fetch.zig+5-1| ... | ... | @@ -13,7 +13,7 @@ pub fn execute(args: [][]u8) !void { |
| 13 | 13 | // |
| 14 | 14 | const dir = try fs.path.join(gpa, &.{".zigmod", "deps"}); |
| 15 | 15 | |
| 16 | const top_module = try common.collect_deps(dir, "zig.mod", .{ | |
| 16 | const top_module = try common.collect_deps_deep(dir, "zig.mod", .{ | |
| 17 | 17 | .log = true, |
| 18 | 18 | .update = true, |
| 19 | 19 | }); |
| ... | ... | @@ -67,6 +67,10 @@ pub fn execute(args: [][]u8) !void { |
| 67 | 67 | try w.writeAll("pub const package_data = struct {\n"); |
| 68 | 68 | const duped = &std.ArrayList(u.Module).init(gpa); |
| 69 | 69 | for (list.items) |mod| { |
| 70 | if (std.mem.eql(u8, mod.id, "root")) { | |
| 71 | continue; | |
| 72 | } | |
| 73 | try duped.append(mod); | |
| 70 | 74 | } |
| 71 | 75 | try print_pkg_data_to(w, duped, &std.ArrayList(u.Module).init(gpa)); |
| 72 | 76 | try w.writeAll("};\n\n"); |
src/cmd/license.zig+6-3| ... | ... | @@ -20,7 +20,7 @@ pub fn execute(args: [][]u8) !void { |
| 20 | 20 | // |
| 21 | 21 | const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"}); |
| 22 | 22 | |
| 23 | const top_module = try common.collect_deps(dir, "zig.mod", .{ | |
| 23 | const top_module = try common.collect_deps_deep(dir, "zig.mod", .{ | |
| 24 | 24 | .log = false, |
| 25 | 25 | .update = false, |
| 26 | 26 | }); |
| ... | ... | @@ -33,6 +33,9 @@ pub fn execute(args: [][]u8) !void { |
| 33 | 33 | const unspecified_list = &List.init(gpa); |
| 34 | 34 | |
| 35 | 35 | for (master_list.items) |item| { |
| 36 | if (item.clean_path.len == 0) { | |
| 37 | continue; | |
| 38 | } | |
| 36 | 39 | if (item.yaml == null) { |
| 37 | 40 | try unspecified_list.append(item); |
| 38 | 41 | continue; |
| ... | ... | @@ -60,7 +63,7 @@ pub fn execute(args: [][]u8) !void { |
| 60 | 63 | } |
| 61 | 64 | std.debug.print(style.ResetIntensity, .{}); |
| 62 | 65 | for (entry.value.items) |item| { |
| 63 | std.debug.print("- {s}\n", .{if (item.clean_path.len > 0) item.clean_path else "This"}); | |
| 66 | std.debug.print("- {s}\n", .{if (!std.mem.eql(u8, item.clean_path, "../..")) item.clean_path else "This"}); | |
| 64 | 67 | } |
| 65 | 68 | std.debug.print("\n", .{}); |
| 66 | 69 | } |
| ... | ... | @@ -68,7 +71,7 @@ pub fn execute(args: [][]u8) !void { |
| 68 | 71 | std.debug.print(style.Bold ++ "Unspecified:\n", .{}); |
| 69 | 72 | std.debug.print(style.ResetIntensity, .{}); |
| 70 | 73 | for (unspecified_list.items) |item| { |
| 71 | std.debug.print("- {s}\n", .{if (item.clean_path.len > 0) item.clean_path else "This"}); | |
| 74 | std.debug.print("- {s}\n", .{if (!std.mem.eql(u8, item.clean_path, "../..")) item.clean_path else "This"}); | |
| 72 | 75 | } |
| 73 | 76 | } |
| 74 | 77 | } |
src/cmd/sum.zig+2-1| ... | ... | @@ -12,7 +12,7 @@ pub fn execute(args: [][]u8) !void { |
| 12 | 12 | // |
| 13 | 13 | const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"}); |
| 14 | 14 | |
| 15 | const top_module = try common.collect_deps(dir, "zig.mod", .{ | |
| 15 | const top_module = try common.collect_deps_deep(dir, "zig.mod", .{ | |
| 16 | 16 | .log = false, |
| 17 | 17 | .update = false, |
| 18 | 18 | }); |
| ... | ... | @@ -28,6 +28,7 @@ pub fn execute(args: [][]u8) !void { |
| 28 | 28 | |
| 29 | 29 | for (module_list.items) |m| { |
| 30 | 30 | if (m.clean_path.len == 0) { continue; } |
| 31 | if (std.mem.eql(u8, m.clean_path, "../..")) { continue; } | |
| 31 | 32 | const hash = try m.get_hash(dir); |
| 32 | 33 | try w.print("{s} {s}\n", .{hash, m.clean_path}); |
| 33 | 34 | } |
src/common.zig+24-1| ... | ... | @@ -12,6 +12,29 @@ pub const CollectOptions = struct { |
| 12 | 12 | update: bool, |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | pub fn collect_deps_deep(dir: []const u8, mpath: []const u8, comptime options: CollectOptions) !u.Module { | |
| 16 | const m = try u.ModFile.init(gpa, mpath); | |
| 17 | const moduledeps = &std.ArrayList(u.Module).init(gpa); | |
| 18 | try moduledeps.append(try collect_deps(dir, mpath, options)); | |
| 19 | for (m.devdeps) |d| { | |
| 20 | try get_module_from_dep(moduledeps, d, dir, m.name, options); | |
| 21 | } | |
| 22 | return u.Module{ | |
| 23 | .is_sys_lib = false, | |
| 24 | .id = "root", | |
| 25 | .name = "root", | |
| 26 | .main = m.main, | |
| 27 | .c_include_dirs = &.{}, | |
| 28 | .c_source_flags = &.{}, | |
| 29 | .c_source_files = &.{}, | |
| 30 | .deps = moduledeps.items, | |
| 31 | .clean_path = "", | |
| 32 | .only_os = &.{}, | |
| 33 | .except_os = &.{}, | |
| 34 | .yaml = m.yaml, | |
| 35 | }; | |
| 36 | } | |
| 37 | ||
| 15 | 38 | pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: CollectOptions) anyerror!u.Module { |
| 16 | 39 | const m = try u.ModFile.init(gpa, mpath); |
| 17 | 40 | const moduledeps = &std.ArrayList(u.Module).init(gpa); |
| ... | ... | @@ -27,7 +50,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec |
| 27 | 50 | .c_source_flags = m.c_source_flags, |
| 28 | 51 | .c_source_files = m.c_source_files, |
| 29 | 52 | .deps = moduledeps.items, |
| 30 | .clean_path = "", | |
| 53 | .clean_path = "../..", | |
| 31 | 54 | .only_os = &.{}, |
| 32 | 55 | .except_os = &.{}, |
| 33 | 56 | .yaml = m.yaml, |
src/util/modfile.zig+3| ... | ... | @@ -22,6 +22,7 @@ pub const ModFile = struct { |
| 22 | 22 | c_source_files: [][]const u8, |
| 23 | 23 | deps: []u.Dep, |
| 24 | 24 | yaml: yaml.Mapping, |
| 25 | devdeps: []u.Dep, | |
| 25 | 26 | |
| 26 | 27 | pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self { |
| 27 | 28 | // |
| ... | ... | @@ -39,6 +40,7 @@ pub const ModFile = struct { |
| 39 | 40 | const main = mapping.get_string("main"); |
| 40 | 41 | |
| 41 | 42 | const dep_list = try dep_list_by_name(alloc, mapping, "dependencies"); |
| 43 | const devdep_list = try dep_list_by_name(alloc, mapping, "dev_dependencies"); | |
| 42 | 44 | |
| 43 | 45 | return Self{ |
| 44 | 46 | .alloc = alloc, |
| ... | ... | @@ -50,6 +52,7 @@ pub const ModFile = struct { |
| 50 | 52 | .c_source_files = try mapping.get_string_array(alloc, "c_source_files"), |
| 51 | 53 | .deps = dep_list.items, |
| 52 | 54 | .yaml = mapping, |
| 55 | .devdeps = devdep_list.items, | |
| 53 | 56 | }; |
| 54 | 57 | } |
| 55 | 58 |