Skip to content

Backport PR 2127. #2185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/Commands/Options.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,8 @@ public class ToolOptions {
/// Write dependency resolver trace to a file.
public var enableResolverTrace = false

/// The number of jobs for llbuild to start (aka the number of schedulerLanes)
public var jobs: UInt32? = nil

public required init() {}
}
8 changes: 8 additions & 0 deletions Sources/Commands/SwiftTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,11 @@ public class SwiftTool<Options: ToolOptions> {
option: parser.add(option: "--trace-resolver", kind: Bool.self),
to: { $0.enableResolverTrace = $1 })

binder.bind(
option: parser.add(option: "--jobs", shortName: "-j", kind: Int.self,
usage: "The number of jobs to spawn in parallel during the build process"),
to: { $0.jobs = UInt32($1) })

// Let subclasses bind arguments.
type(of: self).defineArguments(parser: parser, binder: binder)

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

let databasePath = buildPath.appending(component: "build.db").pathString
if let jobs = options.jobs {
BuildSystem.setSchedulerLaneWidth(width: jobs)
}
let buildSystem = BuildSystem(buildFile: manifest.pathString, databaseFile: databasePath, delegate: buildDelegate)
buildDelegate.onCommmandFailure = { buildSystem.cancel() }

Expand Down