From f12542b93daa5ece650a79b08766594dd25692a0 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 15 Sep 2022 16:00:34 -0700 Subject: [PATCH] Module.is_sys_lib / Module.is_framework replaced with Module.type comparison --- src/cmd/fetch.zig | 8 ++++---- src/cmd/sum.zig | 2 +- src/common.zig | 6 ------ src/util/module.zig | 8 ++------ 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index 18ed59f7b8eec7a1fb2481408449762da22555c7..bfbad49a7592024acfaf643b95593ada7ab3904d 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -116,7 +116,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D try w.writeAll("pub const package_data = struct {\n"); var duped = std.ArrayList(zigmod.Module).init(alloc); for (list.items) |mod| { - if (mod.is_sys_lib or mod.is_framework) { + if (mod.type == .system_lib or mod.type == .framework) { continue; } try duped.append(mod); @@ -249,7 +249,7 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item: fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void { for (list) |mod| { - if (mod.is_sys_lib or mod.is_framework) continue; + if (mod.type == .system_lib or mod.type == .framework) continue; if (std.mem.eql(u8, mod.id, "root")) { try w.writeAll(" pub const _root = \"\";\n"); continue; @@ -332,7 +332,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul if (mod.has_syslib_deps()) { try w.writeAll(" .system_libs = &.{"); for (mod.deps) |item, j| { - if (!item.is_sys_lib) continue; + if (!(item.type == .system_lib)) continue; try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); if (j != mod.deps.len - 1) try w.writeAll(","); } @@ -341,7 +341,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul if (mod.has_framework_deps()) { try w.writeAll(" .frameworks = &.{"); for (mod.deps) |item, j| { - if (!item.is_sys_lib) continue; + if (!(item.type == .system_lib)) continue; try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)}); if (j != mod.deps.len - 1) try w.writeAll(","); } diff --git a/src/cmd/sum.zig b/src/cmd/sum.zig index 8ad66ab5e7f71ced749f23003c3abd84124b3499..2483af21b808e5193dee4378f5e38de941a5a4cf 100644 --- a/src/cmd/sum.zig +++ b/src/cmd/sum.zig @@ -36,7 +36,7 @@ pub fn execute(args: [][]u8) !void { if (std.mem.eql(u8, m.clean_path, "../..")) { continue; } - if (m.is_sys_lib or m.is_framework) continue; + if (m.type.isLocal()) continue; const hash = try m.get_hash(gpa, cachepath); try w.print("{s} {s}\n", .{ hash, m.clean_path }); } diff --git a/src/common.zig b/src/common.zig index 2c1c27cece57411278288421537c28c914b41d56..c3a7d4b1fb54060e4ae1af102fb94d701b99e85b 100644 --- a/src/common.zig +++ b/src/common.zig @@ -48,8 +48,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO } } return zigmod.Module{ - .is_sys_lib = false, - .is_framework = false, .type = .local, .id = "root", .name = "root", @@ -78,8 +76,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption } } return zigmod.Module{ - .is_sys_lib = false, - .is_framework = false, .type = .local, .id = m.id, .name = m.name, @@ -231,8 +227,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO switch (d.type) { .system_lib, .framework => { return zigmod.Module{ - .is_sys_lib = d.type == .system_lib, - .is_framework = d.type == .framework, .type = d.type, .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path), .name = d.path, diff --git a/src/util/module.zig b/src/util/module.zig index 85d7f4c5a08cdbea811a4ceda6b613d72f55f99a..42048948d1abd5479c2edd72185ed548965527d0 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -11,8 +11,6 @@ const common = @import("./../common.zig"); // pub const Module = struct { - is_sys_lib: bool, - is_framework: bool, type: zigmod.Dep.Type, id: string, name: string, @@ -40,8 +38,6 @@ pub const Module = struct { } } return Module{ - .is_sys_lib = false, - .is_framework = false, .type = dep.type, .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48), .name = dep.name, @@ -120,7 +116,7 @@ pub const Module = struct { pub fn has_syslib_deps(self: Module) bool { for (self.deps) |d| { - if (d.is_sys_lib) { + if (d.type == .system_lib) { return true; } } @@ -129,7 +125,7 @@ pub const Module = struct { pub fn has_framework_deps(self: Module) bool { for (self.deps) |d| { - if (d.is_framework) { + if (d.type == .framework) { return true; } } -- 2.54.0