authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-15 16:00:34 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-09-15 16:00:34 -07:00
logf12542b93daa5ece650a79b08766594dd25692a0
treee6b40c1460d2c81a1d992eaab5fb499bd40b3d36
parentf842053622e10883b17aec241587cd962c35971b

Module.is_sys_lib / Module.is_framework replaced with Module.type comparison


4 files changed, 7 insertions(+), 17 deletions(-)

src/cmd/fetch.zig+4-4
......@@ -116,7 +116,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
116116 try w.writeAll("pub const package_data = struct {\n");
117117 var duped = std.ArrayList(zigmod.Module).init(alloc);
118118 for (list.items) |mod| {
119 if (mod.is_sys_lib or mod.is_framework) {
119 if (mod.type == .system_lib or mod.type == .framework) {
120120 continue;
121121 }
122122 try duped.append(mod);
......@@ -249,7 +249,7 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item:
249249
250250fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void {
251251 for (list) |mod| {
252 if (mod.is_sys_lib or mod.is_framework) continue;
252 if (mod.type == .system_lib or mod.type == .framework) continue;
253253 if (std.mem.eql(u8, mod.id, "root")) {
254254 try w.writeAll(" pub const _root = \"\";\n");
255255 continue;
......@@ -332,7 +332,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
332332 if (mod.has_syslib_deps()) {
333333 try w.writeAll(" .system_libs = &.{");
334334 for (mod.deps) |item, j| {
335 if (!item.is_sys_lib) continue;
335 if (!(item.type == .system_lib)) continue;
336336 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
337337 if (j != mod.deps.len - 1) try w.writeAll(",");
338338 }
......@@ -341,7 +341,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
341341 if (mod.has_framework_deps()) {
342342 try w.writeAll(" .frameworks = &.{");
343343 for (mod.deps) |item, j| {
344 if (!item.is_sys_lib) continue;
344 if (!(item.type == .system_lib)) continue;
345345 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
346346 if (j != mod.deps.len - 1) try w.writeAll(",");
347347 }
src/cmd/sum.zig+1-1
......@@ -36,7 +36,7 @@ pub fn execute(args: [][]u8) !void {
3636 if (std.mem.eql(u8, m.clean_path, "../..")) {
3737 continue;
3838 }
39 if (m.is_sys_lib or m.is_framework) continue;
39 if (m.type.isLocal()) continue;
4040 const hash = try m.get_hash(gpa, cachepath);
4141 try w.print("{s} {s}\n", .{ hash, m.clean_path });
4242 }
src/common.zig-6
......@@ -48,8 +48,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO
4848 }
4949 }
5050 return zigmod.Module{
51 .is_sys_lib = false,
52 .is_framework = false,
5351 .type = .local,
5452 .id = "root",
5553 .name = "root",
......@@ -78,8 +76,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption
7876 }
7977 }
8078 return zigmod.Module{
81 .is_sys_lib = false,
82 .is_framework = false,
8379 .type = .local,
8480 .id = m.id,
8581 .name = m.name,
......@@ -231,8 +227,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
231227 switch (d.type) {
232228 .system_lib, .framework => {
233229 return zigmod.Module{
234 .is_sys_lib = d.type == .system_lib,
235 .is_framework = d.type == .framework,
236230 .type = d.type,
237231 .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path),
238232 .name = d.path,
src/util/module.zig+2-6
......@@ -11,8 +11,6 @@ const common = @import("./../common.zig");
1111//
1212
1313pub const Module = struct {
14 is_sys_lib: bool,
15 is_framework: bool,
1614 type: zigmod.Dep.Type,
1715 id: string,
1816 name: string,
......@@ -40,8 +38,6 @@ pub const Module = struct {
4038 }
4139 }
4240 return Module{
43 .is_sys_lib = false,
44 .is_framework = false,
4541 .type = dep.type,
4642 .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48),
4743 .name = dep.name,
......@@ -120,7 +116,7 @@ pub const Module = struct {
120116
121117 pub fn has_syslib_deps(self: Module) bool {
122118 for (self.deps) |d| {
123 if (d.is_sys_lib) {
119 if (d.type == .system_lib) {
124120 return true;
125121 }
126122 }
......@@ -129,7 +125,7 @@ pub const Module = struct {
129125
130126 pub fn has_framework_deps(self: Module) bool {
131127 for (self.deps) |d| {
132 if (d.is_framework) {
128 if (d.type == .framework) {
133129 return true;
134130 }
135131 }