diff options
| author | dweiller <4678790+dweiller@users.noreplay.github.com> | 2023-02-10 02:23:31 +1100 |
|---|---|---|
| committer | Veikka Tuominen <git@vexu.eu> | 2023-02-11 20:50:57 +0200 |
| commit | ca0528209fc2a70fc52013b36439a093db0ac6e2 (patch) | |
| tree | e90601c72f09959f5f08035579bf2e1c2dd76c43 /lib/build_runner.zig | |
| parent | d976b4e4a56e4ac6b45a3d9ae9766e57bf04f82b (diff) | |
| download | zig-ca0528209fc2a70fc52013b36439a093db0ac6e2.tar.gz zig-ca0528209fc2a70fc52013b36439a093db0ac6e2.zip | |
zig build: add -l, --list-steps option to build_runner.zig
Diffstat (limited to 'lib/build_runner.zig')
| -rw-r--r-- | lib/build_runner.zig | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/build_runner.zig b/lib/build_runner.zig index f2b2eba950..aeefb57bfc 100644 --- a/lib/build_runner.zig +++ b/lib/build_runner.zig @@ -93,6 +93,8 @@ pub fn main() !void { std.debug.print("Expected argument after {s}\n\n", .{arg}); return usageAndErr(builder, false, stderr_stream); }; + } else if (mem.eql(u8, arg, "-l") or mem.eql(u8, arg, "--list-steps")) { + return steps(builder, false, stdout_stream); } else if (mem.eql(u8, arg, "--prefix-lib-dir")) { dir_list.lib_dir = nextArg(args, &arg_idx) orelse { std.debug.print("Expected argument after {s}\n\n", .{arg}); @@ -232,20 +234,13 @@ pub fn main() !void { }; } -fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { +fn steps(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { // run the build script to collect the options if (!already_ran_build) { builder.resolveInstallPrefix(null, .{}); try builder.runBuild(root); } - try out_stream.print( - \\Usage: {s} build [steps] [options] - \\ - \\Steps: - \\ - , .{builder.zig_exe}); - const allocator = builder.allocator; for (builder.top_level_steps.items) |top_level_step| { const name = if (&top_level_step.step == builder.default_step) @@ -254,6 +249,23 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi top_level_step.step.name; try out_stream.print(" {s:<28} {s}\n", .{ name, top_level_step.description }); } +} + +fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { + // run the build script to collect the options + if (!already_ran_build) { + builder.resolveInstallPrefix(null, .{}); + try builder.runBuild(root); + } + + try out_stream.print( + \\ + \\Usage: {s} build [steps] [options] + \\ + \\Steps: + \\ + , .{builder.zig_exe}); + try steps(builder, true, out_stream); try out_stream.writeAll( \\ @@ -284,6 +296,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi \\ Windows programs on Linux hosts. (default: no) \\ \\ -h, --help Print this help and exit + \\ -l, --list-steps Print available steps \\ --verbose Print commands before executing them \\ --color [auto|off|on] Enable or disable colored error messages \\ --prominent-compile-errors Output compile errors formatted for a human to read @@ -292,6 +305,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi \\ ); + const allocator = builder.allocator; if (builder.available_options_list.items.len == 0) { try out_stream.print(" (none)\n", .{}); } else { |
