authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-04-09 01:25:05 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-04-09 01:25:05 -07:00
log772f3943a0a4e60e7f1108f96a0356f1a201a164
treee02fcd9e5fcbba095a4114f3e411007afa1653a6
parent3cf3d42217b5cd8ee166f981e6f16c958f88ed86
signaturelock-open Commit is signed but in an unrecognized format.

add self as package and proper dev_dep support


5 files changed, 40 insertions(+), 6 deletions(-)

src/cmd/fetch.zig+5-1
......@@ -13,7 +13,7 @@ pub fn execute(args: [][]u8) !void {
1313 //
1414 const dir = try fs.path.join(gpa, &.{".zigmod", "deps"});
1515
16 const top_module = try common.collect_deps(dir, "zig.mod", .{
16 const top_module = try common.collect_deps_deep(dir, "zig.mod", .{
1717 .log = true,
1818 .update = true,
1919 });
......@@ -67,6 +67,10 @@ pub fn execute(args: [][]u8) !void {
6767 try w.writeAll("pub const package_data = struct {\n");
6868 const duped = &std.ArrayList(u.Module).init(gpa);
6969 for (list.items) |mod| {
70 if (std.mem.eql(u8, mod.id, "root")) {
71 continue;
72 }
73 try duped.append(mod);
7074 }
7175 try print_pkg_data_to(w, duped, &std.ArrayList(u.Module).init(gpa));
7276 try w.writeAll("};\n\n");
src/cmd/license.zig+6-3
......@@ -20,7 +20,7 @@ pub fn execute(args: [][]u8) !void {
2020 //
2121 const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"});
2222
23 const top_module = try common.collect_deps(dir, "zig.mod", .{
23 const top_module = try common.collect_deps_deep(dir, "zig.mod", .{
2424 .log = false,
2525 .update = false,
2626 });
......@@ -33,6 +33,9 @@ pub fn execute(args: [][]u8) !void {
3333 const unspecified_list = &List.init(gpa);
3434
3535 for (master_list.items) |item| {
36 if (item.clean_path.len == 0) {
37 continue;
38 }
3639 if (item.yaml == null) {
3740 try unspecified_list.append(item);
3841 continue;
......@@ -60,7 +63,7 @@ pub fn execute(args: [][]u8) !void {
6063 }
6164 std.debug.print(style.ResetIntensity, .{});
6265 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"});
6467 }
6568 std.debug.print("\n", .{});
6669 }
......@@ -68,7 +71,7 @@ pub fn execute(args: [][]u8) !void {
6871 std.debug.print(style.Bold ++ "Unspecified:\n", .{});
6972 std.debug.print(style.ResetIntensity, .{});
7073 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"});
7275 }
7376 }
7477}
src/cmd/sum.zig+2-1
......@@ -12,7 +12,7 @@ pub fn execute(args: [][]u8) !void {
1212 //
1313 const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"});
1414
15 const top_module = try common.collect_deps(dir, "zig.mod", .{
15 const top_module = try common.collect_deps_deep(dir, "zig.mod", .{
1616 .log = false,
1717 .update = false,
1818 });
......@@ -28,6 +28,7 @@ pub fn execute(args: [][]u8) !void {
2828
2929 for (module_list.items) |m| {
3030 if (m.clean_path.len == 0) { continue; }
31 if (std.mem.eql(u8, m.clean_path, "../..")) { continue; }
3132 const hash = try m.get_hash(dir);
3233 try w.print("{s} {s}\n", .{hash, m.clean_path});
3334 }
src/common.zig+24-1
......@@ -12,6 +12,29 @@ pub const CollectOptions = struct {
1212 update: bool,
1313};
1414
15pub 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
1538pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: CollectOptions) anyerror!u.Module {
1639 const m = try u.ModFile.init(gpa, mpath);
1740 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
2750 .c_source_flags = m.c_source_flags,
2851 .c_source_files = m.c_source_files,
2952 .deps = moduledeps.items,
30 .clean_path = "",
53 .clean_path = "../..",
3154 .only_os = &.{},
3255 .except_os = &.{},
3356 .yaml = m.yaml,
src/util/modfile.zig+3
......@@ -22,6 +22,7 @@ pub const ModFile = struct {
2222 c_source_files: [][]const u8,
2323 deps: []u.Dep,
2424 yaml: yaml.Mapping,
25 devdeps: []u.Dep,
2526
2627 pub fn init(alloc: *std.mem.Allocator, fpath: []const u8) !Self {
2728 //
......@@ -39,6 +40,7 @@ pub const ModFile = struct {
3940 const main = mapping.get_string("main");
4041
4142 const dep_list = try dep_list_by_name(alloc, mapping, "dependencies");
43 const devdep_list = try dep_list_by_name(alloc, mapping, "dev_dependencies");
4244
4345 return Self{
4446 .alloc = alloc,
......@@ -50,6 +52,7 @@ pub const ModFile = struct {
5052 .c_source_files = try mapping.get_string_array(alloc, "c_source_files"),
5153 .deps = dep_list.items,
5254 .yaml = mapping,
55 .devdeps = devdep_list.items,
5356 };
5457 }
5558