| ... | ... | @@ -93,6 +93,8 @@ pub fn main() !void { |
| 93 | 93 | std.debug.print("Expected argument after {s}\n\n", .{arg}); |
| 94 | 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 | 98 | } else if (mem.eql(u8, arg, "--prefix-lib-dir")) { |
| 97 | 99 | dir_list.lib_dir = nextArg(args, &arg_idx) orelse { |
| 98 | 100 | std.debug.print("Expected argument after {s}\n\n", .{arg}); |
| ... | ... | @@ -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 | 238 | // run the build script to collect the options |
| 237 | 239 | if (!already_ran_build) { |
| 238 | 240 | builder.resolveInstallPrefix(null, .{}); |
| 239 | 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 | 244 | const allocator = builder.allocator; |
| 250 | 245 | for (builder.top_level_steps.items) |top_level_step| { |
| 251 | 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 | 249 | top_level_step.step.name; |
| 255 | 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 | 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 | 296 | \\ Windows programs on Linux hosts. (default: no) |
| 285 | 297 | \\ |
| 286 | 298 | \\ -h, --help Print this help and exit |
| 299 | \\ -l, --list-steps Print available steps |
| 287 | 300 | \\ --verbose Print commands before executing them |
| 288 | 301 | \\ --color [auto|off|on] Enable or disable colored error messages |
| 289 | 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 | 305 | \\ |
| 293 | 306 | ); |
| 294 | 307 | |
| 308 | const allocator = builder.allocator; |
| 295 | 309 | if (builder.available_options_list.items.len == 0) { |
| 296 | 310 | try out_stream.print(" (none)\n", .{}); |
| 297 | 311 | } else { |