Skip to content

SwiftIfConfig: Create a "fixed" or "static" build configuration that is Codable #2884

@DougGregor

Description

@DougGregor
Member

Description

The SwiftIfConfig library has a BuildConfiguration protocol, but there is no concrete implementation of the BuildConfiguration protocol in the library. The only BuildConfiguration in normal use right now is buried in the Swift compiler itself, to query the configuration of the compiler.

We should add some kind of "fixed" or "static" build configuration that conforms to BuildConfiguration and is Codable so it can easily be saved and restored. Ideas for such a configuration:

  • Use it for some of the unit tests instead of the bare-bones testing build configuration we have now
  • Extend the compiler and/or SourceKit with an option to dump out JSON in a format that's compatible with this type, so tools can query the build configuration once and then apply it in other contexts such as an IDE (e.g., in SourceKit-LSP)
  • Extend swift-parser-cli with an option to apply a build configuration file (the serialized JSON), removing all of the inactive #if regions based on that configuration (SwiftIfConfig already has an API for this)

Activity

ahoppen

ahoppen commented on Oct 21, 2024

@ahoppen
Member

Synced to Apple’s issue tracker as rdar://138352412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @DougGregor@ahoppen

        Issue actions

          SwiftIfConfig: Create a "fixed" or "static" build configuration that is Codable · Issue #2884 · swiftlang/swift-syntax