| ... | ... | @@ -87,6 +87,7 @@ pub fn main() !void { |
| 87 | 87 | |
| 88 | 88 | var targets = ArrayList([]const u8).init(allocator); |
| 89 | 89 | var debug_log_scopes = ArrayList([]const u8).init(allocator); |
| 90 | var thread_pool_options: std.Thread.Pool.Options = .{ .allocator = allocator }; |
| 90 | 91 | |
| 91 | 92 | const stderr_stream = io.getStdErr().writer(); |
| 92 | 93 | const stdout_stream = io.getStdOut().writer(); |
| ... | ... | @@ -231,6 +232,19 @@ pub fn main() !void { |
| 231 | 232 | }; |
| 232 | 233 | } else if (mem.eql(u8, arg, "-fno-reference-trace")) { |
| 233 | 234 | builder.reference_trace = null; |
| 235 | } else if (mem.startsWith(u8, arg, "-j")) { |
| 236 | const num = arg["-j".len..]; |
| 237 | const n_jobs = std.fmt.parseUnsigned(u32, num, 10) catch |err| { |
| 238 | std.debug.print("unable to parse jobs count '{s}': {s}", .{ |
| 239 | num, @errorName(err), |
| 240 | }); |
| 241 | process.exit(1); |
| 242 | }; |
| 243 | if (n_jobs < 1) { |
| 244 | std.debug.print("number of jobs must be at least 1\n", .{}); |
| 245 | process.exit(1); |
| 246 | } |
| 247 | thread_pool_options.n_jobs = n_jobs; |
| 234 | 248 | } else if (mem.eql(u8, arg, "--")) { |
| 235 | 249 | builder.args = argsRest(args, arg_idx); |
| 236 | 250 | break; |
| ... | ... | @@ -258,7 +272,7 @@ pub fn main() !void { |
| 258 | 272 | if (builder.validateUserInputDidItFail()) |
| 259 | 273 | usageAndErr(builder, true, stderr_stream); |
| 260 | 274 | |
| 261 | | runStepNames(builder, targets.items, main_progress_node) catch |err| { |
| 275 | runStepNames(builder, targets.items, main_progress_node, thread_pool_options) catch |err| { |
| 262 | 276 | switch (err) { |
| 263 | 277 | error.UncleanExit => process.exit(1), |
| 264 | 278 | else => return err, |
| ... | ... | @@ -270,6 +284,7 @@ fn runStepNames( |
| 270 | 284 | b: *std.Build, |
| 271 | 285 | step_names: []const []const u8, |
| 272 | 286 | parent_prog_node: *std.Progress.Node, |
| 287 | thread_pool_options: std.Thread.Pool.Options, |
| 273 | 288 | ) !void { |
| 274 | 289 | var step_stack = ArrayList(*Step).init(b.allocator); |
| 275 | 290 | defer step_stack.deinit(); |
| ... | ... | @@ -297,7 +312,7 @@ fn runStepNames( |
| 297 | 312 | } |
| 298 | 313 | |
| 299 | 314 | var thread_pool: std.Thread.Pool = undefined; |
| 300 | | try thread_pool.init(b.allocator); |
| 315 | try thread_pool.init(thread_pool_options); |
| 301 | 316 | defer thread_pool.deinit(); |
| 302 | 317 | |
| 303 | 318 | { |
| ... | ... | @@ -523,6 +538,7 @@ fn usage(builder: *std.Build, already_ran_build: bool, out_stream: anytype) !voi |
| 523 | 538 | \\ --verbose Print commands before executing them |
| 524 | 539 | \\ --color [auto|off|on] Enable or disable colored error messages |
| 525 | 540 | \\ --prominent-compile-errors Output compile errors formatted for a human to read |
| 541 | \\ -j<N> Limit concurrent jobs (default is to use all CPU cores) |
| 526 | 542 | \\ |
| 527 | 543 | \\Project-Specific Options: |
| 528 | 544 | \\ |