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

Adopt language mode naming in PackageDescription API #7620

Merged
merged 16 commits into from
Jul 24, 2024

Conversation

dempseyatgithub
Copy link
Contributor

@dempseyatgithub dempseyatgithub commented May 31, 2024

This PR implements the package manager changes in Swift evolution proposal SE-0441.

@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor

@xedin xedin left a 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.

Sources/PackageDescription/BuildSettings.swift Outdated Show resolved Hide resolved
Tests/PackageLoadingTests/PD_5_2_LoadingTests.swift Outdated Show resolved Hide resolved
Sources/PackageDescription/PackageDescription.swift Outdated Show resolved Hide resolved
@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

@dempseyatgithub
Copy link
Contributor Author

Overall LGTM, I'm not sure about new initializer though, it seems like that could some unfortunate ambiguity issues because renamed parameter is defaulted.

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 renamed annotation allows the compiler to provide a fix-it.

@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test package compatibility

@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

@dempseyatgithub
Copy link
Contributor Author

dempseyatgithub commented Jun 2, 2024

@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:

  1. Would it be desirable for me to clean up the commits for this PR and then force push it, so the commits and commit messages are nicer? If so, I can do that.

  2. Is there anything else I need to do before this PR can be considered a valid implementation of the proposal? (At least the Swift PM piece of the proposal)

  3. How do you kick off Windows Platform ci tests?

Thank you for your help with this.

@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test

@xedin
Copy link
Contributor

xedin commented Jun 3, 2024

Would it be desirable for me to clean up the commits for this PR and then force push it, so the commits and commit messages are nicer? If so, I can do that.

We can squash merge everything so you can add all the information you'd like in the commit message to the PR description.

Is there anything else I need to do before this PR can be considered a valid implementation of the proposal? (At least the Swift PM piece of the proposal)

I think this is pretty much it.

How do you kick off Windows Platform ci tests?

@swift-ci please test Windows platform

@MaxDesiatov MaxDesiatov changed the title Adopt language mode naming in Swift PM API Adopt language mode naming in PackageDescription API Jun 4, 2024
@MaxDesiatov
Copy link
Contributor

@swift-ci please test Windows platform

both please and platform are redundant, and it's case-insensitive, so plain @swift-ci test windows also works.

@dempseyatgithub
Copy link
Contributor Author

@swift-ci test

@dempseyatgithub
Copy link
Contributor Author

@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(
Copy link
Contributor

@MaxDesiatov MaxDesiatov Jun 27, 2024

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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 🤷

@MaxDesiatov MaxDesiatov dismissed their stale review June 27, 2024 15:31

API compatibility concerns addressed.

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@dempseyatgithub dempseyatgithub force-pushed the adopt-language-mode-naming branch from 7ec5369 to 7481db7 Compare July 9, 2024 19:07
@dempseyatgithub
Copy link
Contributor Author

@swift-ci test

1 similar comment
@dempseyatgithub
Copy link
Contributor Author

@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
@MaxDesiatov
Copy link
Contributor

@swift-ci test

- Change 'obsoleted' to 'deprecated' where possible
- Add back and deprecate swiftLanguageVersion() Swift setting
- Deprecate SwiftVersion type alias
@dempseyatgithub
Copy link
Contributor Author

@swift-ci test

@dempseyatgithub
Copy link
Contributor Author

@swift-ci test windows

@dempseyatgithub
Copy link
Contributor Author

@swift-ci test

@@ -271,7 +271,7 @@ public final class Package {
products: [Product] = [],
dependencies: [Dependency] = [],
targets: [Target] = [],
swiftLanguageVersions: [SwiftVersion]? = nil,
Copy link
Contributor

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(
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 :)

@dempseyatgithub
Copy link
Contributor Author

@swift-ci test

@dempseyatgithub
Copy link
Contributor Author

@swift-ci test windows

@bnbarham
Copy link
Contributor

bnbarham commented Jul 24, 2024

@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 🙏!

@dempseyatgithub dempseyatgithub marked this pull request as ready for review July 24, 2024 09:04
@dempseyatgithub
Copy link
Contributor Author

dempseyatgithub commented Jul 24, 2024

@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.

@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.

Thank you for all your work here 🙏!

You're very welcome and thank you and @xedin for all of your help!

@dempseyatgithub
Copy link
Contributor Author

@swift-ci please test package compatibility

@bnbarham bnbarham merged commit 12c1422 into swiftlang:main Jul 24, 2024
6 checks passed
xedin added a commit to xedin/swift-package-manager that referenced this pull request Jul 26, 2024
…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.
xedin added a commit to xedin/swift-package-manager that referenced this pull request Jul 26, 2024
…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)
bnbarham pushed a commit that referenced this pull request Jul 26, 2024
…tLanguageVersion`

Follow-up to #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)
xedin added a commit that referenced this pull request Jul 26, 2024
#7827)

…tLanguageVersion`

Follow-up to
#7620

This is important for the manifest cache - make sure that older
manifests that used original spelling of the build setting are still
deserializable.
Copy link

@dji1admin dji1admin left a comment

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.

5 participants