Skip to content

Build: adjust the BuildSystemDelegate hander #4192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 4, 2022
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
15 changes: 12 additions & 3 deletions Sources/Build/BuildOperationBuildSystemDelegateHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,9 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
/// Swift parsers keyed by llbuild command name.
private var swiftParsers: [String: SwiftCompilerOutputParser] = [:]

/// Buffer to accumulate non-swift output until command is finished
private var nonSwiftMessageBuffers: [String: [UInt8]] = [:]

/// The build execution context.
private let buildExecutionContext: BuildExecutionContext

Expand Down Expand Up @@ -566,9 +569,7 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
swiftParser.parse(bytes: data)
} else {
queue.async {
self.progressAnimation.clear()
self.outputStream <<< data
self.outputStream.flush()
self.nonSwiftMessageBuffers[command.name, default: []] += data
}
}
}
Expand All @@ -578,6 +579,14 @@ final class BuildOperationBuildSystemDelegateHandler: LLBuildBuildSystemDelegate
process: ProcessHandle,
result: CommandExtendedResult
) {
if let buffer = self.nonSwiftMessageBuffers[command.name] {
queue.async {
self.progressAnimation.clear()
self.outputStream <<< buffer
self.outputStream.flush()
self.nonSwiftMessageBuffers[command.name] = nil
}
}
if result.result == .failed {
// 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.
queue.async {
Expand Down