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...@@ -83,7 +83,7 @@ pub fn create_depszig(dir: []const u8, top_module: u.Module, list: *std.ArrayLis
83 try w.writeAll("pub const package_data = struct {\n");83 try w.writeAll("pub const package_data = struct {\n");
84 const duped = &std.ArrayList(u.Module).init(gpa);84 const duped = &std.ArrayList(u.Module).init(gpa);
85 for (list.items) |mod| {85 for (list.items) |mod| {
86 if (std.mem.eql(u8, mod.id, "root")) {86 if (mod.is_sys_lib) {
87 continue;87 continue;
88 }88 }
89 try duped.append(mod);89 try duped.append(mod);
...@@ -115,6 +115,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {...@@ -115,6 +115,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
115 if (md.type == .local) {115 if (md.type == .local) {
116 continue;116 continue;
117 }117 }
118 if (md.type == .system_lib) continue;
118 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });119 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });
119 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath));120 const version = if (md.version.len > 0) md.version else (try md.type.exact_version(mpath));
120 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });121 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 {...@@ -124,10 +125,12 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {
124125
125fn print_dirs(w: std.fs.File.Writer, list: []const u.Module) !void {126fn print_dirs(w: std.fs.File.Writer, list: []const u.Module) !void {
126 for (list) |mod| {127 for (list) |mod| {
128 if (mod.is_sys_lib) continue;
127 if (std.mem.eql(u8, mod.id, "root")) {129 if (std.mem.eql(u8, mod.id, "root")) {
130 try w.print(" pub const _root = \"\";\n", .{});
128 continue;131 continue;
129 }132 }
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) });
131 }134 }
132}135}
133136
...@@ -151,14 +154,14 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d...@@ -151,14 +154,14 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d
151 \\ pub const _{s} = Package{{154 \\ pub const _{s} = Package{{
152 \\155 \\
153 , .{156 , .{
154 mod.id[0..12],157 mod.short_id(),
155 });158 });
156 if (mod.main.len > 0) {159 if (mod.main.len > 0 and !std.mem.eql(u8, mod.id, "root")) {
157 try w.print(160 try w.print(
158 \\ .pkg = Pkg{{ .name = "{s}", .path = .{{ .path = dirs._{s} ++ "/{s}" }}, .dependencies =161 \\ .pkg = Pkg{{ .name = "{s}", .path = .{{ .path = dirs._{s} ++ "/{s}" }}, .dependencies =
159 , .{162 , .{
160 mod.name,163 mod.name,
161 mod.id[0..12],164 mod.short_id(),
162 mod.main,165 mod.main,
163 });166 });
164 if (mod.has_no_zig_deps()) {167 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...@@ -200,7 +203,7 @@ fn print_pkg_data_to(w: std.fs.File.Writer, notdone: *std.ArrayList(u.Module), d
200 if (mod.has_syslib_deps()) {203 if (mod.has_syslib_deps()) {
201 try w.writeAll(" .system_libs = &.{");204 try w.writeAll(" .system_libs = &.{");
202 for (mod.deps) |item, j| {205 for (mod.deps) |item, j| {
203 if (!mod.is_sys_lib) continue;206 if (!item.is_sys_lib) continue;
204 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});207 try w.print(" \"{}\"", .{std.zig.fmtEscapes(item.name)});
205 if (j != mod.deps.len - 1) try w.writeAll(",");208 if (j != mod.deps.len - 1) try w.writeAll(",");
206 }209 }
src/cmd/sum.zig+1
...@@ -36,6 +36,7 @@ pub fn execute(args: [][]u8) !void {...@@ -36,6 +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) continue;
39 const hash = try m.get_hash(dir);40 const hash = try m.get_hash(dir);
40 try w.print("{s} {s}\n", .{ hash, m.clean_path });41 try w.print("{s} {s}\n", .{ hash, m.clean_path });
41 }42 }
src/util/funcs.zig+6
...@@ -259,3 +259,9 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 {...@@ -259,3 +259,9 @@ pub fn git_rev_HEAD(alloc: *std.mem.Allocator, path: []const u8) ![]const u8 {
259 const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");259 const r = std.mem.trim(u8, try dirg.readFileAlloc(alloc, h[5..], max), "\n");
260 return r;260 return r;
261}261}
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 {...@@ -116,4 +116,8 @@ pub const Module = struct {
116 }116 }
117 return false;117 return false;
118 }118 }
119
120 pub fn short_id(self: Module) []const u8 {
121 return u.slice(u8, self.id, 0, 12);
122 }
119};123};