diff --git a/build.zig b/build.zig index 25359c6a01b05be2694104e389397023b92ff891..ea39be94f36738ee7331d49c33f0b26a9f89a68f 100644 --- a/build.zig +++ b/build.zig @@ -24,7 +24,7 @@ pub fn build(b: *Builder) void { exe.linkLibC(); exe.addIncludeDir("./libs/yaml/include"); - exe.addCSourceFile("./libs/yaml/src/api.c", &[_][]const u8{ + exe.addCSourceFile("./libs/yaml/src/api.c", &.{ // taken from https://github.com/yaml/libyaml/blob/0.2.5/CMakeLists.txt#L5-L8 "-DYAML_VERSION_MAJOR=0", "-DYAML_VERSION_MINOR=2", @@ -32,13 +32,13 @@ pub fn build(b: *Builder) void { "-DYAML_VERSION_STRING=\"0.2.5\"", "-DYAML_DECLARE_STATIC=1", }); - exe.addCSourceFile("./libs/yaml/src/dumper.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/emitter.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/loader.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/parser.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/reader.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/scanner.c", &[_][]const u8{}); - exe.addCSourceFile("./libs/yaml/src/writer.c", &[_][]const u8{}); + exe.addCSourceFile("./libs/yaml/src/dumper.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/emitter.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/loader.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/parser.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/reader.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/scanner.c", &.{}); + exe.addCSourceFile("./libs/yaml/src/writer.c", &.{}); exe.addPackagePath("ansi", "./libs/zig-ansi/src/lib.zig"); } diff --git a/deps.zig b/deps.zig index a1673e1165a8d77c3bb4d7555fe829e4d4223e8f..4e83134bc29dd49679df7a905893b49013400d50 100644 --- a/deps.zig +++ b/deps.zig @@ -75,13 +75,15 @@ pub const c_include_dirs = &[_][]const u8{ }; pub const c_source_flags = struct { - pub const @"89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r" = &[_][]const u8{}; - pub const @"8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc" = &[_][]const u8{"-DYAML_VERSION_MAJOR=0","-DYAML_VERSION_MINOR=2","-DYAML_VERSION_PATCH=5","-DYAML_VERSION_STRING=\"0.2.5\"","-DYAML_DECLARE_STATIC=1",}; - pub const @"s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h" = &[_][]const u8{}; - pub const @"2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf" = &[_][]const u8{}; - pub const @"2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o" = &[_][]const u8{}; - pub const @"csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe" = &[_][]const u8{}; - pub const @"0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r" = &[_][]const u8{}; + pub const @"89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r" = &.{}; + pub const @"8mdbh0zuneb0i3hs5jby5je0heem1i6yxusl7c8y8qx68hqc" = &.{"-DYAML_VERSION_MAJOR=0","-DYAML_VERSION_MINOR=2","-DYAML_VERSION_PATCH=5","-DYAML_VERSION_STRING=\"0.2.5\"","-DYAML_DECLARE_STATIC=1",}; + pub const @"s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h" = &.{}; + pub const @"2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf" = &.{}; + pub const @"2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o" = &.{}; + pub const @"csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe" = &.{}; + pub const @"0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r" = &.{}; + pub const @"aoe2l16htluewam6bfwvv0khsbbno8g8jd7suonifg74u7kd" = &.{}; + pub const @"icwsahmjjop2lcplra9m76n7oyganb81qismvfrsmv0iisxs" = &.{}; }; pub const c_source_files = &[_][2][]const u8{ diff --git a/src/cmd/license.zig b/src/cmd/license.zig index c8369ad9312e29d12df3c9a77990e09c68540e68..35f72776a30476cd0aa04739130696e1746a3cd0 100644 --- a/src/cmd/license.zig +++ b/src/cmd/license.zig @@ -18,7 +18,7 @@ const Map = std.StringArrayHashMap(*List); pub fn execute(args: [][]u8) !void { // - const dir = try std.fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"}); + const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"}); const top_module = try common.collect_deps(dir, "zig.mod", .{ .log = false, diff --git a/src/cmd_fetch.zig b/src/cmd_fetch.zig index a808efe156fb178fde867249f884ac51c6c5b8b2..738f8afca4fc57e7c1fb8e9aad1c5444c0b34e82 100644 --- a/src/cmd_fetch.zig +++ b/src/cmd_fetch.zig @@ -11,7 +11,7 @@ const common = @import("./common.zig"); pub fn execute(args: [][]u8) !void { // - const dir = try fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"}); + const dir = try fs.path.join(gpa, &.{".zigmod", "deps"}); const top_module = try common.collect_deps(dir, "zig.mod", .{ .log = true, @@ -146,7 +146,7 @@ fn print_deps(w: fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32, array: try w.print(" package_data._{s},\n", .{d.id}); } } - try w.print("{s}", .{try u.concat(&[_][]const u8{r,"}"})}); + try w.print("{s}", .{try u.concat(&.{r,"}"})}); } fn print_incl_dirs_to(w: fs.File.Writer, list: []u.Module) !void { @@ -184,7 +184,7 @@ fn print_csrc_flags_to(w: fs.File.Writer, list: []u.Module) !void { if (mod.is_sys_lib) { continue; } - try w.print(" pub const @\"{s}\" = {s}", .{mod.id, "&[_][]const u8{"}); + try w.print(" pub const @\"{s}\" = {s}", .{mod.id, "&.{"}); for (mod.c_source_flags) |it| { try w.print("\"{s}\",", .{std.zig.fmtEscapes(it)}); } diff --git a/src/cmd_init.zig b/src/cmd_init.zig index 213abc9fe113a80b4ab89f503dbafaaef2e450bc..536451134fff37afa7191886ad9b8658789bc545 100644 --- a/src/cmd_init.zig +++ b/src/cmd_init.zig @@ -42,10 +42,10 @@ fn detct_mainfile(def: []const u8) ![]const u8 { } } } - if (try u.does_file_exist(try std.fs.path.join(gpa, &[_][]const u8{"src", "lib.zig"}))) { + if (try u.does_file_exist(try std.fs.path.join(gpa, &.{"src", "lib.zig"}))) { return "src/lib.zig"; } - if (try u.does_file_exist(try std.fs.path.join(gpa, &[_][]const u8{"src", "main.zig"}))) { + if (try u.does_file_exist(try std.fs.path.join(gpa, &.{"src", "main.zig"}))) { return "src/main.zig"; } u.assert(false, "unable to detect package entry point", .{}); diff --git a/src/cmd_sum.zig b/src/cmd_sum.zig index 2ca1af7e0ffff4fdb566f07ddfc8a95dc3440f18..3b06fe0706ac9b545df02aa2033402a81f9fa2eb 100644 --- a/src/cmd_sum.zig +++ b/src/cmd_sum.zig @@ -10,7 +10,7 @@ const common = @import("./common.zig"); pub fn execute(args: [][]u8) !void { // - const dir = try std.fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"}); + const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"}); const top_module = try common.collect_deps(dir, "zig.mod", .{ .log = false, diff --git a/src/common.zig b/src/common.zig index b3c06ad8e78c5b3ac5e1fca1a176caa58e7f5656..dcba4a6c45282fe316259d8cc9e4fcf0456a4c46 100644 --- a/src/common.zig +++ b/src/common.zig @@ -17,8 +17,8 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec const moduledeps = &std.ArrayList(u.Module).init(gpa); var moddir: []const u8 = undefined; 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()}); + const p = try fs.path.join(gpa, &.{dir, try d.clean_path()}); + const pv = try fs.path.join(gpa, &.{dir, try d.clean_path_v()}); if (options.log) { u.print("fetch: {s}: {s}: {s}", .{m.name, @tagName(d.type), d.path}); } moddir = p; switch (d.type) { @@ -48,13 +48,13 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec moddir = pv; break :blk; } - if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", vers.string})) > 0) { + if ((try u.run_cmd(p, &.{"git", "checkout", vers.string})) > 0) { 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", "-"}); + _ = try u.run_cmd(p, &.{"git", "checkout", "-"}); } try d.type.pull(d.path, pv); - _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", vers.string}); + _ = try u.run_cmd(pv, &.{"git", "checkout", vers.string}); if (vers.id != .branch) { const pvd = try std.fs.cwd().openDir(pv, .{}); try pvd.deleteTree(".git"); @@ -77,7 +77,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec } const file_name = try u.last(try u.split(d.path, "/")); if (d.version.len > 0) { - const file_path = try std.fs.path.join(gpa, &[_][]const u8{pv, file_name}); + const file_path = try std.fs.path.join(gpa, &.{pv, file_name}); try d.type.pull(d.path, pv); if (try u.validate_hash(try u.last(try u.split(pv, "/")), file_path)) { try std.fs.deleteFileAbsolute(file_path); @@ -91,7 +91,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec if (try u.does_folder_exist(p)) { try u.rm_recv(p); } - const file_path = try std.fs.path.join(gpa, &[_][]const u8{p, file_name}); + const file_path = try std.fs.path.join(gpa, &.{p, file_name}); try d.type.pull(d.path, p); try std.fs.deleteFileAbsolute(file_path); }, @@ -105,16 +105,16 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec .only_os = d.only_os, .except_os = d.except_os, .main = "", - .c_include_dirs = &[_][]const u8{}, - .c_source_flags = &[_][]const u8{}, - .c_source_files = &[_][]const u8{}, + .c_include_dirs = &.{}, + .c_source_flags = &.{}, + .c_source_files = &.{}, .deps = &[_]u.Module{}, .clean_path = d.path, .yaml = null, }); }, else => blk: { - var dd = try collect_deps(dir, try u.concat(&[_][]const u8{moddir, "/zig.mod"}), options) catch |e| switch (e) { + var dd = try collect_deps(dir, try u.concat(&.{moddir, "/zig.mod"}), options) catch |e| switch (e) { error.FileNotFound => { if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) { var mod_from = try u.Module.from(d); @@ -151,8 +151,8 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec .c_source_files = m.c_source_files, .deps = moduledeps.items, .clean_path = "", - .only_os = &[_][]const u8{}, - .except_os = &[_][]const u8{}, + .only_os = &.{}, + .except_os = &.{}, .yaml = m.yaml, }; } diff --git a/src/util/dep.zig b/src/util/dep.zig index a1a7ad00c35403e25ae9b07c40c3699cc9e0ec58..4d3b814e404dd2ba6e422bdb589a727cb0d9a2b6 100644 --- a/src/util/dep.zig +++ b/src/util/dep.zig @@ -29,15 +29,15 @@ pub const Dep = struct { p = u.trim_prefix(p, "https://"); p = u.trim_prefix(p, "git://"); p = u.trim_suffix(u8, p, ".git"); - p = try std.mem.join(gpa, "/", &[_][]const u8{@tagName(self.type), p}); + p = try std.mem.join(gpa, "/", &.{@tagName(self.type), p}); return p; } pub fn clean_path_v(self: Dep) ![]const u8 { if (self.type == .http and self.version.len > 0) { - return std.mem.join(gpa, "/", &[_][]const u8{"v", @tagName(self.type), self.version}); + return std.mem.join(gpa, "/", &.{"v", @tagName(self.type), self.version}); } - return std.mem.join(gpa, "/", &[_][]const u8{"v", try self.clean_path(), self.version}); + return std.mem.join(gpa, "/", &.{"v", try self.clean_path(), self.version}); } pub fn is_for_this(self: Dep) bool { diff --git a/src/util/dep_type.zig b/src/util/dep_type.zig index 30f9f2eb900f290ae30cee1efa3013017ca4f1b7..9552926ac2b23aeb552708983202d03448bc2e04 100644 --- a/src/util/dep_type.zig +++ b/src/util/dep_type.zig @@ -16,17 +16,17 @@ pub const DepType = enum { switch (self) { .system_lib => {}, .git => { - _ = try u.run_cmd(null, &[_][]const u8{"git", "clone", "--recurse-submodules", rpath, dpath}); + _ = try u.run_cmd(null, &.{"git", "clone", "--recurse-submodules", rpath, dpath}); }, .hg => { - _ = try u.run_cmd(null, &[_][]const u8{"hg", "clone", rpath, dpath}); + _ = try u.run_cmd(null, &.{"hg", "clone", rpath, dpath}); }, .http => { try u.mkdir_all(dpath); - _ = try u.run_cmd(dpath, &[_][]const u8{"wget", rpath}); + _ = try u.run_cmd(dpath, &.{"wget", rpath}); const f = rpath[std.mem.lastIndexOf(u8, rpath, "/").?+1..]; if (std.mem.endsWith(u8, f, ".zip")) { - _ = try u.run_cmd(dpath, &[_][]const u8{"unzip", f, "-d", "."}); + _ = try u.run_cmd(dpath, &.{"unzip", f, "-d", "."}); } if ( std.mem.endsWith(u8, f, ".tar") @@ -34,7 +34,7 @@ pub const DepType = enum { or std.mem.endsWith(u8, f, ".tar.xz") or std.mem.endsWith(u8, f, ".tar.zst") ) { - _ = try u.run_cmd(dpath, &[_][]const u8{"tar", "-xf", f, "-C", "."}); + _ = try u.run_cmd(dpath, &.{"tar", "-xf", f, "-C", "."}); } }, } @@ -44,11 +44,11 @@ pub const DepType = enum { switch (self) { .system_lib => {}, .git => { - _ = try u.run_cmd(dpath, &[_][]const u8{"git", "fetch"}); - _ = try u.run_cmd(dpath, &[_][]const u8{"git", "pull"}); + _ = try u.run_cmd(dpath, &.{"git", "fetch"}); + _ = try u.run_cmd(dpath, &.{"git", "pull"}); }, .hg => { - _ = try u.run_cmd(dpath, &[_][]const u8{"hg", "pull"}); + _ = try u.run_cmd(dpath, &.{"hg", "pull"}); }, .http => { // diff --git a/src/util/funcs.zig b/src/util/funcs.zig index 81d929c5c42e52f1cf4300bc13af565e3f84d7bf..a5a89903f8555a1a8ec434ced82540323bff50da 100644 --- a/src/util/funcs.zig +++ b/src/util/funcs.zig @@ -210,7 +210,7 @@ pub fn rm_recv(path: []const u8) anyerror!void { const dir = std.fs.cwd().openDir(abs_path, .{ .iterate=true, }) catch unreachable; var iter = dir.iterate(); while (try iter.next()) |item| { - try rm_recv(try std.fs.path.join(gpa, &[_][]const u8{abs_path, item.name})); + try rm_recv(try std.fs.path.join(gpa, &.{abs_path, item.name})); } try std.fs.deleteDirAbsolute(abs_path); } diff --git a/src/util/module.zig b/src/util/module.zig index d9a48d6e381b17b9be8ac9b5e357d7c919db7afe..d0039f7780f6dab933236fa0902400ac597cfa13 100644 --- a/src/util/module.zig +++ b/src/util/module.zig @@ -46,7 +46,7 @@ pub const Module = struct { pub fn get_hash(self: Module, cdpath: []const u8) ![]const u8 { const file_list_1 = &std.ArrayList([]const u8).init(gpa); - try u.file_list(try u.concat(&[_][]const u8{cdpath, "/", self.clean_path}), file_list_1); + try u.file_list(try u.concat(&.{cdpath, "/", self.clean_path}), file_list_1); const file_list_2 = &std.ArrayList([]const u8).init(gpa); for (file_list_1.items) |item| { @@ -64,7 +64,7 @@ pub const Module = struct { const h = &std.crypto.hash.Blake3.init(.{}); for (file_list_2.items) |item| { - const abs_path = try u.concat(&[_][]const u8{cdpath, "/", self.clean_path, "/", item}); + const abs_path = try u.concat(&.{cdpath, "/", self.clean_path, "/", item}); const file = try std.fs.cwd().openFile(abs_path, .{}); defer file.close(); const input = try file.reader().readAllAlloc(gpa, u.mb*100);