From bf4cc92d981de56b75bf6005cc66dea32d9d7eba Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Fri, 20 Aug 2021 22:04:59 -0700 Subject: [PATCH] cmd- more consistent names --- src/cmd/fetch.zig | 22 +++++++++++----------- src/cmd/license.zig | 4 ++-- src/cmd/sum.zig | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index 8c75534e5f99eb56aae13afd43adb68613dafe63..101b5d3d666d7836e60484a1edfa8fa405e022d0 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -17,28 +17,28 @@ const bootstrap = if (@hasDecl(build_options, "bootstrap")) build_options.bootst pub fn execute(args: [][]u8) !void { // - const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); + const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); const should_update = !(args.len >= 1 and std.mem.eql(u8, args[0], "--no-update")); var options = common.CollectOptions{ .log = should_update, .update = should_update, }; - const top_module = try common.collect_deps_deep(dir, "zig.mod", &options); + const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); var list = std.ArrayList(u.Module).init(gpa); try common.collect_pkgs(top_module, &list); - try create_depszig(dir, top_module, &list); + try create_depszig(cachepath, top_module, &list); if (bootstrap) return; - try create_lockfile(&list, dir); + try create_lockfile(&list, cachepath); try diff_lockfile(); } -pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u.Module)) !void { +pub fn create_depszig(cachepath: string, top_module: u.Module, list: *std.ArrayList(u.Module)) !void { const f = try std.fs.cwd().createFile("deps.zig", .{}); defer f.close(); @@ -47,7 +47,7 @@ pub fn create_depszig(dir: string, top_module: u.Module, list: *std.ArrayList(u. try w.writeAll("const Pkg = std.build.Pkg;\n"); try w.writeAll("const string = []const u8;\n"); try w.writeAll("\n"); - try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(dir)}); + try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)}); try w.writeAll("\n"); try w.print("{s}\n", .{ \\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. try w.writeAll(";\n\n"); try w.writeAll("pub const imports = struct {\n"); - try print_imports(w, top_module, dir); + try print_imports(w, top_module, cachepath); try w.writeAll("};\n"); } -fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void { +fn create_lockfile(list: *std.ArrayList(u.Module), path: string) !void { const fl = try std.fs.cwd().createFile("zigmod.lock", .{}); defer fl.close(); @@ -127,7 +127,7 @@ fn create_lockfile(list: *std.ArrayList(u.Module), dir: string) !void { continue; } if (md.type == .system_lib) continue; - const mpath = try std.fs.path.join(gpa, &.{ dir, m.clean_path }); + const mpath = try std.fs.path.join(gpa, &.{ path, m.clean_path }); const version = try md.exact_version(mpath); try wl.print("{s} {s} {s}\n", .{ @tagName(md.type), md.path, version }); } @@ -350,13 +350,13 @@ fn print_pkgs(w: std.fs.File.Writer, m: u.Module) !void { try w.writeAll("}"); } -fn print_imports(w: std.fs.File.Writer, m: u.Module, dir: string) !void { +fn print_imports(w: std.fs.File.Writer, m: u.Module, path: string) !void { for (m.deps) |d| { if (d.main.len == 0) { continue; } const r1 = try std.mem.replaceOwned(u8, gpa, d.name, "-", "_"); const r2 = try std.mem.replaceOwned(u8, gpa, r1, "/", "_"); - try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ r2, std.zig.fmtEscapes(dir), std.zig.fmtEscapes(d.clean_path), d.main }); + try w.print(" pub const {s} = @import(\"{}/{}/{s}\");\n", .{ r2, std.zig.fmtEscapes(path), std.zig.fmtEscapes(d.clean_path), d.main }); } } diff --git a/src/cmd/license.zig b/src/cmd/license.zig index 61f9314aa9e8b40a84c3d4bb85c76f2a4a2652c5..01bea77c2bf6a5957bdab9f2de0cad05fa3190b1 100644 --- a/src/cmd/license.zig +++ b/src/cmd/license.zig @@ -17,13 +17,13 @@ const Map = std.StringArrayHashMap(*List); pub fn execute(args: [][]u8) !void { _ = args; - const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); + const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); var options = common.CollectOptions{ .log = false, .update = false, }; - const top_module = try common.collect_deps_deep(dir, "zig.mod", &options); + const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); const master_list = &List.init(gpa); try common.collect_pkgs(top_module, master_list); diff --git a/src/cmd/sum.zig b/src/cmd/sum.zig index 1ed5ff14ae7177a90f252e9dca794206e04c104c..242817dda5c6fd4b23908f14d41c9ff5f19e3c5a 100644 --- a/src/cmd/sum.zig +++ b/src/cmd/sum.zig @@ -10,13 +10,13 @@ const common = @import("./../common.zig"); pub fn execute(args: [][]u8) !void { _ = args; - const dir = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); + const cachepath = try std.fs.path.join(gpa, &.{ ".zigmod", "deps" }); var options = common.CollectOptions{ .log = false, .update = false, }; - const top_module = try common.collect_deps_deep(dir, "zig.mod", &options); + const top_module = try common.collect_deps_deep(cachepath, "zig.mod", &options); // const f = try std.fs.cwd().createFile("zigmod.sum", .{}); @@ -35,7 +35,7 @@ pub fn execute(args: [][]u8) !void { continue; } if (m.is_sys_lib) continue; - const hash = try m.get_hash(dir); + const hash = try m.get_hash(cachepath); try w.print("{s} {s}\n", .{ hash, m.clean_path }); } } -- 2.54.0