Skip to content

Commit 28ff8c0

Browse files
authored
Merge pull request #1913 from hartbit/fix-duplicate-build-output
[SR-9461] Resolve duplicate output in swift bulid
2 parents 72bec53 + 628a86b commit 28ff8c0

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

Sources/Build/BuildDelegate.swift

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,9 @@ public final class BuildDelegate: BuildSystemDelegate {
183183
return completedCount + scanningCount - upToDateCount
184184
}
185185

186-
mutating func update(withStatusChange kind: CommandStatusKind) {
186+
mutating func update(command: SPMLLBuild.Command, kind: CommandStatusKind) {
187+
guard command.shouldShowStatus else { return }
188+
187189
switch kind {
188190
case .isScanning:
189191
scanningCount += 1
@@ -204,7 +206,6 @@ public final class BuildDelegate: BuildSystemDelegate {
204206
public var isVerbose: Bool = false
205207
public var onCommmandFailure: (() -> Void)?
206208
private var commandCounter = CommandCounter()
207-
private var lastProgressDescription: String = ""
208209
private let queue = DispatchQueue(label: "org.swift.swiftpm.build-delegate")
209210

210211
public init(
@@ -237,29 +238,22 @@ public final class BuildDelegate: BuildSystemDelegate {
237238

238239
public func commandStatusChanged(_ command: SPMLLBuild.Command, kind: CommandStatusKind) {
239240
queue.sync {
240-
commandCounter.update(withStatusChange: kind)
241+
commandCounter.update(command: command, kind: kind)
241242
}
242243
}
243244

244245
public func commandPreparing(_ command: SPMLLBuild.Command) {
245246
}
246247

247248
public func commandStarted(_ command: SPMLLBuild.Command) {
249+
guard command.shouldShowStatus else { return }
250+
248251
queue.sync {
249252
commandCounter.startedCount += 1
250-
251-
let description: String
252-
if command.shouldShowStatus {
253-
description = isVerbose ? command.verboseDescription : command.description
254-
} else {
255-
description = lastProgressDescription
256-
}
257-
258-
lastProgressDescription = description
259253
progressAnimation.update(
260254
step: commandCounter.startedCount,
261255
total: commandCounter.estimatedMaximum,
262-
text: description)
256+
text: isVerbose ? command.verboseDescription : command.description)
263257
}
264258
}
265259

@@ -303,7 +297,7 @@ public final class BuildDelegate: BuildSystemDelegate {
303297

304298
public func commandProcessHadOutput(_ command: SPMLLBuild.Command, process: ProcessHandle, data: [UInt8]) {
305299
progressAnimation.clear()
306-
outputStream <<< (data + [newLineByte])
300+
outputStream <<< data
307301
outputStream.flush()
308302
}
309303

0 commit comments

Comments
 (0)