authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-07 18:39:21 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-07 18:39:21 -07:00
log752137bf1b5b820dfbb29f835071a37f9e235d54
treebd39a93f9f68d38049293e519345160b86221e50
parentf41cde3e423d1df8f74115d64f74e7233af83d42

patch fix for system_lib handling and root props


4 files changed, 20 insertions(+), 6 deletions(-)

src/cmd/fetch.zig+9-6
......@@ -83,7 +83,7 @@ pub fn create_depszig(dir: []const u8, top_module: u.Module, list: *std.ArrayLis
8383 try w.writeAll("pub const package_data = struct {\n");
8484 const duped = &std.ArrayList(u.Module).init(gpa);
8585 for (list.items) |mod| {
86 if (std.mem.eql(u8, mod.id, "root")) {
86 if (mod.is_sys_lib) {
8787 continue;
8888 }
8989 try duped.append(mod);
......@@ -115,6 +115,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
115115 if (md.type == .local) {
116116 continue;
117117 }
118 if (md.type == .system_lib) continue;
118119 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });
119120 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath));
120121 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });
......@@ -124,10 +125,12 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
124125
125126fn print_dirs(w: std.fs.File.Writer, list: []const u.Module) !void {
126127 for (list) |mod| {
128 if (mod.is_sys_lib) continue;
127129 if (std.mem.eql(u8, mod.id, "root")) {
130 try w.print(" pub const _root = \"\";\n", .{});
128131 continue;
129132 }
130 try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.id[0..12], std.zig.fmtEscapes(mod.clean_path) });
133 try w.print(" pub const _{s} = cache ++ \"/{}\";\n", .{ mod.short_id(), std.zig.fmtEscapes(mod.clean_path) });
131134 }
132135}
133136
......@@ -151,14 +154,14 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d
151154 \\ pub const _{s} = Package{{
152155 \\
153156 , .{
154 mod.id[0..12],
157 mod.short_id(),
155158 });
156 if (mod.main.len > 0) {
159 if (mod.main.len > 0 and !std.mem.eql(u8, mod.id, "root")) {
157160 try w.print(
158161 \\ .pkg = Pkg{{ .name = "{s}", .path = .{{ .path = dirs._{s} ++ "/{s}" }}, .dependencies =
159162 , .{
160163 mod.name,
161 mod.id[0..12],
164 mod.short_id(),
162165 mod.main,
163166 });
164167 if (mod.has_no_zig_deps()) {
......@@ -200,7 +203,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d
200203 if (mod.has_syslib_deps()) {
201204 try w.writeAll(" .system_libs = &.{");
202205 for (mod.deps) |item, j| {
203 if (!mod.is_sys_lib) continue;
206 if (!item.is_sys_lib) continue;
204207 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
205208 if (j != mod.deps.len - 1) try w.writeAll(",");
206209 }
src/cmd/sum.zig+1
......@@ -36,6 +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) continue;
3940 const hash = try m.get_hash(dir);
4041 try w.print("{s} {s}\n", .{ hash, m.clean_path });
4142 }
src/util/funcs.zig+6
......@@ -259,3 +259,9 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 {
259259 const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");
260260 return r;
261261}
262
263pub fn slice(comptime T: type, input: []const T, from: usize, to: usize) []const T {
264 const f = std.math.max(from, 0);
265 const t = std.math.min(to, input.len);
266 return input[f..t];
267}
src/util/module.zig+4
......@@ -116,4 +116,8 @@ pub const Module = struct {
116116 }
117117 return false;
118118 }
119
120 pub fn short_id(self: Module) []const u8 {
121 return u.slice(u8, self.id, 0, 12);
122 }
119123};