| author | |
| committer | |
| log | 69c1dbc9ff9f5031f7262d6079b83285f5fc0c86 |
| tree | ae9f64d3910e9bb79ed4f5bf0334030ac09a4d67 |
| parent | 473c1d6fa5bea6dcb03151a304af645910826be8 |
21 files changed, 214 insertions(+), 398 deletions(-)
tools/docgen.zig+15-42| ... | ... | @@ -16,16 +16,17 @@ const max_doc_file_size = 10 * 1024 * 1024; |
| 16 | 16 | |
| 17 | 17 | const obj_ext = builtin.object_format.fileExt(builtin.cpu.arch); |
| 18 | 18 | |
| 19 | const usage = | |
| 20 | \\Usage: docgen [options] input output | |
| 21 | \\ | |
| 22 | \\ Generates an HTML document from a docgen template. | |
| 23 | \\ | |
| 24 | \\Options: | |
| 25 | \\ --code-dir dir Path to directory containing code example outputs | |
| 26 | \\ -h, --help Print this help and exit | |
| 27 | \\ | |
| 28 | ; | |
| 19 | const Args = struct { | |
| 20 | pub const description = "Generates an HTML document from a docgen template."; | |
| 21 | named: struct { | |
| 22 | @"code-dir": [:0]const u8, | |
| 23 | pub const @"code-dir_help" = "Path to directory containing code example outputs"; | |
| 24 | }, | |
| 25 | positional: struct { | |
| 26 | input: [:0]const u8, | |
| 27 | output: [:0]const u8, | |
| 28 | }, | |
| 29 | }; | |
| 29 | 30 | |
| 30 | 31 | pub fn main() !void { |
| 31 | 32 | var arena_instance = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| ... | ... | @@ -33,38 +34,10 @@ pub fn main() !void { |
| 33 | 34 | |
| 34 | 35 | const arena = arena_instance.allocator(); |
| 35 | 36 | |
| 36 | var args_it = try process.argsWithAllocator(arena); | |
| 37 | if (!args_it.skip()) @panic("expected self arg"); | |
| 38 | ||
| 39 | var opt_code_dir: ?[]const u8 = null; | |
| 40 | var opt_input: ?[]const u8 = null; | |
| 41 | var opt_output: ?[]const u8 = null; | |
| 42 | ||
| 43 | while (args_it.next()) |arg| { | |
| 44 | if (mem.startsWith(u8, arg, "-")) { | |
| 45 | if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) { | |
| 46 | try fs.File.stdout().writeAll(usage); | |
| 47 | process.exit(0); | |
| 48 | } else if (mem.eql(u8, arg, "--code-dir")) { | |
| 49 | if (args_it.next()) |param| { | |
| 50 | opt_code_dir = param; | |
| 51 | } else { | |
| 52 | fatal("expected parameter after --code-dir", .{}); | |
| 53 | } | |
| 54 | } else { | |
| 55 | fatal("unrecognized option: '{s}'", .{arg}); | |
| 56 | } | |
| 57 | } else if (opt_input == null) { | |
| 58 | opt_input = arg; | |
| 59 | } else if (opt_output == null) { | |
| 60 | opt_output = arg; | |
| 61 | } else { | |
| 62 | fatal("unexpected positional argument: '{s}'", .{arg}); | |
| 63 | } | |
| 64 | } | |
| 65 | const input_path = opt_input orelse fatal("missing input file", .{}); | |
| 66 | const output_path = opt_output orelse fatal("missing output file", .{}); | |
| 67 | const code_dir_path = opt_code_dir orelse fatal("missing --code-dir argument", .{}); | |
| 37 | const args = try std.cli.parse(Args, arena, .{}); | |
| 38 | const input_path = args.positional.input; | |
| 39 | const output_path = args.positional.output; | |
| 40 | const code_dir_path = args.named.@"code-dir"; | |
| 68 | 41 | |
| 69 | 42 | var in_file = try fs.cwd().openFile(input_path, .{}); |
| 70 | 43 | defer in_file.close(); |
tools/dump-cov.zig+9-3| ... | ... | @@ -16,9 +16,15 @@ pub fn main() !void { |
| 16 | 16 | defer arena_instance.deinit(); |
| 17 | 17 | const arena = arena_instance.allocator(); |
| 18 | 18 | |
| 19 | const args = try std.process.argsAlloc(arena); | |
| 20 | const exe_file_name = args[1]; | |
| 21 | const cov_file_name = args[2]; | |
| 19 | const args = try std.cli.parse(struct { | |
| 20 | named: struct {}, | |
| 21 | positional: struct { | |
| 22 | exe_file: [:0]const u8, | |
| 23 | cov_file: [:0]const u8, | |
| 24 | }, | |
| 25 | }, arena, .{}); | |
| 26 | const exe_file_name = args.positional.exe_file; | |
| 27 | const cov_file_name = args.positional.cov_file; | |
| 22 | 28 | |
| 23 | 29 | const exe_path: Path = .{ |
| 24 | 30 | .root_dir = std.Build.Cache.Directory.cwd(), |
tools/fetch_them_macos_headers.zig+14-44| ... | ... | @@ -55,36 +55,24 @@ const Target = struct { |
| 55 | 55 | |
| 56 | 56 | const headers_source_prefix: []const u8 = "headers"; |
| 57 | 57 | |
| 58 | const usage = | |
| 59 | \\fetch_them_macos_headers [options] [cc args] | |
| 60 | \\ | |
| 61 | \\Options: | |
| 62 | \\ --sysroot Path to macOS SDK | |
| 63 | \\ | |
| 64 | \\General Options: | |
| 65 | \\-h, --help Print this help and exit | |
| 66 | ; | |
| 58 | const Args = struct { | |
| 59 | named: struct { | |
| 60 | sysroot: []const u8 = "", | |
| 61 | pub const sysroot_help = "Path to macOS SDK"; | |
| 62 | }, | |
| 63 | positional: struct { | |
| 64 | cc_args: []const [:0]const u8 = &.{}, | |
| 65 | }, | |
| 66 | }; | |
| 67 | 67 | |
| 68 | 68 | pub fn main() anyerror!void { |
| 69 | 69 | var arena = std.heap.ArenaAllocator.init(gpa); |
| 70 | 70 | defer arena.deinit(); |
| 71 | 71 | const allocator = arena.allocator(); |
| 72 | 72 | |
| 73 | const args = try std.process.argsAlloc(allocator); | |
| 74 | ||
| 75 | var argv = std.array_list.Managed([]const u8).init(allocator); | |
| 76 | var sysroot: ?[]const u8 = null; | |
| 77 | ||
| 78 | var args_iter = ArgsIterator{ .args = args[1..] }; | |
| 79 | while (args_iter.next()) |arg| { | |
| 80 | if (mem.eql(u8, arg, "--help") or mem.eql(u8, arg, "-h")) { | |
| 81 | return info(usage, .{}); | |
| 82 | } else if (mem.eql(u8, arg, "--sysroot")) { | |
| 83 | sysroot = args_iter.nextOrFatal(); | |
| 84 | } else try argv.append(arg); | |
| 85 | } | |
| 73 | const args = try std.cli.parse(Args, allocator, .{}); | |
| 86 | 74 | |
| 87 | const sysroot_path = sysroot orelse blk: { | |
| 75 | const sysroot_path = if (args.named.sysroot.len > 0) args.named.sysroot else blk: { | |
| 88 | 76 | const target = try std.zig.system.resolveTargetQuery(.{}); |
| 89 | 77 | break :blk std.zig.system.darwin.getSdk(allocator, &target) orelse |
| 90 | 78 | fatal("no SDK found; you can provide one explicitly with '--sysroot' flag", .{}); |
| ... | ... | @@ -121,13 +109,13 @@ pub fn main() anyerror!void { |
| 121 | 109 | .arch = arch, |
| 122 | 110 | .os_ver = os_ver, |
| 123 | 111 | }; |
| 124 | try fetchTarget(allocator, argv.items, sysroot_path, target, version, tmp); | |
| 112 | try fetchTarget(allocator, args.positional.cc_args, sysroot_path, target, version, tmp); | |
| 125 | 113 | } |
| 126 | 114 | } |
| 127 | 115 | |
| 128 | 116 | fn fetchTarget( |
| 129 | 117 | arena: Allocator, |
| 130 | args: []const []const u8, | |
| 118 | cc_args: []const []const u8, | |
| 131 | 119 | sysroot: []const u8, |
| 132 | 120 | target: Target, |
| 133 | 121 | ver: Version, |
| ... | ... | @@ -165,7 +153,7 @@ fn fetchTarget( |
| 165 | 153 | "-MF", |
| 166 | 154 | headers_list_path, |
| 167 | 155 | }); |
| 168 | try cc_argv.appendSlice(args); | |
| 156 | try cc_argv.appendSlice(cc_args); | |
| 169 | 157 | |
| 170 | 158 | const res = try std.process.Child.run(.{ |
| 171 | 159 | .allocator = arena, |
| ... | ... | @@ -229,24 +217,6 @@ fn fetchTarget( |
| 229 | 217 | } |
| 230 | 218 | } |
| 231 | 219 | |
| 232 | const ArgsIterator = struct { | |
| 233 | args: []const []const u8, | |
| 234 | i: usize = 0, | |
| 235 | ||
| 236 | fn next(it: *@This()) ?[]const u8 { | |
| 237 | if (it.i >= it.args.len) { | |
| 238 | return null; | |
| 239 | } | |
| 240 | defer it.i += 1; | |
| 241 | return it.args[it.i]; | |
| 242 | } | |
| 243 | ||
| 244 | fn nextOrFatal(it: *@This()) []const u8 { | |
| 245 | const arg = it.next() orelse fatal("expected parameter after '{s}'", .{it.args[it.i - 1]}); | |
| 246 | return arg; | |
| 247 | } | |
| 248 | }; | |
| 249 | ||
| 250 | 220 | const Version = struct { |
| 251 | 221 | major: u16, |
| 252 | 222 | minor: u8, |
tools/gen_macos_headers_c.zig+6-20| ... | ... | @@ -8,32 +8,18 @@ const Allocator = std.mem.Allocator; |
| 8 | 8 | var general_purpose_allocator = std.heap.GeneralPurposeAllocator(.{}){}; |
| 9 | 9 | const gpa = general_purpose_allocator.allocator(); |
| 10 | 10 | |
| 11 | const usage = | |
| 12 | \\gen_macos_headers_c [dir] | |
| 13 | \\ | |
| 14 | \\General Options: | |
| 15 | \\-h, --help Print this help and exit | |
| 16 | ; | |
| 17 | ||
| 18 | 11 | pub fn main() anyerror!void { |
| 19 | 12 | var arena_allocator = std.heap.ArenaAllocator.init(gpa); |
| 20 | 13 | defer arena_allocator.deinit(); |
| 21 | 14 | const arena = arena_allocator.allocator(); |
| 22 | 15 | |
| 23 | const args = try std.process.argsAlloc(arena); | |
| 24 | if (args.len == 1) fatal("no command or option specified", .{}); | |
| 25 | ||
| 26 | var positionals = std.array_list.Managed([]const u8).init(arena); | |
| 27 | ||
| 28 | for (args[1..]) |arg| { | |
| 29 | if (std.mem.eql(u8, arg, "--help") or std.mem.eql(u8, arg, "-h")) { | |
| 30 | return info(usage, .{}); | |
| 31 | } else try positionals.append(arg); | |
| 32 | } | |
| 33 | ||
| 34 | if (positionals.items.len != 1) fatal("expected one positional argument: [dir]", .{}); | |
| 16 | const args = try std.cli.parse(struct { | |
| 17 | positional: struct { | |
| 18 | dir: []const u8, | |
| 19 | }, | |
| 20 | }, arena, .{}); | |
| 35 | 21 | |
| 36 | var dir = try std.fs.cwd().openDir(positionals.items[0], .{ .no_follow = true }); | |
| 22 | var dir = try std.fs.cwd().openDir(args.positional.dir, .{ .no_follow = true }); | |
| 37 | 23 | defer dir.close(); |
| 38 | 24 | var paths = std.array_list.Managed([]const u8).init(arena); |
| 39 | 25 | try findHeaders(arena, dir, "", &paths); |
tools/gen_outline_atomics.zig+1-1| ... | ... | @@ -15,7 +15,7 @@ pub fn main() !void { |
| 15 | 15 | defer arena_instance.deinit(); |
| 16 | 16 | const arena = arena_instance.allocator(); |
| 17 | 17 | |
| 18 | //const args = try std.process.argsAlloc(arena); | |
| 18 | _ = try std.cli.parse(struct {}, arena, .{}); | |
| 19 | 19 | |
| 20 | 20 | var stdout_buffer: [2000]u8 = undefined; |
| 21 | 21 | var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer); |
tools/gen_spirv_spec.zig+15-23| ... | ... | @@ -58,12 +58,20 @@ const allocator = arena.allocator(); |
| 58 | 58 | pub fn main() !void { |
| 59 | 59 | defer arena.deinit(); |
| 60 | 60 | |
| 61 | const args = try std.process.argsAlloc(allocator); | |
| 62 | if (args.len != 3) { | |
| 63 | usageAndExit(args[0], 1); | |
| 64 | } | |
| 65 | ||
| 66 | const json_path = try std.fs.path.join(allocator, &.{ args[1], "include/spirv/unified1/" }); | |
| 61 | const args = try std.cli.parse(struct { | |
| 62 | pub const description = | |
| 63 | \\Generates Zig bindings for SPIR-V specifications found in the SPIRV-Headers | |
| 64 | \\repository. The result, printed to stdout, should be used to update | |
| 65 | \\files in src/codegen/spirv. Don't forget to format the output. | |
| 66 | ; | |
| 67 | positional: struct { | |
| 68 | pub const @"path/to/SPIRV-Headers_help" = "should point to a clone of https://github.com/KhronosGroup/SPIRV-Headers/"; | |
| 69 | @"path/to/SPIRV-Headers": [:0]const u8, | |
| 70 | @"path/to/zig/src/codegen/spirv/extinst.zig.grammar.json": [:0]const u8, | |
| 71 | }, | |
| 72 | }, allocator, .{}); | |
| 73 | ||
| 74 | const json_path = try std.fs.path.join(allocator, &.{ args.positional.@"path/to/SPIRV-Headers", "include/spirv/unified1/" }); | |
| 67 | 75 | const dir = try std.fs.cwd().openDir(json_path, .{ .iterate = true }); |
| 68 | 76 | |
| 69 | 77 | const core_spec = try readRegistry(CoreRegistry, dir, "spirv.core.grammar.json"); |
| ... | ... | @@ -80,7 +88,7 @@ pub fn main() !void { |
| 80 | 88 | try readExtRegistry(&exts, dir, entry.name); |
| 81 | 89 | } |
| 82 | 90 | |
| 83 | try readExtRegistry(&exts, std.fs.cwd(), args[2]); | |
| 91 | try readExtRegistry(&exts, std.fs.cwd(), args.positional.@"path/to/zig/src/codegen/spirv/extinst.zig.grammar.json"); | |
| 84 | 92 | |
| 85 | 93 | var allocating: std.Io.Writer.Allocating = .init(allocator); |
| 86 | 94 | defer allocating.deinit(); |
| ... | ... | @@ -929,19 +937,3 @@ fn parseHexInt(text: []const u8) !u31 { |
| 929 | 937 | return error.InvalidHexInt; |
| 930 | 938 | return try std.fmt.parseInt(u31, text[prefix.len..], 16); |
| 931 | 939 | } |
| 932 | ||
| 933 | fn usageAndExit(arg0: []const u8, code: u8) noreturn { | |
| 934 | const stderr = std.debug.lockStderrWriter(&.{}); | |
| 935 | stderr.print( | |
| 936 | \\Usage: {s} <SPIRV-Headers repository path> <path/to/zig/src/codegen/spirv/extinst.zig.grammar.json> | |
| 937 | \\ | |
| 938 | \\Generates Zig bindings for SPIR-V specifications found in the SPIRV-Headers | |
| 939 | \\repository. The result, printed to stdout, should be used to update | |
| 940 | \\files in src/codegen/spirv. Don't forget to format the output. | |
| 941 | \\ | |
| 942 | \\<SPIRV-Headers repository path> should point to a clone of | |
| 943 | \\https://github.com/KhronosGroup/SPIRV-Headers/ | |
| 944 | \\ | |
| 945 | , .{arg0}) catch std.process.exit(1); | |
| 946 | std.process.exit(code); | |
| 947 | } |
tools/gen_stubs.zig+6-2| ... | ... | @@ -284,8 +284,12 @@ pub fn main() !void { |
| 284 | 284 | defer arena_instance.deinit(); |
| 285 | 285 | const arena = arena_instance.allocator(); |
| 286 | 286 | |
| 287 | const args = try std.process.argsAlloc(arena); | |
| 288 | const build_all_path = args[1]; | |
| 287 | const args = try std.cli.parse(struct { | |
| 288 | positional: struct { | |
| 289 | build_all_path: [:0]const u8, | |
| 290 | }, | |
| 291 | }, arena, .{}); | |
| 292 | const build_all_path = args.positional.build_all_path; | |
| 289 | 293 | |
| 290 | 294 | var build_all_dir = try std.fs.cwd().openDir(build_all_path, .{}); |
| 291 | 295 |
tools/generate_JSONTestSuite.zig+5-1| ... | ... | @@ -1,4 +1,6 @@ |
| 1 | // zig run this file inside the test_parsing/ directory of this repo: https://github.com/nst/JSONTestSuite | |
| 1 | const Args = struct { | |
| 2 | pub const description = "zig run this file inside the test_parsing/ directory of this repo: https://github.com/nst/JSONTestSuite"; | |
| 3 | }; | |
| 2 | 4 | |
| 3 | 5 | const std = @import("std"); |
| 4 | 6 | |
| ... | ... | @@ -6,6 +8,8 @@ pub fn main() !void { |
| 6 | 8 | var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init; |
| 7 | 9 | var allocator = gpa.allocator(); |
| 8 | 10 | |
| 11 | _ = try std.cli.parse(Args, allocator, .{}); | |
| 12 | ||
| 9 | 13 | var stdout_buffer: [2000]u8 = undefined; |
| 10 | 14 | var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer); |
| 11 | 15 | const output = &stdout_writer.interface; |
tools/generate_c_size_and_align_checks.zig+11-10| ... | ... | @@ -25,21 +25,22 @@ fn cName(ty: std.Target.CType) []const u8 { |
| 25 | 25 | }; |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init; | |
| 29 | ||
| 30 | 28 | pub fn main() !void { |
| 31 | const gpa = general_purpose_allocator.allocator(); | |
| 29 | var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init; | |
| 32 | 30 | defer std.debug.assert(general_purpose_allocator.deinit() == .ok); |
| 31 | const gpa = general_purpose_allocator.allocator(); | |
| 33 | 32 | |
| 34 | const args = try std.process.argsAlloc(gpa); | |
| 35 | defer std.process.argsFree(gpa, args); | |
| 33 | var arena_instance = std.heap.ArenaAllocator.init(gpa); | |
| 34 | defer arena_instance.deinit(); | |
| 35 | const arena = arena_instance.allocator(); | |
| 36 | 36 | |
| 37 | if (args.len != 2) { | |
| 38 | std.debug.print("Usage: {s} [target_triple]\n", .{args[0]}); | |
| 39 | std.process.exit(1); | |
| 40 | } | |
| 37 | const args = try std.cli.parse(struct { | |
| 38 | positional: struct { | |
| 39 | target_triple: [:0]const u8, | |
| 40 | }, | |
| 41 | }, arena, .{}); | |
| 41 | 42 | |
| 42 | const query = try std.Target.Query.parse(.{ .arch_os_abi = args[1] }); | |
| 43 | const query = try std.Target.Query.parse(.{ .arch_os_abi = args.positional.target_triple }); | |
| 43 | 44 | const target = try std.zig.system.resolveTargetQuery(query); |
| 44 | 45 | |
| 45 | 46 | var buffer: [2000]u8 = undefined; |
tools/generate_linux_syscalls.zig+12-17| ... | ... | @@ -11,6 +11,16 @@ |
| 11 | 11 | //! |
| 12 | 12 | //! Everything after `name` is ignored for the purposes of this tool. |
| 13 | 13 | |
| 14 | const Args = struct { | |
| 15 | pub const description = | |
| 16 | \\Generates the list of Linux syscalls for each supported cpu arch, using the Linux development tree. | |
| 17 | \\Prints to stdout Zig code which you can use to replace the file lib/std/os/linux/syscalls.zig. | |
| 18 | ; | |
| 19 | positional: struct { | |
| 20 | @"/path/to/linux": [:0]const u8, | |
| 21 | }, | |
| 22 | }; | |
| 23 | ||
| 14 | 24 | const std = @import("std"); |
| 15 | 25 | const Io = std.Io; |
| 16 | 26 | const mem = std.mem; |
| ... | ... | @@ -175,12 +185,8 @@ pub fn main() !void { |
| 175 | 185 | defer arena.deinit(); |
| 176 | 186 | const gpa = arena.allocator(); |
| 177 | 187 | |
| 178 | const args = try std.process.argsAlloc(gpa); | |
| 179 | if (args.len < 2 or mem.eql(u8, args[1], "--help")) { | |
| 180 | usage(std.debug.lockStderrWriter(&.{}), args[0]) catch std.process.exit(2); | |
| 181 | std.process.exit(1); | |
| 182 | } | |
| 183 | const linux_path = args[1]; | |
| 188 | const args = try std.cli.parse(Args, gpa, .{}); | |
| 189 | const linux_path = args.positional.@"/path/to/linux"; | |
| 184 | 190 | |
| 185 | 191 | var stdout_buffer: [2048]u8 = undefined; |
| 186 | 192 | var stdout_writer = std.fs.File.stdout().writerStreaming(&stdout_buffer); |
| ... | ... | @@ -247,14 +253,3 @@ pub fn main() !void { |
| 247 | 253 | |
| 248 | 254 | try Io.Writer.flush(stdout); |
| 249 | 255 | } |
| 250 | ||
| 251 | fn usage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void { | |
| 252 | try w.print( | |
| 253 | \\Usage: {s} /path/to/zig /path/to/linux | |
| 254 | \\Alternative Usage: zig run /path/to/git/zig/tools/generate_linux_syscalls.zig -- /path/to/zig /path/to/linux | |
| 255 | \\ | |
| 256 | \\Generates the list of Linux syscalls for each supported cpu arch, using the Linux development tree. | |
| 257 | \\Prints to stdout Zig code which you can use to replace the file lib/std/os/linux/syscalls.zig. | |
| 258 | \\ | |
| 259 | , .{arg0}); | |
| 260 | } |
tools/incr-check.zig+23-42| ... | ... | @@ -2,8 +2,6 @@ const std = @import("std"); |
| 2 | 2 | const Allocator = std.mem.Allocator; |
| 3 | 3 | const Cache = std.Build.Cache; |
| 4 | 4 | |
| 5 | const usage = "usage: incr-check <zig binary path> <input file> [--zig-lib-dir lib] [--debug-zcu] [--debug-dwarf] [--debug-link] [--preserve-tmp] [--zig-cc-binary /path/to/zig]"; | |
| 6 | ||
| 7 | 5 | pub fn main() !void { |
| 8 | 6 | const fatal = std.process.fatal; |
| 9 | 7 | |
| ... | ... | @@ -11,46 +9,29 @@ pub fn main() !void { |
| 11 | 9 | defer arena_instance.deinit(); |
| 12 | 10 | const arena = arena_instance.allocator(); |
| 13 | 11 | |
| 14 | var opt_zig_exe: ?[]const u8 = null; | |
| 15 | var opt_input_file_name: ?[]const u8 = null; | |
| 16 | var opt_lib_dir: ?[]const u8 = null; | |
| 17 | var opt_cc_zig: ?[]const u8 = null; | |
| 18 | var debug_zcu = false; | |
| 19 | var debug_dwarf = false; | |
| 20 | var debug_link = false; | |
| 21 | var preserve_tmp = false; | |
| 22 | ||
| 23 | var arg_it = try std.process.argsWithAllocator(arena); | |
| 24 | _ = arg_it.skip(); | |
| 25 | while (arg_it.next()) |arg| { | |
| 26 | if (arg.len > 0 and arg[0] == '-') { | |
| 27 | if (std.mem.eql(u8, arg, "--zig-lib-dir")) { | |
| 28 | opt_lib_dir = arg_it.next() orelse fatal("expected arg after '--zig-lib-dir'\n{s}", .{usage}); | |
| 29 | } else if (std.mem.eql(u8, arg, "--debug-zcu")) { | |
| 30 | debug_zcu = true; | |
| 31 | } else if (std.mem.eql(u8, arg, "--debug-dwarf")) { | |
| 32 | debug_dwarf = true; | |
| 33 | } else if (std.mem.eql(u8, arg, "--debug-link")) { | |
| 34 | debug_link = true; | |
| 35 | } else if (std.mem.eql(u8, arg, "--preserve-tmp")) { | |
| 36 | preserve_tmp = true; | |
| 37 | } else if (std.mem.eql(u8, arg, "--zig-cc-binary")) { | |
| 38 | opt_cc_zig = arg_it.next() orelse fatal("expect arg after '--zig-cc-binary'\n{s}", .{usage}); | |
| 39 | } else { | |
| 40 | fatal("unknown option '{s}'\n{s}", .{ arg, usage }); | |
| 41 | } | |
| 42 | continue; | |
| 43 | } | |
| 44 | if (opt_zig_exe == null) { | |
| 45 | opt_zig_exe = arg; | |
| 46 | } else if (opt_input_file_name == null) { | |
| 47 | opt_input_file_name = arg; | |
| 48 | } else { | |
| 49 | fatal("unknown argument '{s}'\n{s}", .{ arg, usage }); | |
| 50 | } | |
| 51 | } | |
| 52 | const zig_exe = opt_zig_exe orelse fatal("missing path to zig\n{s}", .{usage}); | |
| 53 | const input_file_name = opt_input_file_name orelse fatal("missing input file\n{s}", .{usage}); | |
| 12 | const args = try std.cli.parse(struct { | |
| 13 | positional: struct { | |
| 14 | @"zig-binary-path": []const u8, | |
| 15 | @"input-file": []const u8, | |
| 16 | }, | |
| 17 | named: struct { | |
| 18 | @"zig-lib-dir": []const u8 = "", | |
| 19 | @"debug-zcu": bool = false, | |
| 20 | @"debug-dwarf": bool = false, | |
| 21 | @"debug-link": bool = false, | |
| 22 | preserve_tmp: bool = false, | |
| 23 | @"zig-cc-binary": []const u8 = "", | |
| 24 | }, | |
| 25 | }, arena, .{}); | |
| 26 | ||
| 27 | const opt_lib_dir: ?[]const u8 = if (args.named.@"zig-lib-dir".len > 0) args.named.@"zig-lib-dir" else null; | |
| 28 | const opt_cc_zig: ?[]const u8 = if (args.named.@"zig-cc-binary".len > 0) args.named.@"zig-cc-binary" else null; | |
| 29 | const debug_zcu = args.named.@"debug-zcu"; | |
| 30 | const debug_dwarf = args.named.@"debug-dwarf"; | |
| 31 | const debug_link = args.named.@"debug-link"; | |
| 32 | const preserve_tmp = args.named.preserve_tmp; | |
| 33 | const zig_exe = args.positional.@"zig-binary-path"; | |
| 34 | const input_file_name = args.positional.@"input-file"; | |
| 54 | 35 | |
| 55 | 36 | const input_file_bytes = try std.fs.cwd().readFileAlloc(input_file_name, arena, .limited(std.math.maxInt(u32))); |
| 56 | 37 | const case = try Case.parse(arena, input_file_bytes); |
tools/migrate_langref.zig+8-3| ... | ... | @@ -13,9 +13,14 @@ pub fn main() !void { |
| 13 | 13 | defer arena_instance.deinit(); |
| 14 | 14 | const arena = arena_instance.allocator(); |
| 15 | 15 | |
| 16 | const args = try std.process.argsAlloc(arena); | |
| 17 | const input_file = args[1]; | |
| 18 | const output_file = args[2]; | |
| 16 | const args = try std.cli.parse(struct { | |
| 17 | positional: struct { | |
| 18 | input_file: [:0]const u8, | |
| 19 | output_file: [:0]const u8, | |
| 20 | }, | |
| 21 | }, arena, .{}); | |
| 22 | const input_file = args.positional.input_file; | |
| 23 | const output_file = args.positional.output_file; | |
| 19 | 24 | |
| 20 | 25 | var in_file = try fs.cwd().openFile(input_file, .{ .mode = .read_only }); |
| 21 | 26 | defer in_file.close(); |
tools/process_headers.zig+14-51| ... | ... | @@ -119,52 +119,24 @@ const HashToContents = std.StringHashMap(Contents); |
| 119 | 119 | const TargetToHash = std.StringArrayHashMap([]const u8); |
| 120 | 120 | const PathTable = std.StringHashMap(*TargetToHash); |
| 121 | 121 | |
| 122 | const LibCVendor = enum { | |
| 123 | musl, | |
| 124 | glibc, | |
| 125 | freebsd, | |
| 126 | netbsd, | |
| 127 | }; | |
| 128 | ||
| 129 | 122 | pub fn main() !void { |
| 130 | 123 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 131 | 124 | const allocator = arena.allocator(); |
| 132 | const args = try std.process.argsAlloc(allocator); | |
| 133 | var search_paths = std.array_list.Managed([]const u8).init(allocator); | |
| 134 | var opt_out_dir: ?[]const u8 = null; | |
| 135 | var opt_abi: ?[]const u8 = null; | |
| 136 | 125 | |
| 137 | var arg_i: usize = 1; | |
| 138 | while (arg_i < args.len) : (arg_i += 1) { | |
| 139 | if (std.mem.eql(u8, args[arg_i], "--help")) | |
| 140 | usageAndExit(args[0]); | |
| 141 | if (arg_i + 1 >= args.len) { | |
| 142 | std.debug.print("expected argument after '{s}'\n", .{args[arg_i]}); | |
| 143 | usageAndExit(args[0]); | |
| 144 | } | |
| 126 | const args = try std.cli.parse(struct { | |
| 127 | named: struct { | |
| 128 | @"search-path": []const []const u8 = &.{}, | |
| 129 | out: []const u8, | |
| 130 | abi: enum { musl, glibc, freebsd, netbsd }, | |
| 145 | 131 | |
| 146 | if (std.mem.eql(u8, args[arg_i], "--search-path")) { | |
| 147 | try search_paths.append(args[arg_i + 1]); | |
| 148 | } else if (std.mem.eql(u8, args[arg_i], "--out")) { | |
| 149 | assert(opt_out_dir == null); | |
| 150 | opt_out_dir = args[arg_i + 1]; | |
| 151 | } else if (std.mem.eql(u8, args[arg_i], "--abi")) { | |
| 152 | assert(opt_abi == null); | |
| 153 | opt_abi = args[arg_i + 1]; | |
| 154 | } else { | |
| 155 | std.debug.print("unrecognized argument: {s}\n", .{args[arg_i]}); | |
| 156 | usageAndExit(args[0]); | |
| 157 | } | |
| 158 | ||
| 159 | arg_i += 1; | |
| 160 | } | |
| 161 | ||
| 162 | const out_dir = opt_out_dir orelse usageAndExit(args[0]); | |
| 163 | const abi_name = opt_abi orelse usageAndExit(args[0]); | |
| 164 | const vendor = std.meta.stringToEnum(LibCVendor, abi_name) orelse { | |
| 165 | std.debug.print("unrecognized C ABI: {s}\n", .{abi_name}); | |
| 166 | usageAndExit(args[0]); | |
| 167 | }; | |
| 132 | pub const @"search-path_help" = "subdirectories of search paths look like, e.g. x86_64-linux-gnu"; | |
| 133 | pub const out_help = "a dir that will be created, and populated with the results"; | |
| 134 | }, | |
| 135 | }, allocator, .{}); | |
| 136 | const search_paths = args.named.@"search-path"; | |
| 137 | const out_dir = args.named.out; | |
| 138 | const vendor = args.named.abi; | |
| 139 | const abi_name = @tagName(vendor); | |
| 168 | 140 | |
| 169 | 141 | const generic_name = try std.fmt.allocPrint(allocator, "generic-{s}", .{abi_name}); |
| 170 | 142 | const libc_targets = switch (vendor) { |
| ... | ... | @@ -225,7 +197,7 @@ pub fn main() !void { |
| 225 | 197 | @tagName(libc_target.abi), |
| 226 | 198 | }); |
| 227 | 199 | |
| 228 | search: for (search_paths.items) |search_path| { | |
| 200 | search: for (search_paths) |search_path| { | |
| 229 | 201 | const sub_path = switch (vendor) { |
| 230 | 202 | .glibc, |
| 231 | 203 | .freebsd, |
| ... | ... | @@ -362,12 +334,3 @@ pub fn main() !void { |
| 362 | 334 | } |
| 363 | 335 | } |
| 364 | 336 | } |
| 365 | ||
| 366 | fn usageAndExit(arg0: []const u8) noreturn { | |
| 367 | std.debug.print("Usage: {s} [--search-path <dir>] --out <dir> --abi <name>\n", .{arg0}); | |
| 368 | std.debug.print("--search-path can be used any number of times.\n", .{}); | |
| 369 | std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); | |
| 370 | std.debug.print("--out is a dir that will be created, and populated with the results\n", .{}); | |
| 371 | std.debug.print("--abi is either glibc, musl, freebsd, or netbsd\n", .{}); | |
| 372 | std.process.exit(1); | |
| 373 | } |
tools/update-linux-headers.zig+11-34| ... | ... | @@ -142,33 +142,18 @@ const PathTable = std.StringHashMap(*TargetToHash); |
| 142 | 142 | pub fn main() !void { |
| 143 | 143 | var arena_state = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 144 | 144 | const arena = arena_state.allocator(); |
| 145 | const args = try std.process.argsAlloc(arena); | |
| 146 | var search_paths = std.array_list.Managed([]const u8).init(arena); | |
| 147 | var opt_out_dir: ?[]const u8 = null; | |
| 148 | 145 | |
| 149 | var arg_i: usize = 1; | |
| 150 | while (arg_i < args.len) : (arg_i += 1) { | |
| 151 | if (std.mem.eql(u8, args[arg_i], "--help")) | |
| 152 | usageAndExit(args[0]); | |
| 153 | if (arg_i + 1 >= args.len) { | |
| 154 | std.debug.print("expected argument after '{s}'\n", .{args[arg_i]}); | |
| 155 | usageAndExit(args[0]); | |
| 156 | } | |
| 157 | ||
| 158 | if (std.mem.eql(u8, args[arg_i], "--search-path")) { | |
| 159 | try search_paths.append(args[arg_i + 1]); | |
| 160 | } else if (std.mem.eql(u8, args[arg_i], "--out")) { | |
| 161 | assert(opt_out_dir == null); | |
| 162 | opt_out_dir = args[arg_i + 1]; | |
| 163 | } else { | |
| 164 | std.debug.print("unrecognized argument: {s}\n", .{args[arg_i]}); | |
| 165 | usageAndExit(args[0]); | |
| 166 | } | |
| 146 | const args = try std.cli.parse(struct { | |
| 147 | named: struct { | |
| 148 | @"search-path": []const []const u8 = &.{}, | |
| 149 | out: []const u8, | |
| 167 | 150 | |
| 168 | arg_i += 1; | |
| 169 | } | |
| 170 | ||
| 171 | const out_dir = opt_out_dir orelse usageAndExit(args[0]); | |
| 151 | pub const @"search-path_help" = "subdirectories of search paths look like, e.g. x86_64-linux-gnu"; | |
| 152 | pub const out_help = "a dir that will be created, and populated with the results"; | |
| 153 | }, | |
| 154 | }, arena, .{}); | |
| 155 | const search_paths = args.named.@"search-path"; | |
| 156 | const out_dir = args.named.out; | |
| 172 | 157 | const generic_name = "any-linux-any"; |
| 173 | 158 | |
| 174 | 159 | var path_table = PathTable.init(arena); |
| ... | ... | @@ -182,7 +167,7 @@ pub fn main() !void { |
| 182 | 167 | const dest_target = DestTarget{ |
| 183 | 168 | .arch = linux_target.arch, |
| 184 | 169 | }; |
| 185 | search: for (search_paths.items) |search_path| { | |
| 170 | search: for (search_paths) |search_path| { | |
| 186 | 171 | const target_include_dir = try std.fs.path.join(arena, &.{ |
| 187 | 172 | search_path, linux_target.name, "include", |
| 188 | 173 | }); |
| ... | ... | @@ -320,11 +305,3 @@ pub fn main() !void { |
| 320 | 305 | try std.fs.cwd().deleteFile(full_path); |
| 321 | 306 | } |
| 322 | 307 | } |
| 323 | ||
| 324 | fn usageAndExit(arg0: []const u8) noreturn { | |
| 325 | std.debug.print("Usage: {s} [--search-path <dir>] --out <dir> --abi <name>\n", .{arg0}); | |
| 326 | std.debug.print("--search-path can be used any number of times.\n", .{}); | |
| 327 | std.debug.print(" subdirectories of search paths look like, e.g. x86_64-linux-gnu\n", .{}); | |
| 328 | std.debug.print("--out is a dir that will be created, and populated with the results\n", .{}); | |
| 329 | std.process.exit(1); | |
| 330 | } |
tools/update_clang_options.zig+9-31| ... | ... | @@ -630,29 +630,22 @@ const cpu_targets = struct { |
| 630 | 630 | pub fn main() anyerror!void { |
| 631 | 631 | var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator); |
| 632 | 632 | defer arena.deinit(); |
| 633 | ||
| 634 | 633 | const allocator = arena.allocator(); |
| 635 | const args = try std.process.argsAlloc(allocator); | |
| 636 | 634 | |
| 637 | 635 | var stdout_buffer: [4000]u8 = undefined; |
| 638 | 636 | var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer); |
| 639 | 637 | const stdout = &stdout_writer.interface; |
| 640 | 638 | |
| 641 | if (args.len <= 1) printUsageAndExit(args[0]); | |
| 642 | ||
| 643 | if (std.mem.eql(u8, args[1], "--help")) { | |
| 644 | printUsage(stdout, args[0]) catch std.process.exit(2); | |
| 645 | stdout.flush() catch std.process.exit(2); | |
| 646 | std.process.exit(0); | |
| 647 | } | |
| 648 | ||
| 649 | if (args.len < 3) printUsageAndExit(args[0]); | |
| 650 | ||
| 651 | const llvm_tblgen_exe = args[1]; | |
| 652 | if (std.mem.startsWith(u8, llvm_tblgen_exe, "-")) printUsageAndExit(args[0]); | |
| 639 | const args = try std.cli.parse(struct { | |
| 640 | pub const description = "Prints to stdout Zig code which you can use to replace the file src/clang_options_data.zig."; | |
| 641 | positional: struct { | |
| 642 | @"/path/to/llvm-tblgen": [:0]const u8, | |
| 643 | @"/path/to/git/llvm/llvm-project": [:0]const u8, | |
| 644 | }, | |
| 645 | }, allocator, .{}); | |
| 653 | 646 | |
| 654 | const llvm_src_root = args[2]; | |
| 655 | if (std.mem.startsWith(u8, llvm_src_root, "-")) printUsageAndExit(args[0]); | |
| 647 | const llvm_tblgen_exe = args.positional.@"/path/to/llvm-tblgen"; | |
| 648 | const llvm_src_root = args.positional.@"/path/to/git/llvm/llvm-project"; | |
| 656 | 649 | |
| 657 | 650 | var llvm_to_zig_cpu_features = std.StringHashMap([]const u8).init(allocator); |
| 658 | 651 | |
| ... | ... | @@ -959,18 +952,3 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool { |
| 959 | 952 | const b_key = b.get("!name").?.string; |
| 960 | 953 | return std.mem.lessThan(u8, a_key, b_key); |
| 961 | 954 | } |
| 962 | ||
| 963 | fn printUsageAndExit(arg0: []const u8) noreturn { | |
| 964 | printUsage(std.debug.lockStderrWriter(&.{}), arg0) catch std.process.exit(2); | |
| 965 | std.process.exit(1); | |
| 966 | } | |
| 967 | ||
| 968 | fn printUsage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void { | |
| 969 | try w.print( | |
| 970 | \\Usage: {s} /path/to/llvm-tblgen /path/to/git/llvm/llvm-project | |
| 971 | \\Alternative Usage: zig run /path/to/git/zig/tools/update_clang_options.zig -- /path/to/llvm-tblgen /path/to/git/llvm/llvm-project | |
| 972 | \\ | |
| 973 | \\Prints to stdout Zig code which you can use to replace the file src/clang_options_data.zig. | |
| 974 | \\ | |
| 975 | , .{arg0}); | |
| 976 | } |
tools/update_cpu_features.zig+17-45| ... | ... | @@ -1567,38 +1567,23 @@ pub fn main() anyerror!void { |
| 1567 | 1567 | defer arena_state.deinit(); |
| 1568 | 1568 | const arena = arena_state.allocator(); |
| 1569 | 1569 | |
| 1570 | var args = try std.process.argsWithAllocator(arena); | |
| 1571 | const args0 = args.next().?; | |
| 1572 | ||
| 1573 | const llvm_tblgen_exe = args.next() orelse | |
| 1574 | usageAndExit(args0, 1); | |
| 1575 | ||
| 1576 | if (std.mem.eql(u8, llvm_tblgen_exe, "--help")) { | |
| 1577 | usageAndExit(args0, 0); | |
| 1578 | } | |
| 1579 | if (std.mem.startsWith(u8, llvm_tblgen_exe, "-")) { | |
| 1580 | usageAndExit(args0, 1); | |
| 1581 | } | |
| 1582 | ||
| 1583 | const llvm_src_root = args.next() orelse | |
| 1584 | usageAndExit(args0, 1); | |
| 1585 | ||
| 1586 | if (std.mem.startsWith(u8, llvm_src_root, "-")) { | |
| 1587 | usageAndExit(args0, 1); | |
| 1588 | } | |
| 1589 | ||
| 1590 | const zig_src_root = args.next() orelse | |
| 1591 | usageAndExit(args0, 1); | |
| 1592 | ||
| 1593 | if (std.mem.startsWith(u8, zig_src_root, "-")) { | |
| 1594 | usageAndExit(args0, 1); | |
| 1595 | } | |
| 1596 | ||
| 1597 | var filter: ?[]const u8 = null; | |
| 1598 | if (args.next()) |arg| filter = arg; | |
| 1599 | ||
| 1600 | // there shouldn't be any more argument after the optional filter | |
| 1601 | if (args.skip()) usageAndExit(args0, 1); | |
| 1570 | const args = try std.cli.parse(struct { | |
| 1571 | pub const description = | |
| 1572 | \\Updates lib/std/target/<target>.zig from llvm/lib/Target/<Target>/<Target>.td . | |
| 1573 | \\ | |
| 1574 | \\On a less beefy system, or when debugging, compile with -fsingle-threaded. | |
| 1575 | ; | |
| 1576 | positional: struct { | |
| 1577 | @"/path/to/llvm-tblgen": [:0]const u8, | |
| 1578 | @"/path/git/llvm-project": [:0]const u8, | |
| 1579 | @"/path/git/zig": [:0]const u8, | |
| 1580 | zig_name_filter: []const u8 = "", | |
| 1581 | }, | |
| 1582 | }, arena, .{}); | |
| 1583 | const llvm_tblgen_exe = args.positional.@"/path/to/llvm-tblgen"; | |
| 1584 | const llvm_src_root = args.positional.@"/path/git/llvm-project"; | |
| 1585 | const zig_src_root = args.positional.@"/path/git/zig"; | |
| 1586 | const filter: ?[]const u8 = if (args.positional.zig_name_filter.len > 0) args.positional.zig_name_filter else null; | |
| 1602 | 1587 | |
| 1603 | 1588 | var zig_src_dir = try fs.cwd().openDir(zig_src_root, .{}); |
| 1604 | 1589 | defer zig_src_dir.close(); |
| ... | ... | @@ -2104,19 +2089,6 @@ fn processOneTarget(job: Job) void { |
| 2104 | 2089 | render_progress.end(); |
| 2105 | 2090 | } |
| 2106 | 2091 | |
| 2107 | fn usageAndExit(arg0: []const u8, code: u8) noreturn { | |
| 2108 | const stderr = std.debug.lockStderrWriter(&.{}); | |
| 2109 | stderr.print( | |
| 2110 | \\Usage: {s} /path/to/llvm-tblgen /path/git/llvm-project /path/git/zig [zig_name filter] | |
| 2111 | \\ | |
| 2112 | \\Updates lib/std/target/<target>.zig from llvm/lib/Target/<Target>/<Target>.td . | |
| 2113 | \\ | |
| 2114 | \\On a less beefy system, or when debugging, compile with -fsingle-threaded. | |
| 2115 | \\ | |
| 2116 | , .{arg0}) catch std.process.exit(1); | |
| 2117 | std.process.exit(code); | |
| 2118 | } | |
| 2119 | ||
| 2120 | 2092 | fn featureLessThan(_: void, a: Feature, b: Feature) bool { |
| 2121 | 2093 | return std.ascii.lessThanIgnoreCase(a.zig_name, b.zig_name); |
| 2122 | 2094 | } |
tools/update_crc_catalog.zig+6-17| ... | ... | @@ -10,11 +10,12 @@ pub fn main() anyerror!void { |
| 10 | 10 | defer arena_state.deinit(); |
| 11 | 11 | const arena = arena_state.allocator(); |
| 12 | 12 | |
| 13 | const args = try std.process.argsAlloc(arena); | |
| 14 | if (args.len <= 1) printUsageAndExit(args[0]); | |
| 15 | ||
| 16 | const zig_src_root = args[1]; | |
| 17 | if (mem.startsWith(u8, zig_src_root, "-")) printUsageAndExit(args[0]); | |
| 13 | const args = try std.cli.parse(struct { | |
| 14 | positional: struct { | |
| 15 | @"/path/git/zig": [:0]const u8, | |
| 16 | }, | |
| 17 | }, arena, .{}); | |
| 18 | const zig_src_root = args.positional.@"/path/git/zig"; | |
| 18 | 19 | |
| 19 | 20 | var zig_src_dir = try fs.cwd().openDir(zig_src_root, .{}); |
| 20 | 21 | defer zig_src_dir.close(); |
| ... | ... | @@ -188,15 +189,3 @@ pub fn main() anyerror!void { |
| 188 | 189 | try code_writer.flush(); |
| 189 | 190 | try test_writer.flush(); |
| 190 | 191 | } |
| 191 | ||
| 192 | fn printUsageAndExit(arg0: []const u8) noreturn { | |
| 193 | printUsage(std.debug.lockStderrWriter(&.{}), arg0) catch std.process.exit(2); | |
| 194 | std.process.exit(1); | |
| 195 | } | |
| 196 | ||
| 197 | fn printUsage(w: *std.Io.Writer, arg0: []const u8) std.Io.Writer.Error!void { | |
| 198 | return w.print( | |
| 199 | \\Usage: {s} /path/git/zig | |
| 200 | \\ | |
| 201 | , .{arg0}); | |
| 202 | } |
tools/update_freebsd_libc.zig+8-3| ... | ... | @@ -16,9 +16,14 @@ pub fn main() !void { |
| 16 | 16 | defer arena_instance.deinit(); |
| 17 | 17 | const arena = arena_instance.allocator(); |
| 18 | 18 | |
| 19 | const args = try std.process.argsAlloc(arena); | |
| 20 | const freebsd_src_path = args[1]; | |
| 21 | const zig_src_path = args[2]; | |
| 19 | const args = try std.cli.parse(struct { | |
| 20 | positional: struct { | |
| 21 | freebsd_src_path: [:0]const u8, | |
| 22 | zig_src_path: [:0]const u8, | |
| 23 | }, | |
| 24 | }, arena, .{}); | |
| 25 | const freebsd_src_path = args.positional.freebsd_src_path; | |
| 26 | const zig_src_path = args.positional.zig_src_path; | |
| 22 | 27 | |
| 23 | 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/freebsd", .{zig_src_path}); |
| 24 | 29 |
tools/update_glibc.zig+8-3| ... | ... | @@ -41,9 +41,14 @@ pub fn main() !void { |
| 41 | 41 | defer arena_instance.deinit(); |
| 42 | 42 | const arena = arena_instance.allocator(); |
| 43 | 43 | |
| 44 | const args = try std.process.argsAlloc(arena); | |
| 45 | const glibc_src_path = args[1]; | |
| 46 | const zig_src_path = args[2]; | |
| 44 | const args = try std.cli.parse(struct { | |
| 45 | positional: struct { | |
| 46 | glibc_src_path: [:0]const u8, | |
| 47 | zig_src_path: [:0]const u8, | |
| 48 | }, | |
| 49 | }, arena, .{}); | |
| 50 | const glibc_src_path = args.positional.glibc_src_path; | |
| 51 | const zig_src_path = args.positional.zig_src_path; | |
| 47 | 52 | |
| 48 | 53 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/glibc", .{zig_src_path}); |
| 49 | 54 |
tools/update_mingw.zig+8-3| ... | ... | @@ -5,9 +5,14 @@ pub fn main() !void { |
| 5 | 5 | defer arena_instance.deinit(); |
| 6 | 6 | const arena = arena_instance.allocator(); |
| 7 | 7 | |
| 8 | const args = try std.process.argsAlloc(arena); | |
| 9 | const zig_src_lib_path = args[1]; | |
| 10 | const mingw_src_path = args[2]; | |
| 8 | const args = try std.cli.parse(struct { | |
| 9 | positional: struct { | |
| 10 | zig_src_lib_path: [:0]const u8, | |
| 11 | mingw_src_path: [:0]const u8, | |
| 12 | }, | |
| 13 | }, arena, .{}); | |
| 14 | const zig_src_lib_path = args.positional.zig_src_lib_path; | |
| 15 | const mingw_src_path = args.positional.mingw_src_path; | |
| 11 | 16 | |
| 12 | 17 | const dest_mingw_crt_path = try std.fs.path.join(arena, &.{ |
| 13 | 18 | zig_src_lib_path, "libc", "mingw", |
tools/update_netbsd_libc.zig+8-3| ... | ... | @@ -16,9 +16,14 @@ pub fn main() !void { |
| 16 | 16 | defer arena_instance.deinit(); |
| 17 | 17 | const arena = arena_instance.allocator(); |
| 18 | 18 | |
| 19 | const args = try std.process.argsAlloc(arena); | |
| 20 | const netbsd_src_path = args[1]; | |
| 21 | const zig_src_path = args[2]; | |
| 19 | const args = try std.cli.parse(struct { | |
| 20 | positional: struct { | |
| 21 | netbsd_src_path: [:0]const u8, | |
| 22 | zig_src_path: [:0]const u8, | |
| 23 | }, | |
| 24 | }, arena, .{}); | |
| 25 | const netbsd_src_path = args.positional.netbsd_src_path; | |
| 26 | const zig_src_path = args.positional.zig_src_path; | |
| 22 | 27 | |
| 23 | 28 | const dest_dir_path = try std.fmt.allocPrint(arena, "{s}/lib/libc/netbsd", .{zig_src_path}); |
| 24 | 29 |