authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-05 17:37:41 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-07-05 17:37:41 -07:00
log1b963fe00dbd657b570c8a6a099d8c8feb91f2ff
tree1cf8fdcdd9ba450cd4ab46d1818284153e76a2f1
parent43fc40b5c14a5892344eeffbadb0d8faef209150

cmd/fetch- put `deps.zig` generation into a function


1 files changed, 9 insertions(+), 8 deletions(-)

src/cmd/fetch.zig+9-8
...@@ -19,7 +19,15 @@ pub fn execute(args: [][]u8) !void {...@@ -19,7 +19,15 @@ pub fn execute(args: [][]u8) !void {
19 .update = should_update,19 .update = should_update,
20 });20 });
2121
22 //22 const list = &std.ArrayList(u.Module).init(gpa);
23 try common.collect_pkgs(top_module, list);
24
25 try create_depszig(dir, top_module, list);
26
27 try create_lockfile(list, dir);
28}
29
30pub fn create_depszig(dir: []const u8, top_module: u.Module, list: *std.ArrayList(u.Module)) !void {
23 const f = try std.fs.cwd().createFile("deps.zig", .{});31 const f = try std.fs.cwd().createFile("deps.zig", .{});
24 defer f.close();32 defer f.close();
2533
...@@ -56,9 +64,6 @@ pub fn execute(args: [][]u8) !void {...@@ -56,9 +64,6 @@ pub fn execute(args: [][]u8) !void {
56 \\64 \\
57 });65 });
5866
59 const list = &std.ArrayList(u.Module).init(gpa);
60 try common.collect_pkgs(top_module, list);
61
62 try w.writeAll("pub const _ids = .{\n");67 try w.writeAll("pub const _ids = .{\n");
63 try print_ids(w, list.items);68 try print_ids(w, list.items);
64 try w.writeAll("};\n\n");69 try w.writeAll("};\n\n");
...@@ -104,10 +109,6 @@ pub fn execute(args: [][]u8) !void {...@@ -104,10 +109,6 @@ pub fn execute(args: [][]u8) !void {
104 try w.writeAll("pub const system_libs = &[_][]const u8{\n");109 try w.writeAll("pub const system_libs = &[_][]const u8{\n");
105 try print_sys_libs_to(w, list.items, &std.ArrayList([]const u8).init(gpa));110 try print_sys_libs_to(w, list.items, &std.ArrayList([]const u8).init(gpa));
106 try w.writeAll("};\n\n");111 try w.writeAll("};\n\n");
107
108 //
109
110 try create_lockfile(list, dir);
111}112}
112113
113fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {114fn create_lockfile(list: *std.ArrayList(u.Module), dir: []const u8) !void {