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
36 changes: 21 additions & 15 deletions Sources/Build/LLBuildProgressTracker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
guard command.shouldShowStatus else { return }
guard !self.swiftParsers.keys.contains(command.name) else { return }

let commandName = command.name
let commandDescription = command.description

self.queue.async {
if result == .cancelled {
self.cancelled = true
Expand All @@ -288,8 +291,8 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
self.delegate?.buildSystem(self.buildSystem, didFinishCommand: BuildSystemCommand(command))

if !self.logLevel.isVerbose && !self.logLevel.isQuiet {
let targetName = self.swiftParsers[command.name]?.targetName
self.taskTracker.commandFinished(command, result: result, targetName: targetName)
let targetName = self.swiftParsers[commandName]?.targetName
self.taskTracker.commandFinished(commandDescription, result: result, targetName: targetName)
self.updateProgress()
}
}
Expand Down Expand Up @@ -345,12 +348,15 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
// FIXME: This should really happen at the command-level and is just a stopgap measure.
let shouldFilterOutput = !self.logLevel.isVerbose && command.verboseDescription.hasPrefix("codesign ") && result
.result != .failed

let commandName = command.name

self.queue.async {
if let buffer = self.nonSwiftMessageBuffers[command.name], !shouldFilterOutput {
if let buffer = self.nonSwiftMessageBuffers[commandName], !shouldFilterOutput {
self.progressAnimation.clear()
self.outputStream.send(buffer)
self.outputStream.flush()
self.nonSwiftMessageBuffers[command.name] = nil
self.nonSwiftMessageBuffers[commandName] = nil
}
}

Expand All @@ -362,13 +368,13 @@ final class LLBuildProgressTracker: LLBuildBuildSystemDelegate, SwiftCompilerOut
// The command failed, so we queue up an asynchronous task to see if we have any error messages from the
// target to provide advice about.
self.queue.async {
guard let target = self.swiftParsers[command.name]?.targetName else { return }
guard let target = self.swiftParsers[commandName]?.targetName else { return }
guard let errorMessages = self.errorMessagesByTarget[target] else { return }
for errorMessage in errorMessages {
// Emit any advice that's provided for each error message.
if let adviceMessage = self.buildExecutionContext.buildErrorAdviceProvider?.provideBuildErrorAdvice(
for: target,
command: command.name,
command: commandName,
message: errorMessage
) {
self.outputStream.send("note: \(adviceMessage)\n")
Expand Down Expand Up @@ -536,8 +542,8 @@ private struct CommandTaskTracker {
}
}

mutating func commandFinished(_ command: SPMLLBuild.Command, result: CommandResult, targetName: String?) {
let progressTextValue = self.progressText(of: command, targetName: targetName)
mutating func commandFinished(_ commandDescription: String, result: CommandResult, targetName: String?) {
let progressTextValue = self.progressText(of: commandDescription, targetName: targetName)
self.onTaskProgressUpdateText?(progressTextValue, targetName)

self.latestFinishedText = progressTextValue
Expand All @@ -564,27 +570,27 @@ private struct CommandTaskTracker {
}
}

private func progressText(of command: SPMLLBuild.Command, targetName: String?) -> String {
private func progressText(of commandDescription: String, targetName: String?) -> String {
#if os(Windows)
let pathSep: Character = "\\"
#else
let pathSep: Character = "/"
#endif
// Transforms descriptions like "Linking ./.build/x86_64-apple-macosx/debug/foo" into "Linking foo".
if let firstSpaceIndex = command.description.firstIndex(of: " "),
let lastDirectorySeparatorIndex = command.description.lastIndex(of: pathSep)
if let firstSpaceIndex = commandDescription.firstIndex(of: " "),
let lastDirectorySeparatorIndex = commandDescription.lastIndex(of: pathSep)
{
let action = command.description[..<firstSpaceIndex]
let fileNameStartIndex = command.description.index(after: lastDirectorySeparatorIndex)
let fileName = command.description[fileNameStartIndex...]
let action = commandDescription[..<firstSpaceIndex]
let fileNameStartIndex = commandDescription.index(after: lastDirectorySeparatorIndex)
let fileName = commandDescription[fileNameStartIndex...]

if let targetName {
return "\(action) \(targetName) \(fileName)"
} else {
return "\(action) \(fileName)"
}
} else {
return command.description
return commandDescription
}
}

Expand Down