| ... | @@ -93,6 +93,8 @@ pub fn main() !void { | ... | @@ -93,6 +93,8 @@ pub fn main() !void { |
| 93 | std.debug.print("Expected argument after {s}\n\n", .{arg}); | 93 | std.debug.print("Expected argument after {s}\n\n", .{arg}); |
| 94 | return usageAndErr(builder, false, stderr_stream); | 94 | return usageAndErr(builder, false, stderr_stream); |
| 95 | }; | 95 | }; |
| | 96 | } else if (mem.eql(u8, arg, "-l") or mem.eql(u8, arg, "--list-steps")) { |
| | 97 | return steps(builder, false, stdout_stream); |
| 96 | } else if (mem.eql(u8, arg, "--prefix-lib-dir")) { | 98 | } else if (mem.eql(u8, arg, "--prefix-lib-dir")) { |
| 97 | dir_list.lib_dir = nextArg(args, &arg_idx) orelse { | 99 | dir_list.lib_dir = nextArg(args, &arg_idx) orelse { |
| 98 | std.debug.print("Expected argument after {s}\n\n", .{arg}); | 100 | std.debug.print("Expected argument after {s}\n\n", .{arg}); |
| ... | @@ -232,20 +234,13 @@ pub fn main() !void { | ... | @@ -232,20 +234,13 @@ pub fn main() !void { |
| 232 | }; | 234 | }; |
| 233 | } | 235 | } |
| 234 | | 236 | |
| 235 | fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { | 237 | fn steps(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { |
| 236 | // run the build script to collect the options | 238 | // run the build script to collect the options |
| 237 | if (!already_ran_build) { | 239 | if (!already_ran_build) { |
| 238 | builder.resolveInstallPrefix(null, .{}); | 240 | builder.resolveInstallPrefix(null, .{}); |
| 239 | try builder.runBuild(root); | 241 | try builder.runBuild(root); |
| 240 | } | 242 | } |
| 241 | | 243 | |
| 242 | try out_stream.print( | | |
| 243 | \\Usage: {s} build [steps] [options] | | |
| 244 | \\ | | |
| 245 | \\Steps: | | |
| 246 | \\ | | |
| 247 | , .{builder.zig_exe}); | | |
| 248 | | | |
| 249 | const allocator = builder.allocator; | 244 | const allocator = builder.allocator; |
| 250 | for (builder.top_level_steps.items) |top_level_step| { | 245 | for (builder.top_level_steps.items) |top_level_step| { |
| 251 | const name = if (&top_level_step.step == builder.default_step) | 246 | 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 | ... | @@ -254,6 +249,23 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi |
| 254 | top_level_step.step.name; | 249 | top_level_step.step.name; |
| 255 | try out_stream.print(" {s:<28} {s}\n", .{ name, top_level_step.description }); | 250 | try out_stream.print(" {s:<28} {s}\n", .{ name, top_level_step.description }); |
| 256 | } | 251 | } |
| | 252 | } |
| | 253 | |
| | 254 | fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !void { |
| | 255 | // run the build script to collect the options |
| | 256 | if (!already_ran_build) { |
| | 257 | builder.resolveInstallPrefix(null, .{}); |
| | 258 | try builder.runBuild(root); |
| | 259 | } |
| | 260 | |
| | 261 | try out_stream.print( |
| | 262 | \\ |
| | 263 | \\Usage: {s} build [steps] [options] |
| | 264 | \\ |
| | 265 | \\Steps: |
| | 266 | \\ |
| | 267 | , .{builder.zig_exe}); |
| | 268 | try steps(builder, true, out_stream); |
| 257 | | 269 | |
| 258 | try out_stream.writeAll( | 270 | try out_stream.writeAll( |
| 259 | \\ | 271 | \\ |
| ... | @@ -284,6 +296,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi | ... | @@ -284,6 +296,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi |
| 284 | \\ Windows programs on Linux hosts. (default: no) | 296 | \\ Windows programs on Linux hosts. (default: no) |
| 285 | \\ | 297 | \\ |
| 286 | \\ -h, --help Print this help and exit | 298 | \\ -h, --help Print this help and exit |
| | 299 | \\ -l, --list-steps Print available steps |
| 287 | \\ --verbose Print commands before executing them | 300 | \\ --verbose Print commands before executing them |
| 288 | \\ --color [auto|off|on] Enable or disable colored error messages | 301 | \\ --color [auto|off|on] Enable or disable colored error messages |
| 289 | \\ --prominent-compile-errors Output compile errors formatted for a human to read | 302 | \\ --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 | ... | @@ -292,6 +305,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi |
| 292 | \\ | 305 | \\ |
| 293 | ); | 306 | ); |
| 294 | | 307 | |
| | 308 | const allocator = builder.allocator; |
| 295 | if (builder.available_options_list.items.len == 0) { | 309 | if (builder.available_options_list.items.len == 0) { |
| 296 | try out_stream.print(" (none)\n", .{}); | 310 | try out_stream.print(" (none)\n", .{}); |
| 297 | } else { | 311 | } else { |