authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-02-20 18:48:13 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2021-02-20 18:48:13 -08:00
log345ff6f14e0cf40ddcf2fb6ec9634d868f55acb5
tree7d2e522de9a68d8e042df848ca21231ecf78d5be
parent28b2b44a90ac0e37fbaf991d5e85e85b597a8205

array literals can infer type


11 files changed, 51 insertions(+), 49 deletions(-)

build.zig+8-8
......@@ -24,7 +24,7 @@ pub fn build(b: *Builder) void {
2424 exe.linkLibC();
2525
2626 exe.addIncludeDir("./libs/yaml/include");
27 exe.addCSourceFile("./libs/yaml/src/api.c", &[_][]const u8{
27 exe.addCSourceFile("./libs/yaml/src/api.c", &.{
2828 // taken from https://github.com/yaml/libyaml/blob/0.2.5/CMakeLists.txt#L5-L8
2929 "-DYAML_VERSION_MAJOR=0",
3030 "-DYAML_VERSION_MINOR=2",
......@@ -32,13 +32,13 @@ pub fn build(b: *Builder) void {
3232 "-DYAML_VERSION_STRING=\"0.2.5\"",
3333 "-DYAML_DECLARE_STATIC=1",
3434 });
35 exe.addCSourceFile("./libs/yaml/src/dumper.c", &[_][]const u8{});
36 exe.addCSourceFile("./libs/yaml/src/emitter.c", &[_][]const u8{});
37 exe.addCSourceFile("./libs/yaml/src/loader.c", &[_][]const u8{});
38 exe.addCSourceFile("./libs/yaml/src/parser.c", &[_][]const u8{});
39 exe.addCSourceFile("./libs/yaml/src/reader.c", &[_][]const u8{});
40 exe.addCSourceFile("./libs/yaml/src/scanner.c", &[_][]const u8{});
41 exe.addCSourceFile("./libs/yaml/src/writer.c", &[_][]const u8{});
35 exe.addCSourceFile("./libs/yaml/src/dumper.c", &.{});
36 exe.addCSourceFile("./libs/yaml/src/emitter.c", &.{});
37 exe.addCSourceFile("./libs/yaml/src/loader.c", &.{});
38 exe.addCSourceFile("./libs/yaml/src/parser.c", &.{});
39 exe.addCSourceFile("./libs/yaml/src/reader.c", &.{});
40 exe.addCSourceFile("./libs/yaml/src/scanner.c", &.{});
41 exe.addCSourceFile("./libs/yaml/src/writer.c", &.{});
4242
4343 exe.addPackagePath("ansi", "./libs/zig-ansi/src/lib.zig");
4444 }
deps.zig+9-7
......@@ -75,13 +75,15 @@ pub const c_include_dirs = &[_][]const u8{
7575};
7676
7777pub const c_source_flags = struct {
78 pub const @"89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r" = &[_][]const u8{};
79 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",};
80 pub const @"s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h" = &[_][]const u8{};
81 pub const @"2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf" = &[_][]const u8{};
82 pub const @"2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o" = &[_][]const u8{};
83 pub const @"csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe" = &[_][]const u8{};
84 pub const @"0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r" = &[_][]const u8{};
78 pub const @"89ujp8gq842x6mzok8feypwze138n2d96zpugw44hcq7406r" = &.{};
79 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",};
80 pub const @"s84v9o48ucb0xq0cmzq0cn433hgw0iaqztugja16h8bzxu3h" = &.{};
81 pub const @"2ta738wrqbaqzl3iwzoo8nj35k9ynwz5p5iyz80ryrpp4ttf" = &.{};
82 pub const @"2b7mq571jmq31ktmpigopu29480iw245heueajgxzxn7ab8o" = &.{};
83 pub const @"csbnipaad8n77buaszsnjvlmn6j173fl7pkprsctelswjywe" = &.{};
84 pub const @"0npcrzfdlrvkf44mzjo8bduj9gmqyefo0j3rstt6b0pm2r6r" = &.{};
85 pub const @"aoe2l16htluewam6bfwvv0khsbbno8g8jd7suonifg74u7kd" = &.{};
86 pub const @"icwsahmjjop2lcplra9m76n7oyganb81qismvfrsmv0iisxs" = &.{};
8587};
8688
8789pub const c_source_files = &[_][2][]const u8{
src/cmd/license.zig+1-1
......@@ -18,7 +18,7 @@ const Map = std.StringArrayHashMap(*List);
1818
1919pub fn execute(args: [][]u8) !void {
2020 //
21 const dir = try std.fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"});
21 const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"});
2222
2323 const top_module = try common.collect_deps(dir, "zig.mod", .{
2424 .log = false,
src/cmd_fetch.zig+3-3
......@@ -11,7 +11,7 @@ const common = @import("./common.zig");
1111
1212pub fn execute(args: [][]u8) !void {
1313 //
14 const dir = try fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"});
14 const dir = try fs.path.join(gpa, &.{".zigmod", "deps"});
1515
1616 const top_module = try common.collect_deps(dir, "zig.mod", .{
1717 .log = true,
......@@ -146,7 +146,7 @@ fn print_deps(w: fs.File.Writer, dir: []const u8, m: u.Module, tabs: i32, array:
146146 try w.print(" package_data._{s},\n", .{d.id});
147147 }
148148 }
149 try w.print("{s}", .{try u.concat(&[_][]const u8{r,"}"})});
149 try w.print("{s}", .{try u.concat(&.{r,"}"})});
150150}
151151
152152fn 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 {
184184 if (mod.is_sys_lib) {
185185 continue;
186186 }
187 try w.print(" pub const @\"{s}\" = {s}", .{mod.id, "&[_][]const u8{"});
187 try w.print(" pub const @\"{s}\" = {s}", .{mod.id, "&.{"});
188188 for (mod.c_source_flags) |it| {
189189 try w.print("\"{s}\",", .{std.zig.fmtEscapes(it)});
190190 }
src/cmd_init.zig+2-2
......@@ -42,10 +42,10 @@ fn detct_mainfile(def: []const u8) ![]const u8 {
4242 }
4343 }
4444 }
45 if (try u.does_file_exist(try std.fs.path.join(gpa, &[_][]const u8{"src", "lib.zig"}))) {
45 if (try u.does_file_exist(try std.fs.path.join(gpa, &.{"src", "lib.zig"}))) {
4646 return "src/lib.zig";
4747 }
48 if (try u.does_file_exist(try std.fs.path.join(gpa, &[_][]const u8{"src", "main.zig"}))) {
48 if (try u.does_file_exist(try std.fs.path.join(gpa, &.{"src", "main.zig"}))) {
4949 return "src/main.zig";
5050 }
5151 u.assert(false, "unable to detect package entry point", .{});
src/cmd_sum.zig+1-1
......@@ -10,7 +10,7 @@ const common = @import("./common.zig");
1010
1111pub fn execute(args: [][]u8) !void {
1212 //
13 const dir = try std.fs.path.join(gpa, &[_][]const u8{".zigmod", "deps"});
13 const dir = try std.fs.path.join(gpa, &.{".zigmod", "deps"});
1414
1515 const top_module = try common.collect_deps(dir, "zig.mod", .{
1616 .log = false,
src/common.zig+13-13
......@@ -17,8 +17,8 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec
1717 const moduledeps = &std.ArrayList(u.Module).init(gpa);
1818 var moddir: []const u8 = undefined;
1919 for (m.deps) |d| {
20 const p = try fs.path.join(gpa, &[_][]const u8{dir, try d.clean_path()});
21 const pv = try fs.path.join(gpa, &[_][]const u8{dir, try d.clean_path_v()});
20 const p = try fs.path.join(gpa, &.{dir, try d.clean_path()});
21 const pv = try fs.path.join(gpa, &.{dir, try d.clean_path_v()});
2222 if (options.log) { u.print("fetch: {s}: {s}: {s}", .{m.name, @tagName(d.type), d.path}); }
2323 moddir = p;
2424 switch (d.type) {
......@@ -48,13 +48,13 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec
4848 moddir = pv;
4949 break :blk;
5050 }
51 if ((try u.run_cmd(p, &[_][]const u8{"git", "checkout", vers.string})) > 0) {
51 if ((try u.run_cmd(p, &.{"git", "checkout", vers.string})) > 0) {
5252 u.assert(false, "fetch: git: {s}: {s} {s} does not exist", .{d.path, @tagName(vers.id), vers.string});
5353 } else {
54 _ = try u.run_cmd(p, &[_][]const u8{"git", "checkout", "-"});
54 _ = try u.run_cmd(p, &.{"git", "checkout", "-"});
5555 }
5656 try d.type.pull(d.path, pv);
57 _ = try u.run_cmd(pv, &[_][]const u8{"git", "checkout", vers.string});
57 _ = try u.run_cmd(pv, &.{"git", "checkout", vers.string});
5858 if (vers.id != .branch) {
5959 const pvd = try std.fs.cwd().openDir(pv, .{});
6060 try pvd.deleteTree(".git");
......@@ -77,7 +77,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec
7777 }
7878 const file_name = try u.last(try u.split(d.path, "/"));
7979 if (d.version.len > 0) {
80 const file_path = try std.fs.path.join(gpa, &[_][]const u8{pv, file_name});
80 const file_path = try std.fs.path.join(gpa, &.{pv, file_name});
8181 try d.type.pull(d.path, pv);
8282 if (try u.validate_hash(try u.last(try u.split(pv, "/")), file_path)) {
8383 try std.fs.deleteFileAbsolute(file_path);
......@@ -91,7 +91,7 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec
9191 if (try u.does_folder_exist(p)) {
9292 try u.rm_recv(p);
9393 }
94 const file_path = try std.fs.path.join(gpa, &[_][]const u8{p, file_name});
94 const file_path = try std.fs.path.join(gpa, &.{p, file_name});
9595 try d.type.pull(d.path, p);
9696 try std.fs.deleteFileAbsolute(file_path);
9797 },
......@@ -105,16 +105,16 @@ pub fn collect_deps(dir: []const u8, mpath: []const u8, comptime options: Collec
105105 .only_os = d.only_os,
106106 .except_os = d.except_os,
107107 .main = "",
108 .c_include_dirs = &[_][]const u8{},
109 .c_source_flags = &[_][]const u8{},
110 .c_source_files = &[_][]const u8{},
108 .c_include_dirs = &.{},
109 .c_source_flags = &.{},
110 .c_source_files = &.{},
111111 .deps = &[_]u.Module{},
112112 .clean_path = d.path,
113113 .yaml = null,
114114 });
115115 },
116116 else => blk: {
117 var dd = try collect_deps(dir, try u.concat(&[_][]const u8{moddir, "/zig.mod"}), options) catch |e| switch (e) {
117 var dd = try collect_deps(dir, try u.concat(&.{moddir, "/zig.mod"}), options) catch |e| switch (e) {
118118 error.FileNotFound => {
119119 if (d.main.len > 0 or d.c_include_dirs.len > 0 or d.c_source_files.len > 0) {
120120 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
151151 .c_source_files = m.c_source_files,
152152 .deps = moduledeps.items,
153153 .clean_path = "",
154 .only_os = &[_][]const u8{},
155 .except_os = &[_][]const u8{},
154 .only_os = &.{},
155 .except_os = &.{},
156156 .yaml = m.yaml,
157157 };
158158}
src/util/dep.zig+3-3
......@@ -29,15 +29,15 @@ pub const Dep = struct {
2929 p = u.trim_prefix(p, "https://");
3030 p = u.trim_prefix(p, "git://");
3131 p = u.trim_suffix(u8, p, ".git");
32 p = try std.mem.join(gpa, "/", &[_][]const u8{@tagName(self.type), p});
32 p = try std.mem.join(gpa, "/", &.{@tagName(self.type), p});
3333 return p;
3434 }
3535
3636 pub fn clean_path_v(self: Dep) ![]const u8 {
3737 if (self.type == .http and self.version.len > 0) {
38 return std.mem.join(gpa, "/", &[_][]const u8{"v", @tagName(self.type), self.version});
38 return std.mem.join(gpa, "/", &.{"v", @tagName(self.type), self.version});
3939 }
40 return std.mem.join(gpa, "/", &[_][]const u8{"v", try self.clean_path(), self.version});
40 return std.mem.join(gpa, "/", &.{"v", try self.clean_path(), self.version});
4141 }
4242
4343 pub fn is_for_this(self: Dep) bool {
src/util/dep_type.zig+8-8
......@@ -16,17 +16,17 @@ pub const DepType = enum {
1616 switch (self) {
1717 .system_lib => {},
1818 .git => {
19 _ = try u.run_cmd(null, &[_][]const u8{"git", "clone", "--recurse-submodules", rpath, dpath});
19 _ = try u.run_cmd(null, &.{"git", "clone", "--recurse-submodules", rpath, dpath});
2020 },
2121 .hg => {
22 _ = try u.run_cmd(null, &[_][]const u8{"hg", "clone", rpath, dpath});
22 _ = try u.run_cmd(null, &.{"hg", "clone", rpath, dpath});
2323 },
2424 .http => {
2525 try u.mkdir_all(dpath);
26 _ = try u.run_cmd(dpath, &[_][]const u8{"wget", rpath});
26 _ = try u.run_cmd(dpath, &.{"wget", rpath});
2727 const f = rpath[std.mem.lastIndexOf(u8, rpath, "/").?+1..];
2828 if (std.mem.endsWith(u8, f, ".zip")) {
29 _ = try u.run_cmd(dpath, &[_][]const u8{"unzip", f, "-d", "."});
29 _ = try u.run_cmd(dpath, &.{"unzip", f, "-d", "."});
3030 }
3131 if (
3232 std.mem.endsWith(u8, f, ".tar")
......@@ -34,7 +34,7 @@ pub const DepType = enum {
3434 or std.mem.endsWith(u8, f, ".tar.xz")
3535 or std.mem.endsWith(u8, f, ".tar.zst")
3636 ) {
37 _ = try u.run_cmd(dpath, &[_][]const u8{"tar", "-xf", f, "-C", "."});
37 _ = try u.run_cmd(dpath, &.{"tar", "-xf", f, "-C", "."});
3838 }
3939 },
4040 }
......@@ -44,11 +44,11 @@ pub const DepType = enum {
4444 switch (self) {
4545 .system_lib => {},
4646 .git => {
47 _ = try u.run_cmd(dpath, &[_][]const u8{"git", "fetch"});
48 _ = try u.run_cmd(dpath, &[_][]const u8{"git", "pull"});
47 _ = try u.run_cmd(dpath, &.{"git", "fetch"});
48 _ = try u.run_cmd(dpath, &.{"git", "pull"});
4949 },
5050 .hg => {
51 _ = try u.run_cmd(dpath, &[_][]const u8{"hg", "pull"});
51 _ = try u.run_cmd(dpath, &.{"hg", "pull"});
5252 },
5353 .http => {
5454 //
src/util/funcs.zig+1-1
......@@ -210,7 +210,7 @@ pub fn rm_recv(path: []const u8) anyerror!void {
210210 const dir = std.fs.cwd().openDir(abs_path, .{ .iterate=true, }) catch unreachable;
211211 var iter = dir.iterate();
212212 while (try iter.next()) |item| {
213 try rm_recv(try std.fs.path.join(gpa, &[_][]const u8{abs_path, item.name}));
213 try rm_recv(try std.fs.path.join(gpa, &.{abs_path, item.name}));
214214 }
215215 try std.fs.deleteDirAbsolute(abs_path);
216216 }
src/util/module.zig+2-2
......@@ -46,7 +46,7 @@ pub const Module = struct {
4646
4747 pub fn get_hash(self: Module, cdpath: []const u8) ![]const u8 {
4848 const file_list_1 = &std.ArrayList([]const u8).init(gpa);
49 try u.file_list(try u.concat(&[_][]const u8{cdpath, "/", self.clean_path}), file_list_1);
49 try u.file_list(try u.concat(&.{cdpath, "/", self.clean_path}), file_list_1);
5050
5151 const file_list_2 = &std.ArrayList([]const u8).init(gpa);
5252 for (file_list_1.items) |item| {
......@@ -64,7 +64,7 @@ pub const Module = struct {
6464
6565 const h = &std.crypto.hash.Blake3.init(.{});
6666 for (file_list_2.items) |item| {
67 const abs_path = try u.concat(&[_][]const u8{cdpath, "/", self.clean_path, "/", item});
67 const abs_path = try u.concat(&.{cdpath, "/", self.clean_path, "/", item});
6868 const file = try std.fs.cwd().openFile(abs_path, .{});
6969 defer file.close();
7070 const input = try file.reader().readAllAlloc(gpa, u.mb*100);