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...@@ -116,7 +116,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D
116 try w.writeAll("pub const package_data = struct {\n");116 try w.writeAll("pub const package_data = struct {\n");
117 var duped = std.ArrayList(zigmod.Module).init(alloc);117 var duped = std.ArrayList(zigmod.Module).init(alloc);
118 for (list.items) |mod| {118 for (list.items) |mod| {
119 if (mod.is_sys_lib or mod.is_framework) {119 if (mod.type == .system_lib or mod.type == .framework) {
120 continue;120 continue;
121 }121 }
122 try duped.append(mod);122 try duped.append(mod);
...@@ -249,7 +249,7 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item:...@@ -249,7 +249,7 @@ fn diff_printchange(comptime testt: string, comptime replacement: string, item:
249249
250fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void {250fn print_dirs(w: std.fs.File.Writer, list: []const zigmod.Module) !void {
251 for (list) |mod| {251 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;
253 if (std.mem.eql(u8, mod.id, "root")) {253 if (std.mem.eql(u8, mod.id, "root")) {
254 try w.writeAll(" pub const _root = \"\";\n");254 try w.writeAll(" pub const _root = \"\";\n");
255 continue;255 continue;
...@@ -332,7 +332,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul...@@ -332,7 +332,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
332 if (mod.has_syslib_deps()) {332 if (mod.has_syslib_deps()) {
333 try w.writeAll(" .system_libs = &.{");333 try w.writeAll(" .system_libs = &.{");
334 for (mod.deps) |item, j| {334 for (mod.deps) |item, j| {
335 if (!item.is_sys_lib) continue;335 if (!(item.type == .system_lib)) continue;
336 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});336 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
337 if (j != mod.deps.len - 1) try w.writeAll(",");337 if (j != mod.deps.len - 1) try w.writeAll(",");
338 }338 }
...@@ -341,7 +341,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul...@@ -341,7 +341,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(zigmod.Modul
341 if (mod.has_framework_deps()) {341 if (mod.has_framework_deps()) {
342 try w.writeAll(" .frameworks = &.{");342 try w.writeAll(" .frameworks = &.{");
343 for (mod.deps) |item, j| {343 for (mod.deps) |item, j| {
344 if (!item.is_sys_lib) continue;344 if (!(item.type == .system_lib)) continue;
345 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});345 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
346 if (j != mod.deps.len - 1) try w.writeAll(",");346 if (j != mod.deps.len - 1) try w.writeAll(",");
347 }347 }
src/cmd/sum.zig+1-1
...@@ -36,7 +36,7 @@ pub fn execute(args: [][]u8) !void {...@@ -36,7 +36,7 @@ pub fn execute(args: [][]u8) !void {
36 if (std.mem.eql(u8, m.clean_path, "../..")) {36 if (std.mem.eql(u8, m.clean_path, "../..")) {
37 continue;37 continue;
38 }38 }
39 if (m.is_sys_lib or m.is_framework) continue;39 if (m.type.isLocal()) continue;
40 const hash = try m.get_hash(gpa, cachepath);40 const hash = try m.get_hash(gpa, cachepath);
41 try w.print("{s} {s}\n", .{ hash, m.clean_path });41 try w.print("{s} {s}\n", .{ hash, m.clean_path });
42 }42 }
src/common.zig-6
...@@ -48,8 +48,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO...@@ -48,8 +48,6 @@ pub fn collect_deps_deep(cachepath: string, mdir: std.fs.Dir, options: *CollectO
48 }48 }
49 }49 }
50 return zigmod.Module{50 return zigmod.Module{
51 .is_sys_lib = false,
52 .is_framework = false,
53 .type = .local,51 .type = .local,
54 .id = "root",52 .id = "root",
55 .name = "root",53 .name = "root",
...@@ -78,8 +76,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption...@@ -78,8 +76,6 @@ pub fn collect_deps(cachepath: string, mdir: std.fs.Dir, options: *CollectOption
78 }76 }
79 }77 }
80 return zigmod.Module{78 return zigmod.Module{
81 .is_sys_lib = false,
82 .is_framework = false,
83 .type = .local,79 .type = .local,
84 .id = m.id,80 .id = m.id,
85 .name = m.name,81 .name = m.name,
...@@ -231,8 +227,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO...@@ -231,8 +227,6 @@ pub fn get_module_from_dep(d: *zigmod.Dep, cachepath: string, options: *CollectO
231 switch (d.type) {227 switch (d.type) {
232 .system_lib, .framework => {228 .system_lib, .framework => {
233 return zigmod.Module{229 return zigmod.Module{
234 .is_sys_lib = d.type == .system_lib,
235 .is_framework = d.type == .framework,
236 .type = d.type,230 .type = d.type,
237 .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path),231 .id = try u.do_hash(options.alloc, std.crypto.hash.sha3.Sha3_384, d.path),
238 .name = d.path,232 .name = d.path,
src/util/module.zig+2-6
...@@ -11,8 +11,6 @@ const common = @import("./../common.zig");...@@ -11,8 +11,6 @@ const common = @import("./../common.zig");
11//11//
1212
13pub const Module = struct {13pub const Module = struct {
14 is_sys_lib: bool,
15 is_framework: bool,
16 type: zigmod.Dep.Type,14 type: zigmod.Dep.Type,
17 id: string,15 id: string,
18 name: string,16 name: string,
...@@ -40,8 +38,6 @@ pub const Module = struct {...@@ -40,8 +38,6 @@ pub const Module = struct {
40 }38 }
41 }39 }
42 return Module{40 return Module{
43 .is_sys_lib = false,
44 .is_framework = false,
45 .type = dep.type,41 .type = dep.type,
46 .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48),42 .id = if (dep.id.len > 0) dep.id else try u.random_string(alloc, 48),
47 .name = dep.name,43 .name = dep.name,
...@@ -120,7 +116,7 @@ pub const Module = struct {...@@ -120,7 +116,7 @@ pub const Module = struct {
120116
121 pub fn has_syslib_deps(self: Module) bool {117 pub fn has_syslib_deps(self: Module) bool {
122 for (self.deps) |d| {118 for (self.deps) |d| {
123 if (d.is_sys_lib) {119 if (d.type == .system_lib) {
124 return true;120 return true;
125 }121 }
126 }122 }
...@@ -129,7 +125,7 @@ pub const Module = struct {...@@ -129,7 +125,7 @@ pub const Module = struct {
129125
130 pub fn has_framework_deps(self: Module) bool {126 pub fn has_framework_deps(self: Module) bool {
131 for (self.deps) |d| {127 for (self.deps) |d| {
132 if (d.is_framework) {128 if (d.type == .framework) {
133 return true;129 return true;
134 }130 }
135 }131 }