authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 22:04:59 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-08-20 22:04:59 -07:00
logbf4cc92d981de56b75bf6005cc66dea32d9d7eba
tree9b7bae200f909a12d2ac4220c83264397a749ecf
parented543fcb3734d152e3ee18b36b18d9ec15680944

cmd- more consistent names


3 files changed, 16 insertions(+), 16 deletions(-)

src/cmd/fetch.zig+11-11
...@@ -17,28 +17,28 @@ const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootst...@@ -17,28 +17,28 @@ const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootst
1717
18pub fn execute(args: [][]u8) !void {18pub fn execute(args: [][]u8) !void {
19 //19 //
20 const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });20 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
21 const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update"));21 const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update"));
2222
23 var options = common.CollectOptions{23 var options = common.CollectOptions{
24 .log = should_update,24 .log = should_update,
25 .update = should_update,25 .update = should_update,
26 };26 };
27 const top_module = try common.collect_deps_deep(dir, "zig.mod", &options);27 const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options);
2828
29 var list = std.ArrayList(u.Module).init(gpa);29 var list = std.ArrayList(u.Module).init(gpa);
30 try common.collect_pkgs(top_module, &list);30 try common.collect_pkgs(top_module, &list);
3131
32 try create_depszig(dir, top_module, &list);32 try create_depszig(cachepath, top_module, &list);
3333
34 if (bootstrap) return;34 if (bootstrap) return;
3535
36 try create_lockfile(&list, dir);36 try create_lockfile(&list, cachepath);
3737
38 try diff_lockfile();38 try diff_lockfile();
39}39}
4040
41pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.Module)) !void {41pub fn create_depszig(cachepath: string, top_module: u.Module, list: *std.ArrayList(u.Module)) !void {
42 const f = try std.fs.cwd().createFile("deps.zig", .{});42 const f = try std.fs.cwd().createFile("deps.zig", .{});
43 defer f.close();43 defer f.close();
4444
...@@ -47,7 +47,7 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u....@@ -47,7 +47,7 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.
47 try w.writeAll("const Pkg = std.build.Pkg;\n");47 try w.writeAll("const Pkg = std.build.Pkg;\n");
48 try w.writeAll("const string = []const u8;\n");48 try w.writeAll("const string = []const u8;\n");
49 try w.writeAll("\n");49 try w.writeAll("\n");
50 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(dir)});50 try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)});
51 try w.writeAll("\n");51 try w.writeAll("\n");
52 try w.print("{s}\n", .{52 try w.print("{s}\n", .{
53 \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void {53 \\pub fn addAllTo(exe: *std.build.LibExeObjStep) void {
...@@ -111,11 +111,11 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u....@@ -111,11 +111,11 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.
111 try w.writeAll(";\n\n");111 try w.writeAll(";\n\n");
112112
113 try w.writeAll("pub const imports = struct {\n");113 try w.writeAll("pub const imports = struct {\n");
114 try print_imports(w, top_module, dir);114 try print_imports(w, top_module, cachepath);
115 try w.writeAll("};\n");115 try w.writeAll("};\n");
116}116}
117117
118fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void {118fn create_lockfile(list: *std.ArrayList(u.Module), path: string) !void {
119 const fl = try std.fs.cwd().createFile("zigmod.lock", .{});119 const fl = try std.fs.cwd().createFile("zigmod.lock", .{});
120 defer fl.close();120 defer fl.close();
121121
...@@ -127,7 +127,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void {...@@ -127,7 +127,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void {
127 continue;127 continue;
128 }128 }
129 if (md.type == .system_lib) continue;129 if (md.type == .system_lib) continue;
130 const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path });130 const mpath = try std.fs.path.join(gpa, &.{ path, m.clean_path });
131 const version = try md.exact_version(mpath);131 const version = try md.exact_version(mpath);
132 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });132 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });
133 }133 }
...@@ -350,13 +350,13 @@ fn print_pkgs(w: std.fs.File.Writer, m: u.Module) !void {...@@ -350,13 +350,13 @@ fn print_pkgs(w: std.fs.File.Writer, m: u.Module) !void {
350 try w.writeAll("}");350 try w.writeAll("}");
351}351}
352352
353fn print_imports(w: std.fs.File.Writer, m: u.Module, dir: string) !void {353fn print_imports(w: std.fs.File.Writer, m: u.Module, path: string) !void {
354 for (m.deps) |d| {354 for (m.deps) |d| {
355 if (d.main.len == 0) {355 if (d.main.len == 0) {
356 continue;356 continue;
357 }357 }
358 const r1 = try std.mem.replaceOwned(u8, gpa, d.name, "-", "_");358 const r1 = try std.mem.replaceOwned(u8, gpa, d.name, "-", "_");
359 const r2 = try std.mem.replaceOwned(u8, gpa, r1, "/", "_");359 const r2 = try std.mem.replaceOwned(u8, gpa, r1, "/", "_");
360 try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ r2, std.zig.fmtEscapes(dir), std.zig.fmtEscapes(d.clean_path), d.main });360 try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ r2, std.zig.fmtEscapes(path), std.zig.fmtEscapes(d.clean_path), d.main });
361 }361 }
362}362}
src/cmd/license.zig+2-2
...@@ -17,13 +17,13 @@ const Map = std.StringArrayHashMap(*List);...@@ -17,13 +17,13 @@ const Map = std.StringArrayHashMap(*List);
17pub fn execute(args: [][]u8) !void {17pub fn execute(args: [][]u8) !void {
18 _ = args;18 _ = args;
1919
20 const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });20 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
2121
22 var options = common.CollectOptions{22 var options = common.CollectOptions{
23 .log = false,23 .log = false,
24 .update = false,24 .update = false,
25 };25 };
26 const top_module = try common.collect_deps_deep(dir, "zig.mod", &options);26 const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options);
2727
28 const master_list = &List.init(gpa);28 const master_list = &List.init(gpa);
29 try common.collect_pkgs(top_module, master_list);29 try common.collect_pkgs(top_module, master_list);
src/cmd/sum.zig+3-3
...@@ -10,13 +10,13 @@ const common = @import("./../common.zig");...@@ -10,13 +10,13 @@ const common = @import("./../common.zig");
10pub fn execute(args: [][]u8) !void {10pub fn execute(args: [][]u8) !void {
11 _ = args;11 _ = args;
1212
13 const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });13 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
1414
15 var options = common.CollectOptions{15 var options = common.CollectOptions{
16 .log = false,16 .log = false,
17 .update = false,17 .update = false,
18 };18 };
19 const top_module = try common.collect_deps_deep(dir, "zig.mod", &options);19 const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options);
2020
21 //21 //
22 const f = try std.fs.cwd().createFile("zigmod.sum", .{});22 const f = try std.fs.cwd().createFile("zigmod.sum", .{});
...@@ -35,7 +35,7 @@ pub fn execute(args: [][]u8) !void {...@@ -35,7 +35,7 @@ pub fn execute(args: [][]u8) !void {
35 continue;35 continue;
36 }36 }
37 if (m.is_sys_lib) continue;37 if (m.is_sys_lib) continue;
38 const hash = try m.get_hash(dir);38 const hash = try m.get_hash(cachepath);
39 try w.print("{s} {s}\n", .{ hash, m.clean_path });39 try w.print("{s} {s}\n", .{ hash, m.clean_path });
40 }40 }
41}41}