Skip to content

Commit b1cb0c0

Browse files
committed
add completion message
1 parent ba59872 commit b1cb0c0

11 files changed

+46
-79
lines changed

Sources/Basics/ProgressAnimation/Concrete/BlastProgressAnimation.swift

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ extension BlastProgressAnimation: ProgressAnimationProtocol {
103103
self._flush()
104104
}
105105

106-
func complete() {
107-
self._complete()
106+
func complete(_ message: String?) {
107+
self._complete(message)
108108
self._flush()
109109
}
110110
}
@@ -151,13 +151,17 @@ extension BlastProgressAnimation {
151151
self.terminal.text(styles: .reset)
152152
}
153153

154+
func _drawMessage(_ message: String?) {
155+
if let message {
156+
self.terminal.write(" ")
157+
self.terminal.write(message)
158+
}
159+
}
160+
154161
func _draw() {
155162
assert(self.drawnLines == 0)
156163
self._drawStates()
157-
if let header = self.header {
158-
self.terminal.write(" ")
159-
self.terminal.write(header)
160-
}
164+
self._drawMessage(self.header)
161165
self.drawnLines += 1
162166
let tasks = self.state.tasks.values.filter { $0.state == .started }.sorted()
163167
for task in tasks {
@@ -167,9 +171,10 @@ extension BlastProgressAnimation {
167171
}
168172
}
169173

170-
func _complete() {
174+
func _complete(_ message: String?) {
171175
self._clear()
172176
self._drawStates()
177+
self._drawMessage(message ?? self.header)
173178
self.terminal.newLine()
174179
}
175180

Sources/Basics/ProgressAnimation/Concrete/NinjaMultiLineProgressAnimation.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,10 @@ extension NinjaMultiLineProgressAnimation: ProgressAnimationProtocol {
6363
self.terminal.flush()
6464
}
6565

66-
func complete() {}
66+
func complete(_ message: String?) {
67+
if let message {
68+
self.terminal.write(message)
69+
self.terminal.flush()
70+
}
71+
}
6772
}

Sources/Basics/ProgressAnimation/Concrete/NinjaRedrawingProgressAnimation.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ extension NinjaRedrawingProgressAnimation: ProgressAnimationProtocol {
6363
self._flush()
6464
}
6565

66-
func complete() {
67-
self._complete()
66+
func complete(_ message: String?) {
67+
self._complete(message)
6868
self._flush()
6969
}
7070
}
@@ -85,7 +85,8 @@ extension NinjaRedrawingProgressAnimation {
8585
self.hasDisplayedProgress = true
8686
}
8787

88-
func _complete() {
88+
func _complete(_ message: String?) {
89+
#warning("TODO")
8990
if self.hasDisplayedProgress {
9091
self.terminal.newLine()
9192
}

Sources/Basics/ProgressAnimation/Concrete/PercentMultiLineProgressAnimation.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,10 @@ extension PercentMultiLineProgressAnimation: ProgressAnimationProtocol {
7272
self.terminal.flush()
7373
}
7474

75-
func complete() {}
75+
func complete(_ message: String?) {
76+
if let message {
77+
self.terminal.write(message)
78+
self.terminal.flush()
79+
}
80+
}
7681
}

Sources/Basics/ProgressAnimation/Concrete/PercentRedrawingProgressAnimation.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ extension PercentRedrawingProgressAnimation: ProgressAnimationProtocol {
7272
self._flush()
7373
}
7474

75-
func complete() {
76-
self._complete()
75+
func complete(_ message: String?) {
76+
self._complete(message)
7777
self._flush()
7878
}
7979
}
@@ -134,12 +134,15 @@ extension PercentRedrawingProgressAnimation {
134134
self.hasDisplayedProgress = true
135135
}
136136

137-
func _complete() {
137+
func _complete(_ message: String?) {
138138
self._clear()
139139
guard self.hasDisplayedHeader else { return }
140140
self.terminal.carriageReturn()
141141
self.terminal.moveCursorUp(cells: 1)
142142
self.terminal.eraseLine(.entire)
143+
if let message {
144+
self.terminal.write(message)
145+
}
143146
}
144147

145148
func _clear() {

Sources/Basics/ProgressAnimation/Concrete/PercentSingleLineProgressAnimation.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,10 @@ extension PercentSingleLineProgressAnimation: ProgressAnimationProtocol {
7676
self.terminal.flush()
7777
}
7878

79-
func complete() {}
79+
func complete(_ message: String?) {
80+
if let message {
81+
self.terminal.write(message)
82+
self.terminal.flush()
83+
}
84+
}
8085
}

Sources/Basics/ProgressAnimation/Misc/ProgressAdapter.swift

Lines changed: 0 additions & 43 deletions
This file was deleted.

Sources/Basics/ProgressAnimation/Misc/ProgressAnimation.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,6 @@ package enum ProgressAnimation {
4343
} else {
4444
NinjaMultiLineProgressAnimation.self
4545
}
46-
47-
// if !interactive {
48-
// PercentSingleLineProgressAnimation.self
49-
// } else if !verbose {
50-
// NinjaRedrawingProgressAnimation.self
51-
// } else {
52-
// NinjaMultiLineProgressAnimation.self
53-
// }
5446
}
5547

5648
package static func make(

Sources/Basics/ProgressAnimation/Misc/ProgressAnimationProtocol.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ package protocol ProgressAnimationProtocol {
3131
func interleave(_ bytes: some Collection<UInt8>)
3232

3333
/// Complete the animation.
34-
func complete()
34+
func complete(_ message: String?)
3535
}
3636

3737
extension ProgressAnimationProtocol {

Sources/Build/LLBuildProgressTracker.swift

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,7 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
444444
func buildStart(
445445
configuration: BuildConfiguration,
446446
action: String
447-
) {
448-
self.queue.sync {
449-
self.progressAnimation.interleave("\(action) for \(configuration == .debug ? "debugging" : "production")...\n")
450-
}
451-
}
447+
) { }
452448

453449
func buildComplete(
454450
success: Bool,
@@ -463,11 +459,9 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
463459
}
464460

465461
self.queue.sync {
466-
self.progressAnimation.complete()
467-
if success {
468-
let result = self.cancelled ? "cancelled" : "complete"
469-
self.progressAnimation.interleave("\(action) \(subsetString)\(result)! (\(duration.descriptionInSeconds))\n")
470-
}
462+
let result = !success ? "failed" :
463+
self.cancelled ? "cancelled" : "complete"
464+
self.progressAnimation.complete("\(action) \(subsetString)\(result)!")
471465
}
472466
}
473467
}

0 commit comments

Comments
 (0)