From 810f25e254135fcb1b666f7acb982b05d08ce946 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sun, 31 Jan 2021 11:58:36 -0800 Subject: [PATCH] update to zig 0.8.0-dev.1071+fdc875ed0 --- .circleci/config.yml | 2 +- build.zig | 4 ++-- build_all_zig.sh | 2 +- src/cmd_add.zig | 2 +- src/cmd_fetch.zig | 44 ++++++++++++++++++++++---------------------- src/cmd_init.zig | 8 ++++---- src/cmd_sum.zig | 2 +- src/common.zig | 2 +- src/main.zig | 6 +++--- src/util/funcs.zig | 10 +++++----- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index a1feb850170ff2e00f6226e090d1847289c74513..8a849283707072dac0e7a71caa8194599f63e5f3 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -15,7 +15,7 @@ jobs: - run: git submodule update --init --recursive - run: apt -y install xz-utils jq - - run: ./download_zig.sh 0.7.1 + - run: ./download_zig.sh 0.8.0-dev.1071+fdc875ed0 - run: zig version - run: zig env - run: ./build_all_zig.sh diff --git a/build.zig b/build.zig index 3db0363056a81cfade2b1d90f4d0041e565ba63e..bb493ccb7f400ad6ad04b47d65d7c12bbe4445f4 100644 --- a/build.zig +++ b/build.zig @@ -9,8 +9,8 @@ pub fn build(b: *Builder) void { const mode = b.standardReleaseOptions(); const use_full_name = b.option(bool, "use-full-name", "") orelse false; - const with_arch_os = b.fmt("-{}-{}", .{@tagName(target.cpu_arch orelse builtin.arch), @tagName(target.os_tag orelse builtin.os.tag)}); - const exe_name = b.fmt("{}{}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); + const with_arch_os = b.fmt("-{s}-{s}", .{@tagName(target.cpu_arch orelse builtin.arch), @tagName(target.os_tag orelse builtin.os.tag)}); + const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" }); const exe = b.addExecutable(exe_name, "src/main.zig"); exe.setTarget(target); diff --git a/build_all_zig.sh b/build_all_zig.sh index d8c8049c90a1eba27e953ba82f8bc938ab193799..674f660b1239bd9e17d35260dcd0c4fa583adad1 100755 --- a/build_all_zig.sh +++ b/build_all_zig.sh @@ -19,5 +19,5 @@ x86_64-macos-gnu for item in $targets do echo "$tag-$item" - zig build -Dtarget=$item -Drelease -Duse-full-name -Dtag=$tag + zig build -Dtarget=$item -Duse-full-name -Dtag=$tag done diff --git a/src/cmd_add.zig b/src/cmd_add.zig index d8493d498e3879ece6ac79d1141b859550c59ebc..bc342f8ed4cae0d4745f9ed7e78442c552707172 100644 --- a/src/cmd_add.zig +++ b/src/cmd_add.zig @@ -51,5 +51,5 @@ pub fn execute(args: [][]u8) !void { try w.print(" path: {}\n", .{d.path}); } - u.print("Successfully added {}", .{path}); + u.print("Successfully added {s}", .{path}); } diff --git a/src/cmd_fetch.zig b/src/cmd_fetch.zig index d41c93d978f7b82e0d15780a506d52730418e735..94e1e1350986ee873237cbc07adbe31b75ea9474 100644 --- a/src/cmd_fetch.zig +++ b/src/cmd_fetch.zig @@ -22,9 +22,9 @@ pub fn execute(args: [][]u8) !void { try w.writeAll("const std = @import(\"std\");\n"); try w.writeAll("const build = std.build;\n"); try w.writeAll("\n"); - try w.print("const cache = \"{Z}\";\n", .{dir}); + try w.print("const cache = \"{s}\";\n", .{std.zig.fmtEscapes(dir)}); try w.writeAll("\n"); - try w.print("{}\n", .{ + try w.print("{s}\n", .{ \\pub fn addAllTo(exe: *build.LibExeObjStep) void { \\ @setEvalBranchQuota(1_000_000); \\ for (packages) |pkg| { @@ -57,7 +57,7 @@ pub fn execute(args: [][]u8) !void { try print_ids(w, list.items); try w.writeAll("};\n\n"); - try w.print("pub const _paths = {}\n", .{".{"}); + try w.print("pub const _paths = {s}\n", .{".{"}); try print_paths(w, list.items); try w.writeAll("};\n\n"); @@ -103,7 +103,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { for (m.deps) |d| { const p = try fs.path.join(gpa, &[_][]const u8{dir, try d.clean_path()}); const pv = try fs.path.join(gpa, &[_][]const u8{dir, try d.clean_path_v()}); - u.print("fetch: {}: {}: {}", .{m.name, @tagName(d.type), d.path}); + u.print("fetch: {s}: {s}: {s}", .{m.name, @tagName(d.type), d.path}); moddir = p; switch (d.type) { .system_lib => { @@ -121,7 +121,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { error.IterEmpty => unreachable, error.NoMemberFound => { const vtype = d.version[0..std.mem.indexOf(u8, d.version, "-").?]; - u.assert(false, "fetch: git: version type '{}' is invalid.", .{vtype}); + u.assert(false, "fetch: git: version type '{s}' is invalid.", .{vtype}); unreachable; }, }; @@ -133,7 +133,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { break :blk; } if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", vers.string})) > 0) { - u.assert(false, "fetch: git: {}: {} {} does not exist", .{d.path, @tagName(vers.id), vers.string}); + u.assert(false, "fetch: git: {s}: {s} {s} does not exist", .{d.path, @tagName(vers.id), vers.string}); } else { _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"}); } @@ -169,7 +169,7 @@ fn fetch_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { break :blk; } try u.rm_recv(pv); - u.assert(false, "{} does not match hash {}", .{d.path, d.version}); + u.assert(false, "{s} does not match hash {s}", .{d.path, d.version}); break :blk; } if (try u.does_folder_exist(p)) { @@ -244,7 +244,7 @@ fn print_ids(w: fs.File.Writer, list: []u.Module) !void { if (mod.is_sys_lib) { continue; } - try w.print(" \"{}\",\n", .{mod.id}); + try w.print(" \"{s}\",\n", .{mod.id}); } } @@ -257,7 +257,7 @@ fn print_paths(w: fs.File.Writer, list: []u.Module) !void { try w.print(" \"\",\n", .{}); } else { const s = std.fs.path.sep_str; - try w.print(" \"{Z}{Z}{Z}\",\n", .{s, mod.clean_path, s}); + try w.print(" \"{s}{s}{s}\",\n", .{std.zig.fmtEscapes(s), std.zig.fmtEscapes(mod.clean_path), std.zig.fmtEscapes(s)}); } } } @@ -279,13 +279,13 @@ fn print_deps(w: fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32, array: continue; } if (!array) { - try w.print(" pub const {} = packages[{}];\n", .{std.mem.replaceOwned(u8, gpa, d.name, "-", "_"), i}); + try w.print(" pub const {s} = packages[{}];\n", .{std.mem.replaceOwned(u8, gpa, d.name, "-", "_"), i}); } else { - try w.print(" package_data._{},\n", .{d.id}); + try w.print(" package_data._{s},\n", .{d.id}); } } - try w.print("{}", .{try u.concat(&[_][]const u8{r,"}"})}); + try w.print("{s}", .{try u.concat(&[_][]const u8{r,"}"})}); } fn print_incl_dirs_to(w: fs.File.Writer, list: []u.Module) !void { @@ -295,9 +295,9 @@ fn print_incl_dirs_to(w: fs.File.Writer, list: []u.Module) !void { } for (mod.c_include_dirs) |it| { if (i > 0) { - try w.print(" cache ++ _paths[{}] ++ \"{Z}\",\n", .{i, it}); + try w.print(" cache ++ _paths[{}] ++ \"{s}\",\n", .{i, std.zig.fmtEscapes(it)}); } else { - try w.print(" \"{Z}\",\n", .{it}); + try w.print(" \"{s}\",\n", .{std.zig.fmtEscapes(it)}); } } } @@ -310,9 +310,9 @@ fn print_csrc_dirs_to(w: fs.File.Writer, list: []u.Module) !void { } for (mod.c_source_files) |it| { if (i > 0) { - try w.print(" {}_ids[{}], cache ++ _paths[{}] ++ \"{}\"{},\n", .{"[_][]const u8{", i, i, it, "}"}); + try w.print(" {s}_ids[{}], cache ++ _paths[{}] ++ \"{s}\"{s},\n", .{"[_][]const u8{", i, i, it, "}"}); } else { - try w.print(" {}_ids[{}], \".{}/{}\"{},\n", .{"[_][]const u8{", i, mod.clean_path, it, "}"}); + try w.print(" {s}_ids[{}], \".{s}/{s}\"{s},\n", .{"[_][]const u8{", i, std.zig.fmtEscapes(mod.clean_path), it, "}"}); } } } @@ -323,11 +323,11 @@ fn print_csrc_flags_to(w: fs.File.Writer, list: []u.Module) !void { if (mod.is_sys_lib) { continue; } - try w.print(" pub const @\"{}\" = {}", .{mod.id, "&[_][]const u8{"}); + try w.print(" pub const @\"{s}\" = {s}", .{mod.id, "&[_][]const u8{"}); for (mod.c_source_flags) |it| { - try w.print("\"{Z}\",", .{it}); + try w.print("\"{s}\",", .{std.zig.fmtEscapes(it)}); } - try w.print("{};\n", .{"}"}); + try w.print("{s};\n", .{"}"}); } } @@ -337,7 +337,7 @@ fn print_sys_libs_to(w: fs.File.Writer, list: []u.Module, list2: *std.ArrayList( if (!mod.is_sys_lib) { continue; } - try w.print(" \"{}\",\n", .{mod.name}); + try w.print(" \"{s}\",\n", .{mod.name}); } } @@ -357,10 +357,10 @@ fn print_pkg_data_to(w: fs.File.Writer, list: *std.ArrayList(u.Module), list2: * while (i < list.items.len) : (i += 1) { const mod = list.items[i]; if (contains_all(mod.deps, list2)) { - try w.print(" pub const _{} = build.Pkg{{ .name = \"{}\", .path = cache ++ \"/{Z}/{}\", .dependencies = &[_]build.Pkg{{", .{mod.id, mod.name, mod.clean_path, mod.main}); + try w.print(" pub const _{s} = build.Pkg{{ .name = \"{s}\", .path = cache ++ \"/{s}/{s}\", .dependencies = &[_]build.Pkg{{", .{mod.id, mod.name, std.zig.fmtEscapes(mod.clean_path), mod.main}); for (mod.deps) |d| { if (d.main.len > 0) { - try w.print(" _{},", .{d.id}); + try w.print(" _{s},", .{d.id}); } } try w.print(" }} }};\n", .{}); diff --git a/src/cmd_init.zig b/src/cmd_init.zig index b6c3dda1541406f7091f1f826a33fb45cb3609da..213abc9fe113a80b4ab89f503dbafaaef2e450bc 100644 --- a/src/cmd_init.zig +++ b/src/cmd_init.zig @@ -14,12 +14,12 @@ pub fn execute(args: [][]u8) !void { defer file.close(); const fwriter = file.writer(); - try fwriter.print("id: {}\n", .{u.random_string(48)}); - try fwriter.print("name: {}\n", .{name}); - try fwriter.print("main: {}\n", .{mainf}); + try fwriter.print("id: {s}\n", .{u.random_string(48)}); + try fwriter.print("name: {s}\n", .{name}); + try fwriter.print("main: {s}\n", .{mainf}); try fwriter.print("dependencies:\n", .{}); - u.print("Initialized a new package named {} with entry point {}", .{name, mainf}); + u.print("Initialized a new package named {s} with entry point {s}", .{name, mainf}); } fn detect_pkgname(def: []const u8) ![]const u8 { diff --git a/src/cmd_sum.zig b/src/cmd_sum.zig index 31e28419efd39817fc324727bb5fcec0698aab84..08174c36d0a4281ee29442b69419a349c6184173 100644 --- a/src/cmd_sum.zig +++ b/src/cmd_sum.zig @@ -25,7 +25,7 @@ pub fn execute(args: [][]u8) !void { for (module_list.items) |m| { const hash = try m.get_hash(dir); - try w.print("{} {}\n", .{hash, m.clean_path}); + try w.print("{s} {s}\n", .{hash, m.clean_path}); } } diff --git a/src/common.zig b/src/common.zig index 76cdf3be0651cfd554e72d94e32ae7a22e499719..0b5da2bced65e248f969c514e4f44f28205f63f0 100644 --- a/src/common.zig +++ b/src/common.zig @@ -17,7 +17,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8) anyerror!u.Module { if (try u.does_file_exist(pv)) { moddir = pv; } else { - u.assert(try u.does_file_exist(p), "unable to find dep: {} {}, please run zigmod fetch", .{d.path, d.version}); + u.assert(try u.does_file_exist(p), "unable to find dep: {s} {s}, please run zigmod fetch", .{d.path, d.version}); moddir = p; } switch (d.type) { diff --git a/src/main.zig b/src/main.zig index 6cd85e74b466c5a4b8844a5ba436fcef1abba3c6..50ef6b82a82b7a076ad99d0e1fa44f95948b38b7 100644 --- a/src/main.zig +++ b/src/main.zig @@ -21,7 +21,7 @@ pub fn main() !void { const args = proc_args[1..]; if (args.len == 0) { - u.print("zigmod {} {} {} {}", .{ + u.print("zigmod {s} {s} {s} {s}", .{ @import("build_options").version, @tagName(builtin.os.tag), @tagName(builtin.arch), @@ -39,14 +39,14 @@ pub fn main() !void { } var sub_cmd_args = &std.ArrayList([]const u8).init(gpa); - try sub_cmd_args.append(try std.fmt.allocPrint(gpa, "zigmod-{}", .{args[0]})); + try sub_cmd_args.append(try std.fmt.allocPrint(gpa, "zigmod-{s}", .{args[0]})); for (args[1..]) |item| { try sub_cmd_args.append(item); } const result = std.ChildProcess.exec(.{ .allocator = gpa, .argv = sub_cmd_args.items, }) catch |e| switch(e) { else => return e, error.FileNotFound => { - u.assert(false, "unknown command \"{}\" for \"zigmod\"", .{args[0]}); + u.assert(false, "unknown command \"{s}\" for \"zigmod\"", .{args[0]}); unreachable; }, }; diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 6267909f297b1c4bfa69ed998c90202f336e81bb..81d929c5c42e52f1cf4300bc13af565e3f84d7bf 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -98,7 +98,7 @@ pub fn repeat(s: []const u8, times: i32) ![]const u8 { pub fn join(xs: [][]const u8, delim: []const u8) ![]const u8 { var res: []const u8 = ""; for (xs) |x, i| { - res = try std.fmt.allocPrint(gpa, "{}{}{}", .{res, x, if (i < xs.len-1) delim else ""}); + res = try std.fmt.allocPrint(gpa, "{s}{s}{s}", .{res, x, if (i < xs.len-1) delim else ""}); } return res; } @@ -106,7 +106,7 @@ pub fn join(xs: [][]const u8, delim: []const u8) ![]const u8 { pub fn concat(items: [][]const u8) ![]const u8 { var buf: []const u8 = ""; for (items) |x| { - buf = try std.fmt.allocPrint(gpa, "{}{}", .{buf, x}); + buf = try std.fmt.allocPrint(gpa, "{s}{s}", .{buf, x}); } return buf; } @@ -114,9 +114,9 @@ pub fn concat(items: [][]const u8) ![]const u8 { pub fn print_all(w: std.fs.File.Writer, items: anytype, ln: bool) !void { inline for (items) |x, i| { if (i == 0) { - try w.print("{}", .{x}); + try w.print("{s}", .{x}); } else { - try w.print(" {}", .{x}); + try w.print(" {s}", .{x}); } } if (ln) { @@ -160,7 +160,7 @@ pub fn file_list(dpath: []const u8, list: *std.ArrayList([]const u8)) !void { pub fn run_cmd(dir: ?[]const u8, args: []const []const u8) !u32 { const result = std.ChildProcess.exec(.{ .allocator = gpa, .cwd = dir, .argv = args, }) catch |e| switch(e) { error.FileNotFound => { - u.assert(false, "\"{}\" command not found", .{args[0]}); + u.assert(false, "\"{s}\" command not found", .{args[0]}); unreachable; }, else => return e, -- 2.54.0