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