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

Split SwiftProtobuf into SwiftProtobufCore & SwiftProtobufFoundationCompat #1331

Merged
merged 7 commits into from
Nov 2, 2022

Conversation

gjcairo
Copy link
Contributor

@gjcairo gjcairo commented Oct 31, 2022

Motivation

This is the first step of several in the path to removing the usage of Data (and eventually Foundation) from swift-protobuf. This is related to #816.

Modifications

  • Renamed SwiftProtobuf module to SwiftProtobufCore
  • Created new SwiftProtobufFoundationCompat module, which is currently empty.
  • Created new SwiftProtobuf module that only re-exports both SwiftProtobufFoundationCore and SwiftProtobufFoundationCompat.
  • Made changes to Makefile and regenerated necessary files.

Result

We now have different modules that lay the groundwork for the migration proposed in #816. Other related, currently-open PRs will be updated once this one is landed.

@testable import SwiftProtobuf
@testable import SwiftProtobufCore
Copy link
Member

Choose a reason for hiding this comment

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

I think none of these should change for now. If we do this move without breaking anything all the tests compile without any real change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue here is that in these tests are using internal methods (hence the @testable). However, the re-export I'm doing in SwiftProtobuf/Exports.swift using @_exported import SwiftProtobufCore doesn't expose those methods, and there's no way to do it (AFAIK) without explicitly doing @testable import SwiftProtobufCore instead.

Copy link
Collaborator

@thomasvl thomasvl Nov 1, 2022

Choose a reason for hiding this comment

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

@FranzBusch is there where @_spi() usage comes up?

Copy link
Member

Choose a reason for hiding this comment

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

This might work here. Never tried to combination of @_exported import and @_spi together. We should definitely take a look since @_spi has a few more upsides to @testable as well like being able to compile in release mode without extra flags. However, I would do this investigation in a follow up since I am not sure which Swift version introduced @_spi and if we can actually use it here.

@gjcairo gjcairo marked this pull request as ready for review October 31, 2022 16:09
- Move SwiftProtobufContiguousBytes to SwiftProtobufCore (it was mistakenly added to SwiftProtobufFoundationCompat earlier)
- Added a placeholder for extending Data with SwiftProtobufContiguousBytes conformance in SwiftProtobufFoundationCompat
To keep PR more focused. Will re-add them in a separate PR.
@thomasvl
Copy link
Collaborator

thomasvl commented Nov 1, 2022

I think I'm good with things at this as a starting point.

@tbkka @FranzBusch (and anyone else) - thoughts?

Copy link
Contributor

@tbkka tbkka left a comment

Choose a reason for hiding this comment

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

This looks good. It opens the door for us to segregate out Data usage and also sets an example that may be useful for segregating JSON and TextFormat support (which has been proposed a couple of times but no one has done the experiment to see whether it's worth doing).

@thomasvl
Copy link
Collaborator

thomasvl commented Nov 1, 2022

Unless someone does it before me, I'll do a squash+merge tomorrow; just so anyone else that wants to comment gets a chance.

Copy link
Member

@FranzBusch FranzBusch left a comment

Choose a reason for hiding this comment

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

LGTM and happy to get this merged!

@thomasvl thomasvl merged commit b0c4726 into apple:main Nov 2, 2022
@gjcairo gjcairo deleted the foundation-structure branch March 27, 2024 16:02
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.

4 participants