Skip to content

Commit 10bf129

Browse files
authored
Merge pull request #2185 from TaborKelly/swift-5.1-backport-pr2127
Backport PR 2127.
2 parents 009877c + 0de5012 commit 10bf129

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Sources/Commands/Options.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,5 +74,8 @@ public class ToolOptions {
7474
/// Write dependency resolver trace to a file.
7575
public var enableResolverTrace = false
7676

77+
/// The number of jobs for llbuild to start (aka the number of schedulerLanes)
78+
public var jobs: UInt32? = nil
79+
7780
public required init() {}
7881
}

Sources/Commands/SwiftTool.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,11 @@ public class SwiftTool<Options: ToolOptions> {
357357
option: parser.add(option: "--trace-resolver", kind: Bool.self),
358358
to: { $0.enableResolverTrace = $1 })
359359

360+
binder.bind(
361+
option: parser.add(option: "--jobs", shortName: "-j", kind: Int.self,
362+
usage: "The number of jobs to spawn in parallel during the build process"),
363+
to: { $0.jobs = UInt32($1) })
364+
360365
// Let subclasses bind arguments.
361366
type(of: self).defineArguments(parser: parser, binder: binder)
362367

@@ -619,6 +624,9 @@ public class SwiftTool<Options: ToolOptions> {
619624
buildDelegate.isVerbose = isVerbose
620625

621626
let databasePath = buildPath.appending(component: "build.db").pathString
627+
if let jobs = options.jobs {
628+
BuildSystem.setSchedulerLaneWidth(width: jobs)
629+
}
622630
let buildSystem = BuildSystem(buildFile: manifest.pathString, databaseFile: databasePath, delegate: buildDelegate)
623631
buildDelegate.onCommmandFailure = { buildSystem.cancel() }
624632

0 commit comments

Comments
 (0)