Skip to content

Commit c22c9e9

Browse files
authored
add "building for <configuration>" message (#3826)
motivation: inform users of configuration they building for changes: add "building for <configuration>" message at the begining of the build rdar://84533229
1 parent 5062080 commit c22c9e9

File tree

5 files changed

+35
-11
lines changed

5 files changed

+35
-11
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
135135
let buildSystem = try self.createBuildSystem(buildDescription: buildDescription)
136136
self.buildSystem = buildSystem
137137

138+
buildSystemDelegate?.buildStart(configuration: self.buildParameters.configuration)
139+
138140
// Perform the build.
139141
let llbuildTarget = try computeLLBuildTargetName(for: subset)
140142
let success = buildSystem.build(target: llbuildTarget)

Sources/Build/BuildOperationBuildSystemDelegateHandler.swift

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
588588
self.outputStream.flush()
589589
}
590590
} else {
591-
self.taskTracker.swiftCompilerDidOuputMessage(message, targetName: parser.targetName)
591+
self.taskTracker.swiftCompilerDidOutputMessage(message, targetName: parser.targetName)
592592
self.updateProgress()
593593
}
594594

@@ -619,6 +619,14 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
619619
self.commandFailureHandler?()
620620
}
621621

622+
func buildStart(configuration: BuildConfiguration) {
623+
queue.sync {
624+
self.progressAnimation.clear()
625+
self.outputStream <<< "Building for \(configuration == .debug ? "debugging" : "production")...\n"
626+
self.outputStream.flush()
627+
}
628+
}
629+
622630
func buildComplete(success: Bool) {
623631
queue.sync {
624632
self.progressAnimation.complete(success: success)
@@ -657,9 +665,9 @@ fileprivate struct CommandTaskTracker {
657665
mutating func commandStatusChanged(_ command: SPMLLBuild.Command, kind: CommandStatusKind) {
658666
switch kind {
659667
case .isScanning:
660-
totalCount += 1
668+
self.totalCount += 1
661669
case .isUpToDate:
662-
totalCount -= 1
670+
self.totalCount -= 1
663671
case .isComplete:
664672
break
665673
@unknown default:
@@ -670,21 +678,21 @@ fileprivate struct CommandTaskTracker {
670678

671679
mutating func commandFinished(_ command: SPMLLBuild.Command, result: CommandResult, targetName: String?) {
672680
let progressTextValue = progressText(of: command, targetName: targetName)
673-
onTaskProgressUpdateText?(progressTextValue, targetName)
681+
self.onTaskProgressUpdateText?(progressTextValue, targetName)
674682

675-
latestFinishedText = progressTextValue
683+
self.latestFinishedText = progressTextValue
676684

677685
switch result {
678686
case .succeeded, .skipped:
679-
finishedCount += 1
687+
self.finishedCount += 1
680688
case .cancelled, .failed:
681689
break
682690
default:
683691
break
684692
}
685693
}
686694

687-
mutating func swiftCompilerDidOuputMessage(_ message: SwiftCompilerMessage, targetName: String) {
695+
mutating func swiftCompilerDidOutputMessage(_ message: SwiftCompilerMessage, targetName: String) {
688696
switch message.kind {
689697
case .began(let info):
690698
if let text = progressText(of: message, targetName: targetName) {

Sources/Build/BuildPlan.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -804,7 +804,7 @@ public final class SwiftTargetBuildDescription {
804804
args += ["-color-diagnostics"]
805805
}
806806

807-
// Add agruments from declared build settings.
807+
// Add arguments from declared build settings.
808808
args += self.buildSettingsFlags()
809809

810810
// Add the output for the `.swiftinterface`, if requested or if library evolution has been enabled some other way.

Sources/LLBuildManifest/Tools.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ public struct CopyTool: ToolProtocol {
7070
}
7171
}
7272

73-
/// Package strcuture tool is used to determine if the package has changed in some way
73+
/// Package structure tool is used to determine if the package has changed in some way
7474
/// that requires regenerating the build manifest file. This allows us to skip a lot of
75-
/// redundent work (package graph loading, build planning, manifest generation) during
75+
/// redundant work (package graph loading, build planning, manifest generation) during
7676
/// incremental builds.
7777
public struct PackageStructureTool: ToolProtocol {
7878
public static let name: String = "package-structure-tool"

Tests/CommandsTests/BuildToolTests.swift

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,21 @@ final class BuildToolTests: XCTestCase {
280280
do {
281281
let result = try execute([], packagePath: path)
282282
// test second time, to make sure message is presented even when nothing to build (cached)
283-
XCTAssertMatch(result.stdout, .equal("[1/1] Planning build\nBuild complete!\n"))
283+
XCTAssertMatch(result.stdout, .equal("[1/1] Planning build\nBuilding for debugging...\nBuild complete!\n"))
284+
}
285+
}
286+
}
287+
288+
func testBuildStartMessage() {
289+
fixture(name: "DependencyResolution/Internal/Simple") { path in
290+
do {
291+
let result = try execute(["-c", "debug"], packagePath: path)
292+
XCTAssertMatch(result.stdout, .prefix("Building for debugging"))
293+
}
294+
295+
do {
296+
let result = try execute(["-c", "release"], packagePath: path)
297+
XCTAssertMatch(result.stdout, .prefix("Building for production"))
284298
}
285299
}
286300
}

0 commit comments

Comments
 (0)