Swift-format as part of brew

Now that swift-format in main uses the Swift rewrite of SwiftSyntax (as per the new notice in swift-format), does that mean that the compiled binary is no longer tied to the runtime libraries of the toolchain? What I was wondering now is if that enables finally a path to officially distribute swift-format over brew, and have semver on the swift-format tool that's untied to the version of Xcode being used (thinking about macOS specifically, not sure what's the status of this for linux)

6 Likes

Could you change the title to specifically mention swift format and not Swift in general?

sorry, meant to do that

1 Like

I think swift-format by itself cannot adopt SemVer until the underlying SwiftSyntax adopts SemVer. This is still an open discussion point. cc @ahoppen
swift-format also depends on ArgumentParser and swift-tools-support-core. Where the latter also has not released a major version yet.

Correct, I think we'll want to coordinate with swift-syntax to determine the best strategy for semver on both repos before locking anything in.

Once that's resolved, if swift-tools-support-core was the only remaining dependency that didn't have a major version, I'd consider just implementing my own ad hoc diagnostics printing logic to remove that dependency (that's all it's used for). What I'd really love to see though is a lightweight diagnostics package that could be shared by multiple compiler packages, including swift-format.

1 Like

This seems very reasonable to me. SwiftSyntax is here really in the driver seat. A bunch of other packages cannot adopt SemVer cleanly because they depend on it.

assuming semver can be ironed out (which seems like there are some efforts in that line), would that be enough to unblock distribution through brew? Or do you foresee other issues that might block that?

I don't know enough about brew distribution to answer with 100% confidence, but since swift-format at main only depends on other Swift packages now and not a toolchain library, as long as brew can swift build it then I think it would work fine.

swift-syntax is gaining some lightweight diagnostics printing facilities (e.g., see Added a formatter to pretty print diagnostics by flashspys · Pull Request #874 · apple/swift-syntax · GitHub) that, we hope, will be better to standardize on that TSC's.

Doug

5 Likes

Good discussion going on here :+1:

I'm curious about the status of both this swift-format in Brew, and what the chances are that swift-format could one day be bundled in with Swift itself, like Go does.