Skip to content
Merged
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
22 changes: 8 additions & 14 deletions Sources/Build/BuildDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,9 @@ public final class BuildDelegate: BuildSystemDelegate {
return completedCount + scanningCount - upToDateCount
}

mutating func update(withStatusChange kind: CommandStatusKind) {
mutating func update(command: SPMLLBuild.Command, kind: CommandStatusKind) {
guard command.shouldShowStatus else { return }

switch kind {
case .isScanning:
scanningCount += 1
Expand All @@ -204,7 +206,6 @@ public final class BuildDelegate: BuildSystemDelegate {
public var isVerbose: Bool = false
public var onCommmandFailure: (() -> Void)?
private var commandCounter = CommandCounter()
private var lastProgressDescription: String = ""
private let queue = DispatchQueue(label: "org.swift.swiftpm.build-delegate")

public init(
Expand Down Expand Up @@ -237,29 +238,22 @@ public final class BuildDelegate: BuildSystemDelegate {

public func commandStatusChanged(_ command: SPMLLBuild.Command, kind: CommandStatusKind) {
queue.sync {
commandCounter.update(withStatusChange: kind)
commandCounter.update(command: command, kind: kind)
}
}

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

public func commandStarted(_ command: SPMLLBuild.Command) {
guard command.shouldShowStatus else { return }

queue.sync {
commandCounter.startedCount += 1

let description: String
if command.shouldShowStatus {
description = isVerbose ? command.verboseDescription : command.description
} else {
description = lastProgressDescription
}

lastProgressDescription = description
progressAnimation.update(
step: commandCounter.startedCount,
total: commandCounter.estimatedMaximum,
text: description)
text: isVerbose ? command.verboseDescription : command.description)
}
}

Expand Down Expand Up @@ -303,7 +297,7 @@ public final class BuildDelegate: BuildSystemDelegate {

public func commandProcessHadOutput(_ command: SPMLLBuild.Command, process: ProcessHandle, data: [UInt8]) {
progressAnimation.clear()
outputStream <<< (data + [newLineByte])
outputStream <<< data
outputStream.flush()
}

Expand Down