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
1717
1818pub fn execute(args: [][]u8) !void {
1919 //
20 const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
20 const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" });
2121 const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update"));
2222
2323 var options = common.CollectOptions{
2424 .log = should_update,
2525 .update = should_update,
2626 };
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
2929 var list = std.ArrayList(u.Module).init(gpa);
3030 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
3434 if (bootstrap) return;
3535
36 try create_lockfile(&list, dir);
36 try create_lockfile(&list, cachepath);
3737
3838 try diff_lockfile();
3939}
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 {
4242 const f = try std.fs.cwd().createFile("deps.zig", .{});
4343 defer f.close();
4444
......@@ -47,7 +47,7 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.
4747 try w.writeAll("const Pkg = std.build.Pkg;\n");
4848 try w.writeAll("const string = []const u8;\n");
4949 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)});
5151 try w.writeAll("\n");
5252 try w.print("{s}\n", .{
5353 \\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.
111111 try w.writeAll(";\n\n");
112112
113113 try w.writeAll("pub const imports = struct {\n");
114 try print_imports(w, top_module, dir);
114 try print_imports(w, top_module, cachepath);
115115 try w.writeAll("};\n");
116116}
117117
118fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void {
118fn create_lockfile(list: *std.ArrayList(u.Module), path: string) !void {
119119 const fl = try std.fs.cwd().createFile("zigmod.lock", .{});
120120 defer fl.close();
121121
......@@ -127,7 +127,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void {
127127 continue;
128128 }
129129 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 });
131131 const version = try md.exact_version(mpath);
132132 try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version });
133133 }
......@@ -350,13 +350,13 @@ fn print_pkgs(w: std.fs.File.Writer, m: u.Module) !void {
350350 try w.writeAll("}");
351351}
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 {
354354 for (m.deps) |d| {
355355 if (d.main.len == 0) {
356356 continue;
357357 }
358358 const r1 = try std.mem.replaceOwned(u8, gpa, d.name, "-", "_");
359359 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 });
361361 }
362362}
src/cmd/license.zig+2-2
......@@ -17,13 +17,13 @@ const Map = std.StringArrayHashMap(*List);
1717pub fn execute(args: [][]u8) !void {
1818 _ = 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
2222 var options = common.CollectOptions{
2323 .log = false,
2424 .update = false,
2525 };
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
2828 const master_list = &List.init(gpa);
2929 try common.collect_pkgs(top_module, master_list);
src/cmd/sum.zig+3-3
......@@ -10,13 +10,13 @@ const common = @import("./../common.zig");
1010pub fn execute(args: [][]u8) !void {
1111 _ = 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
1515 var options = common.CollectOptions{
1616 .log = false,
1717 .update = false,
1818 };
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
2121 //
2222 const f = try std.fs.cwd().createFile("zigmod.sum", .{});
......@@ -35,7 +35,7 @@ pub fn execute(args: [][]u8) !void {
3535 continue;
3636 }
3737 if (m.is_sys_lib) continue;
38 const hash = try m.get_hash(dir);
38 const hash = try m.get_hash(cachepath);
3939 try w.print("{s} {s}\n", .{ hash, m.clean_path });
4040 }
4141}