Skip to content
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

PluginAPI: Optionally animate build progress in console #8383

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kateinoigakukun
Copy link
Member

Introduce a way to animate build progress in console triggered by PackagePlugin API.

Motivation:

When a package plugin asks SwiftPM to build a target, SwiftPM captures the whole build output including the progress messages and compiler diagnostics into a non-TTY output buffer stream. Use of the non-TTY output buffer stream makes the [n/N] Compiling ... progress messages always to be newlined. This is not ideal when building a large scale project as it consumes a lot of space in the terminal buffer.

Modifications:

This commit introduces a new parameter progressToConsole to the BuildParameters to allow the package plugin to decide whether to write the progress messages to the console or capture them into logText buffer.

Compiler diagnostics are still "tee"ed and they are not colored and are included in logText.

Result:

Package plugin developers will be able to provide a better build output to plugin users.

progressToConsole: false progressToConsole: true
Screen.Recording.2025-03-19.at.22.40.31.mov
Screen.Recording.2025-03-19.at.22.41.14.mov

When a package plugin asks SwiftPM to build a target, SwiftPM captures
the whole build output including the progress messages and compiler
diagnostics into a non-TTY output buffer stream. Use of the non-TTY
output buffer stream makes the `[n/N] Compiling ...` progress messages
always to be newlined. This is not ideal when building a large scale
project as it consumes a lot of space in the terminal buffer.

This commit introduces a new parameter `progressToConsole` to the
`BuildParameters` to allow the package plugin to decide whether to
write the progress messages to the console or capture them into
`logText` buffer.
///
/// If this is set to true, `BuildResult.logText` will not contain any
/// progress information.
public var progressToConsole: Bool
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is new public API and will therefore need a Swift Evolution proposal API availability annotation.

Can you please start a pitch on the Swift Forums to propose this new API?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants