-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adopt language mode naming in PackageDescription
API
#7620
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
Changes from 15 commits
4a74d64
3d80f9c
50f4e0f
64180d7
25c29b7
54029d0
b650dcb
0112629
c59d5ae
95af338
b53eb42
3f484ff
2d93cd4
fbdbb1d
262664c
83c96a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,5 +35,5 @@ let package = Package( | |
] | ||
), | ||
], | ||
swiftLanguageVersions: [.v5] | ||
swiftLanguageModes: [.v5] | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,8 +108,15 @@ public final class Package { | |
/// The list of package dependencies. | ||
public var dependencies: [Dependency] | ||
|
||
/// The list of Swift versions with which this package is compatible. | ||
public var swiftLanguageVersions: [SwiftVersion]? | ||
/// The list of Swift language modes with which this package is compatible. | ||
public var swiftLanguageModes: [SwiftLanguageMode]? | ||
|
||
/// Legacy property name, accesses value of `swiftLanguageModes` | ||
@available(_PackageDescription, deprecated: 6, renamed: "swiftLanguageModes") | ||
public var swiftLanguageVersions: [SwiftVersion]? { | ||
get { swiftLanguageModes } | ||
set { swiftLanguageModes = newValue } | ||
} | ||
|
||
/// The C language standard to use for all C targets in this package. | ||
public var cLanguageStandard: CLanguageStandard? | ||
|
@@ -151,7 +158,7 @@ public final class Package { | |
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageVersions = swiftLanguageVersions.map{ $0.map{ .version("\($0)") } } | ||
self.swiftLanguageModes = swiftLanguageVersions.map{ $0.map{ .version("\($0)") } } | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
|
@@ -190,7 +197,7 @@ public final class Package { | |
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageVersions = swiftLanguageVersions | ||
self.swiftLanguageModes = swiftLanguageVersions | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
|
@@ -232,7 +239,7 @@ public final class Package { | |
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageVersions = swiftLanguageVersions | ||
self.swiftLanguageModes = swiftLanguageVersions | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
|
@@ -254,6 +261,51 @@ public final class Package { | |
/// - cLanguageStandard: The C language standard to use for all C targets in this package. | ||
/// - 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( | ||
name: String, | ||
defaultLocalization: LanguageTag? = nil, | ||
platforms: [SupportedPlatform]? = nil, | ||
pkgConfig: String? = nil, | ||
providers: [SystemPackageProvider]? = nil, | ||
products: [Product] = [], | ||
dependencies: [Dependency] = [], | ||
targets: [Target] = [], | ||
swiftLanguageVersions: [SwiftVersion]?, | ||
cLanguageStandard: CLanguageStandard? = nil, | ||
cxxLanguageStandard: CXXLanguageStandard? = nil | ||
) { | ||
self.name = name | ||
self.defaultLocalization = defaultLocalization | ||
self.platforms = platforms | ||
self.pkgConfig = pkgConfig | ||
self.providers = providers | ||
self.products = products | ||
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageModes = swiftLanguageVersions | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
} | ||
|
||
/// Initializes a Swift package with configuration options you provide. | ||
/// | ||
/// - Parameters: | ||
/// - name: The name of the Swift package, or `nil` to use the package's Git URL to deduce the name. | ||
/// - defaultLocalization: The default localization for resources. | ||
/// - platforms: The list of supported platforms with a custom deployment target. | ||
/// - pkgConfig: The name to use for C modules. If present, Swift Package Manager searches for a | ||
/// `<name>.pc` file to get the additional flags required for a system target. | ||
/// - providers: The package providers for a system target. | ||
/// - products: The list of products that this package makes available for clients to use. | ||
/// - dependencies: The list of package dependencies. | ||
/// - targets: The list of targets that are part of this package. | ||
/// - cLanguageStandard: The C language standard to use for all C targets in this package. | ||
/// - 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't realize that But since it seems to be acceptable, I think 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 commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it's fine to use responsibly :) |
||
name: String, | ||
defaultLocalization: LanguageTag? = nil, | ||
|
@@ -263,7 +315,6 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. I think in thise scheme new overload with |
||
cLanguageStandard: CLanguageStandard? = nil, | ||
cxxLanguageStandard: CXXLanguageStandard? = nil | ||
) { | ||
|
@@ -276,12 +327,58 @@ public final class Package { | |
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageVersions = swiftLanguageVersions | ||
self.swiftLanguageModes = [] | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
} | ||
|
||
|
||
/// Initializes a Swift package with configuration options you provide. | ||
/// | ||
/// - Parameters: | ||
/// - name: The name of the Swift package, or `nil` to use the package's Git URL to deduce the name. | ||
/// - defaultLocalization: The default localization for resources. | ||
/// - platforms: The list of supported platforms with a custom deployment target. | ||
/// - pkgConfig: The name to use for C modules. If present, Swift Package Manager searches for a | ||
/// `<name>.pc` file to get the additional flags required for a system target. | ||
/// - providers: The package providers for a system target. | ||
/// - products: The list of products that this package makes available for clients to use. | ||
/// - dependencies: The list of package dependencies. | ||
/// - targets: The list of targets that are part of this package. | ||
/// - swiftLanguageModes: The list of Swift language modes with which this package is compatible. | ||
/// - cLanguageStandard: The C language standard to use for all C targets in this package. | ||
/// - cxxLanguageStandard: The C++ language standard to use for all C++ targets in this package. | ||
@available(_PackageDescription, introduced: 6) | ||
public init( | ||
xedin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
name: String, | ||
defaultLocalization: LanguageTag? = nil, | ||
platforms: [SupportedPlatform]? = nil, | ||
pkgConfig: String? = nil, | ||
providers: [SystemPackageProvider]? = nil, | ||
products: [Product] = [], | ||
dependencies: [Dependency] = [], | ||
targets: [Target] = [], | ||
swiftLanguageModes: [SwiftLanguageMode]? = nil, | ||
cLanguageStandard: CLanguageStandard? = nil, | ||
cxxLanguageStandard: CXXLanguageStandard? = nil | ||
) { | ||
self.name = name | ||
self.defaultLocalization = defaultLocalization | ||
self.platforms = platforms | ||
self.pkgConfig = pkgConfig | ||
self.providers = providers | ||
self.products = products | ||
self.dependencies = dependencies | ||
self.targets = targets | ||
self.traits = [] | ||
self.swiftLanguageModes = swiftLanguageModes | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
} | ||
|
||
|
||
/// Initializes a Swift package with configuration options you provide. | ||
/// | ||
/// - Parameters: | ||
|
@@ -295,7 +392,7 @@ public final class Package { | |
/// - traits: The set of traits of this package. | ||
/// - dependencies: The list of package dependencies. | ||
/// - targets: The list of targets that are part of this package. | ||
/// - swiftLanguageVersions: The list of Swift versions with which this package is compatible. | ||
/// - swiftLanguageModes: The list of Swift language modes with which this package is compatible. | ||
/// - cLanguageStandard: The C language standard to use for all C targets in this package. | ||
/// - cxxLanguageStandard: The C++ language standard to use for all C++ targets in this package. | ||
@_spi(ExperimentalTraits) | ||
xedin marked this conversation as resolved.
Show resolved
Hide resolved
xedin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
@@ -310,7 +407,7 @@ public final class Package { | |
traits: Set<Trait> = [], | ||
dependencies: [Dependency] = [], | ||
targets: [Target] = [], | ||
swiftLanguageVersions: [SwiftVersion]? = nil, | ||
swiftLanguageModes: [SwiftLanguageMode]? = nil, | ||
cLanguageStandard: CLanguageStandard? = nil, | ||
cxxLanguageStandard: CXXLanguageStandard? = nil | ||
) { | ||
|
@@ -323,7 +420,7 @@ public final class Package { | |
self.traits = traits | ||
self.dependencies = dependencies | ||
self.targets = targets | ||
self.swiftLanguageVersions = swiftLanguageVersions | ||
self.swiftLanguageModes = swiftLanguageModes | ||
self.cLanguageStandard = cLanguageStandard | ||
self.cxxLanguageStandard = cxxLanguageStandard | ||
registerExitHandler() | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
We can just deprecate it and then remove when we remove the other
swiftLanguageVersion
🤷