-
Notifications
You must be signed in to change notification settings - Fork 162
Move platform requirements to availability annotations #348
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 1 commit
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 |
---|---|---|
@@ -1,15 +1,39 @@ | ||
// swift-tools-version: 5.8 | ||
|
||
import PackageDescription | ||
import CompilerPluginSupport | ||
|
||
// Availability Macros | ||
let availabilityTags = [_Availability("AsyncAlgorithms")] | ||
let versionNumbers = ["1.0"] | ||
|
||
// Availability Macro Utilities | ||
enum _OSAvailability: String { | ||
// This should match the package's deployment target | ||
case alwaysAvailable = "macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0" | ||
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. naming nit: this should probably be more so named |
||
// Use 10000 for future availability to avoid compiler magic around | ||
// the 9999 version number but ensure it is greater than 9999 | ||
case future = "macOS 10000, iOS 10000, tvOS 10000, watchOS 10000" | ||
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. it might be good to have a "pending" case for the 9999 versions |
||
} | ||
|
||
struct _Availability { | ||
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. ditto here on the underscore. |
||
let name: String | ||
let osAvailability: _OSAvailability | ||
|
||
init(_ name: String, availability: _OSAvailability = .alwaysAvailable) { | ||
self.name = name | ||
self.osAvailability = availability | ||
} | ||
} | ||
|
||
let availabilityMacros: [SwiftSetting] = versionNumbers.flatMap { version in | ||
availabilityTags.map { | ||
.enableExperimentalFeature("AvailabilityMacro=\($0.name) \(version):\($0.osAvailability.rawValue)") | ||
} | ||
} | ||
|
||
let package = Package( | ||
name: "swift-async-algorithms", | ||
platforms: [ | ||
.macOS("10.15"), | ||
.iOS("13.0"), | ||
.tvOS("13.0"), | ||
.watchOS("6.0"), | ||
], | ||
products: [ | ||
.library(name: "AsyncAlgorithms", targets: ["AsyncAlgorithms"]) | ||
], | ||
|
@@ -20,29 +44,29 @@ let package = Package( | |
.product(name: "OrderedCollections", package: "swift-collections"), | ||
.product(name: "DequeModule", package: "swift-collections"), | ||
], | ||
swiftSettings: [ | ||
swiftSettings: availabilityMacros + [ | ||
.enableExperimentalFeature("StrictConcurrency=complete") | ||
] | ||
), | ||
.target( | ||
name: "AsyncSequenceValidation", | ||
dependencies: ["_CAsyncSequenceValidationSupport", "AsyncAlgorithms"], | ||
swiftSettings: [ | ||
swiftSettings: availabilityMacros + [ | ||
.enableExperimentalFeature("StrictConcurrency=complete") | ||
] | ||
), | ||
.systemLibrary(name: "_CAsyncSequenceValidationSupport"), | ||
.target( | ||
name: "AsyncAlgorithms_XCTest", | ||
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation"], | ||
swiftSettings: [ | ||
swiftSettings: availabilityMacros + [ | ||
.enableExperimentalFeature("StrictConcurrency=complete") | ||
] | ||
), | ||
.testTarget( | ||
name: "AsyncAlgorithmsTests", | ||
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"], | ||
swiftSettings: [ | ||
swiftSettings: availabilityMacros + [ | ||
.enableExperimentalFeature("StrictConcurrency=complete") | ||
] | ||
), | ||
|
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.
naming nit: this doesn't need an underscore since this is not public API (it is restricted to the package)
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.
ack, this was copy-pasta from Foundation. I've fixed this up now.