-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Adopt language mode naming in PackageDescription
API
#7620
Adopt language mode naming in PackageDescription
API
#7620
Conversation
@swift-ci please test |
1 similar comment
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, I'm not sure about new initializer though, it seems like that could some unfortunate ambiguity issues because renamed parameter is defaulted.
@swift-ci please test |
1 similar comment
@swift-ci please test |
Yes, the proposal describes this. Looking back at all the existing init methods, every time a new Package init method is introduced, it is made available in a particular release. The existing init method is obsoleted in the same release, so there is no ambiguity. When adding parameters, there is no breaking change. Changing a parameter name, as happens here, introduces a breaking change when moving to swift tools version 6.0. The |
@swift-ci please test package compatibility |
@swift-ci please test |
@xedin I believe all of the Swift PM changes in the proposal are included and the Linux and macOS tests pass. (Something related to the CI itself seems to have gone wrong in the latest macOS test, I will re-run it) Three questions:
Thank you for your help with this. |
@swift-ci please test |
We can squash merge everything so you can add all the information you'd like in the commit message to the PR description.
I think this is pretty much it.
|
PackageDescription
API
both |
@swift-ci test |
@swift-ci test windows |
/// - condition: A condition that restricts the application of the build setting. | ||
@available(_PackageDescription, introduced: 6.0) | ||
public static func swiftLanguageVersion( | ||
_ version: SwiftVersion, | ||
public static func swiftLanguageMode( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR needs to introduce a new function and mark the old one as deprecated, otherwise existing Package.swift
manifests will break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm willing to do so, but this would be an API change within the same release cycle. No shipping release version of Swift PM has the original API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry I missed that, makes sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should do this anyway - it would be nice not to break packages that have already started using this in their conversion to Swift 6. I admit it's a little weird, but IMO worth handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming this proposal does get reviewed in the Swift 6.0 timeframe, I could completely see adding an 'obsoleted in 6 / renamed in 6' for swiftLanguageVersion
to give folks an easy migration to move over during pre-release Swift 6.0 with a fix-it - but removing that for the final version so it doesn't have to be baked into the API for all time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but removing that for the final version so it doesn't have to be baked into the API for all time
We can just deprecate it and then remove when we remove the other swiftLanguageVersion
🤷
@swift-ci test |
7ec5369
to
7481db7
Compare
@swift-ci test |
1 similar comment
@swift-ci test |
In the PackageDescription Module: - Rename SwiftVersion enum to SwiftLanguageMode - Use new name in extension declaration - Add SwiftVersion as a type alias for SwiftLanguageMode The SwiftVersion type alias provides backwards compatibilty. The existing, now obsoleted init methods use the type alias for clarity with the parameter name matching the parameter type.
Note this only changes the API, the plumbing including the name of the Swift setting generated by the method, still uses the term "swiftLanguageVersion". Updating the plubming will be a follow-on PR.
- Add init method with swiftLanguageModes parameter instead of swiftVersions - Mark existing init method as obsoleted in Swift 6 - Add renamed annotation to existing init method - Update one test of 5.2 package manifests that found new init methods ambiguous
…tion - Update build setting string to "swiftLanguageMode" - Rename Kind enum case in TargetBuildSettingDescription - Update naming in source and tests
- Add public swiftLanguageModes property to Package - Add computed property swiftVersions that accesses new property - Make swiftVersions obsolete for swift tools version 6 - Update to use new property name
@swift-ci test |
- Change 'obsoleted' to 'deprecated' where possible - Add back and deprecate swiftLanguageVersion() Swift setting - Deprecate SwiftVersion type alias
@swift-ci test |
@swift-ci test windows |
…aking it obsoleted
@swift-ci test |
@@ -271,7 +271,7 @@ public final class Package { | |||
products: [Product] = [], | |||
dependencies: [Dependency] = [], | |||
targets: [Target] = [], | |||
swiftLanguageVersions: [SwiftVersion]? = nil, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think in thise scheme new overload with swiftLanguageModes
needs default removed as well so we have to versions that accept explicit swiftLanguage* parameter and one that sets a default.
/// - cxxLanguageStandard: The C++ language standard to use for all C++ targets in this package. | ||
@available(_PackageDescription, introduced: 5.3) | ||
@available(_PackageDescription, deprecated: 6, renamed:"init(name:defaultLocalization:platforms:pkgConfig:providers:products:dependencies:targets:swiftLanguageModes:cLanguageStandard:cxxLanguageStandard:)") | ||
public init( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can get the same effect by removing this overload and using @_disfavoredOverload
on the old one, fewer overloads is usually easier to deal with, do you have a strong reference with this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't realize that @_disfavoredOverload
was acceptable in public API.
But since it seems to be acceptable, I think @_disfavoredOverload
would be a better way to go.
It would let us avoid adding a completely new init method just to have the overloads work out right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it's fine to use responsibly :)
@swift-ci test |
@swift-ci test windows |
@dempseyatgithub given the relatively short runway for 6.0, I'm happy to merge this (and the 6.0 cherry-pick #7813) now. We can implement any requested changes or revert on top as necessary, and this way we can actually test it out on the nightlies. Thank you for all your work here 🙏! |
@bnbarham This sounds good to me. I've brought the PR out of draft mode. I'm not well versed in the nuts and bolts of the release process for the project, so I am fine with whatever you think will work best.
You're very welcome and thank you and @xedin for all of your help! |
@swift-ci please test package compatibility |
…tLanguageVersion` Follow-up to swiftlang#7620 This is important for the manifest cache - make sure that older manifests that used original spelling of the build setting are still deserializable.
…tLanguageVersion` Follow-up to swiftlang#7620 This is important for the manifest cache - make sure that older manifests that used original spelling of the build setting are still deserializable. (cherry picked from commit 5189086)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙂
This PR implements the package manager changes in Swift evolution proposal SE-0441.