Skip to content

Commit 2410aed

Browse files
authored
Merge pull request #251 from apple/release/1.6.0
Merge 1.6.x into main
2 parents d89ca1d + 9226c72 commit 2410aed

36 files changed

+262
-275
lines changed

.github/workflows/pull_request.yml

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,34 @@ jobs:
1010
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
1111
with:
1212
linux_os_versions: '["jammy", "focal"]'
13-
enable_macos_checks: false
14-
macos_xcode_versions: '["16.3"]'
13+
enable_macos_checks: true
14+
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
15+
# Xcode 16.0 and 16.1 are not actually available
16+
macos_exclude_xcode_versions: |
17+
[
18+
{"xcode_version": "16.0"},
19+
{"xcode_version": "16.1"},
20+
]
21+
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI"
22+
23+
build-abi-stable:
24+
name: Build ABI Stable
25+
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
26+
with:
27+
enable_linux_checks: false
28+
enable_macos_checks: true
29+
enable_windows_checks: false
30+
# Only build
31+
macos_build_command: "xcrun swift build --build-tests"
32+
# FIXME: https://github.com/swiftlang/github-workflows/pull/140
33+
# Xcode 16.0 and 16.1 are not actually available
34+
macos_exclude_xcode_versions: |
35+
[
36+
{"xcode_version": "16.0"},
37+
{"xcode_version": "16.1"},
38+
]
39+
# Enable availability to match ABI stable verion of system.
40+
swift_flags: "-Xbuild-tools-swiftc -DSYSTEM_CI -Xbuild-tools-swiftc -DSYSTEM_ABI_STABLE"
1541

1642
soundness:
1743
name: Soundness

Package.swift

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,71 @@
1212

1313
import PackageDescription
1414

15-
let cSettings: [CSetting] = [
16-
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
15+
struct Available {
16+
var name: String
17+
var version: String
18+
var osAvailability: String
19+
var sourceAvailability: String
20+
21+
init(
22+
_ version: String,
23+
_ osAvailability: String
24+
) {
25+
self.name = "System"
26+
self.version = version
27+
self.osAvailability = osAvailability
28+
self.sourceAvailability = "macOS 10.10, iOS 8.0, watchOS 2.0, tvOS 9.0, visionOS 1.0"
29+
}
30+
31+
var swiftSetting: SwiftSetting {
32+
#if SYSTEM_ABI_STABLE
33+
// Use availability matching Darwin API.
34+
let availability = self.osAvailability
35+
#else
36+
// Use availability matching SwiftPM default.
37+
let availability = self.sourceAvailability
38+
#endif
39+
return .enableExperimentalFeature(
40+
"AvailabilityMacro=\(self.name) \(version):\(availability)")
41+
}
42+
}
43+
44+
let availability: [Available] = [
45+
Available("0.0.1", "macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0"),
46+
47+
Available("0.0.2", "macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0"),
48+
49+
Available("0.0.3", "macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4"),
50+
Available("1.1.0", "macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4"),
51+
52+
Available("1.1.1", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4"),
53+
Available("1.2.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4"),
54+
55+
Available("1.2.1", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4"),
56+
Available("1.3.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4"),
57+
58+
Available("1.3.1", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
59+
Available("1.3.2", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
60+
Available("1.4.0", "macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.0"),
61+
62+
Available("1.4.1", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
63+
Available("1.4.2", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
64+
Available("1.5.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
65+
Available("1.6.0", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
66+
Available("1.6.1", "macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999"),
67+
]
68+
69+
let swiftSettingsAvailability = availability.map(\.swiftSetting)
70+
71+
#if SYSTEM_CI
72+
let swiftSettingsCI: [SwiftSetting] = [
73+
.unsafeFlags(["-require-explicit-availability=error"]),
1774
]
75+
#else
76+
let swiftSettingsCI: [SwiftSetting] = []
77+
#endif
1878

19-
let swiftSettings: [SwiftSetting] = [
79+
let swiftSettings = swiftSettingsAvailability + swiftSettingsCI + [
2080
.define(
2181
"SYSTEM_PACKAGE_DARWIN",
2282
.when(platforms: [.macOS, .macCatalyst, .iOS, .watchOS, .tvOS, .visionOS])),
@@ -25,6 +85,22 @@ let swiftSettings: [SwiftSetting] = [
2585
.enableExperimentalFeature("Lifetimes"),
2686
]
2787

88+
let cSettings: [CSetting] = [
89+
.define("_CRT_SECURE_NO_WARNINGS", .when(platforms: [.windows])),
90+
]
91+
92+
#if SYSTEM_ABI_STABLE
93+
let platforms: [SupportedPlatform] = [
94+
.macOS("26"),
95+
.iOS("26"),
96+
.watchOS("26"),
97+
.tvOS("26"),
98+
.visionOS("26"),
99+
]
100+
#else
101+
let platforms: [SupportedPlatform]? = nil
102+
#endif
103+
28104
#if os(Linux)
29105
let filesToExclude = ["CMakeLists.txt"]
30106
#else
@@ -39,6 +115,7 @@ let testsToExclude = ["IORequestTests.swift", "IORingTests.swift"]
39115

40116
let package = Package(
41117
name: "swift-system",
118+
platforms: platforms,
42119
products: [
43120
.library(name: "SystemPackage", targets: ["SystemPackage"]),
44121
],
@@ -63,3 +140,4 @@ let package = Package(
63140
cSettings: cSettings,
64141
swiftSettings: swiftSettings),
65142
])
143+

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ To use the `SystemPackage` library in a SwiftPM project,
3232
add the following line to the dependencies in your `Package.swift` file:
3333

3434
```swift
35-
.package(url: "https://github.com/apple/swift-system", from: "1.6.0"),
35+
.package(url: "https://github.com/apple/swift-system", from: "1.6.1"),
3636
```
3737

3838
Finally, include `"SystemPackage"` as a dependency for your executable target:
@@ -41,7 +41,7 @@ Finally, include `"SystemPackage"` as a dependency for your executable target:
4141
let package = Package(
4242
// name, platforms, products, etc.
4343
dependencies: [
44-
.package(url: "https://github.com/apple/swift-system", from: "1.6.0"),
44+
.package(url: "https://github.com/apple/swift-system", from: "1.6.1"),
4545
// other dependencies
4646
],
4747
targets: [

Sources/System/Errno.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/// An error number used by system calls to communicate what kind of error
1111
/// occurred.
1212
@frozen
13-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
13+
@available(System 0.0.1, *)
1414
public struct Errno: RawRepresentable, Error, Hashable, Codable {
1515
/// The raw C error number.
1616
@_alwaysEmitIntoClient
@@ -1391,7 +1391,7 @@ public struct Errno: RawRepresentable, Error, Hashable, Codable {
13911391
}
13921392

13931393
// Constants defined in header but not man page
1394-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
1394+
@available(System 0.0.1, *)
13951395
extension Errno {
13961396
/// Operation would block.
13971397
///
@@ -1520,7 +1520,7 @@ extension Errno {
15201520
#endif
15211521
}
15221522

1523-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
1523+
@available(System 0.0.1, *)
15241524
extension Errno {
15251525
// TODO: We want to provide safe access to `errno`, but we need a
15261526
// release-barrier to do so.
@@ -1535,14 +1535,14 @@ extension Errno {
15351535
}
15361536

15371537
// Use "hidden" entry points for `NSError` bridging
1538-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
1538+
@available(System 0.0.1, *)
15391539
extension Errno {
15401540
public var _code: Int { Int(rawValue) }
15411541

15421542
public var _domain: String { "NSPOSIXErrorDomain" }
15431543
}
15441544

1545-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
1545+
@available(System 0.0.1, *)
15461546
extension Errno: CustomStringConvertible, CustomDebugStringConvertible {
15471547
/// A textual representation of the most recent error
15481548
/// returned by a system call.
@@ -1562,7 +1562,7 @@ extension Errno: CustomStringConvertible, CustomDebugStringConvertible {
15621562
public var debugDescription: String { self.description }
15631563
}
15641564

1565-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
1565+
@available(System 0.0.1, *)
15661566
extension Errno {
15671567
@_alwaysEmitIntoClient
15681568
public static func ~=(_ lhs: Errno, _ rhs: Error) -> Bool {

Sources/System/FileDescriptor.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/// of `FileDescriptor` values,
1515
/// in the same way as you manage a raw C file handle.
1616
@frozen
17-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
17+
@available(System 0.0.1, *)
1818
public struct FileDescriptor: RawRepresentable, Hashable, Codable {
1919
/// The raw C file handle.
2020
@_alwaysEmitIntoClient
@@ -26,7 +26,7 @@ public struct FileDescriptor: RawRepresentable, Hashable, Codable {
2626
}
2727

2828
// Standard file descriptors.
29-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
29+
@available(System 0.0.1, *)
3030
extension FileDescriptor {
3131
/// The standard input file descriptor, with a numeric value of 0.
3232
@_alwaysEmitIntoClient
@@ -41,11 +41,11 @@ extension FileDescriptor {
4141
public static var standardError: FileDescriptor { .init(rawValue: 2) }
4242
}
4343

44-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
44+
@available(System 0.0.1, *)
4545
extension FileDescriptor {
4646
/// The desired read and write access for a newly opened file.
4747
@frozen
48-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
48+
@available(System 0.0.1, *)
4949
public struct AccessMode: RawRepresentable, Sendable, Hashable, Codable {
5050
/// The raw C access mode.
5151
@_alwaysEmitIntoClient
@@ -88,7 +88,7 @@ extension FileDescriptor {
8888

8989
/// Options that specify behavior for a newly-opened file.
9090
@frozen
91-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
91+
@available(System 0.0.1, *)
9292
public struct OpenOptions: OptionSet, Sendable, Hashable, Codable {
9393
/// The raw C options.
9494
@_alwaysEmitIntoClient
@@ -326,7 +326,7 @@ extension FileDescriptor {
326326

327327
/// Options for specifying what a file descriptor's offset is relative to.
328328
@frozen
329-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
329+
@available(System 0.0.1, *)
330330
public struct SeekOrigin: RawRepresentable, Sendable, Hashable, Codable {
331331
/// The raw C value.
332332
@_alwaysEmitIntoClient
@@ -402,7 +402,7 @@ extension FileDescriptor {
402402
}
403403
}
404404

405-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
405+
@available(System 0.0.1, *)
406406
extension FileDescriptor.AccessMode
407407
: CustomStringConvertible, CustomDebugStringConvertible
408408
{
@@ -421,7 +421,7 @@ extension FileDescriptor.AccessMode
421421
public var debugDescription: String { self.description }
422422
}
423423

424-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
424+
@available(System 0.0.1, *)
425425
extension FileDescriptor.SeekOrigin
426426
: CustomStringConvertible, CustomDebugStringConvertible
427427
{
@@ -444,7 +444,7 @@ extension FileDescriptor.SeekOrigin
444444
public var debugDescription: String { self.description }
445445
}
446446

447-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
447+
@available(System 0.0.1, *)
448448
extension FileDescriptor.OpenOptions
449449
: CustomStringConvertible, CustomDebugStringConvertible
450450
{

Sources/System/FileHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
10+
@available(System 0.0.1, *)
1111
extension FileDescriptor {
1212
/// Runs a closure and then closes the file descriptor, even if an error occurs.
1313
///

Sources/System/FileOperations.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
See https://swift.org/LICENSE.txt for license information
88
*/
99

10-
@available(/*System 0.0.1: macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0*/iOS 8, *)
10+
@available(System 0.0.1, *)
1111
extension FileDescriptor {
1212
/// Opens or creates a file for reading or writing.
1313
///
@@ -368,7 +368,7 @@ extension FileDescriptor {
368368
}
369369

370370
#if !os(WASI)
371-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
371+
@available(System 0.0.2, *)
372372
extension FileDescriptor {
373373
/// Duplicates this file descriptor and return the newly created copy.
374374
///
@@ -398,15 +398,15 @@ extension FileDescriptor {
398398
///
399399
/// The corresponding C functions are `dup` and `dup2`.
400400
@_alwaysEmitIntoClient
401-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
401+
@available(System 0.0.2, *)
402402
public func duplicate(
403403
as target: FileDescriptor? = nil,
404404
retryOnInterrupt: Bool = true
405405
) throws -> FileDescriptor {
406406
try _duplicate(as: target, retryOnInterrupt: retryOnInterrupt).get()
407407
}
408408

409-
@available(/*System 0.0.2: macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0*/iOS 8, *)
409+
@available(System 0.0.2, *)
410410
@usableFromInline
411411
internal func _duplicate(
412412
as target: FileDescriptor?,
@@ -435,20 +435,20 @@ extension FileDescriptor {
435435
#endif
436436

437437
#if !os(WASI)
438-
@available(/*System 1.1.0: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4*/iOS 8, *)
438+
@available(System 1.1.0, *)
439439
extension FileDescriptor {
440440
/// Creates a unidirectional data channel, which can be used for interprocess communication.
441441
///
442442
/// - Returns: The pair of file descriptors.
443443
///
444444
/// The corresponding C function is `pipe`.
445445
@_alwaysEmitIntoClient
446-
@available(/*System 1.1.0: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4*/iOS 8, *)
446+
@available(System 1.1.0, *)
447447
public static func pipe() throws -> (readEnd: FileDescriptor, writeEnd: FileDescriptor) {
448448
try _pipe().get()
449449
}
450450

451-
@available(/*System 1.1.0: macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4*/iOS 8, *)
451+
@available(System 1.1.0, *)
452452
@usableFromInline
453453
internal static func _pipe() -> Result<(readEnd: FileDescriptor, writeEnd: FileDescriptor), Errno> {
454454
var fds: (Int32, Int32) = (-1, -1)
@@ -463,7 +463,7 @@ extension FileDescriptor {
463463
}
464464
#endif
465465

466-
@available(/*System 1.2.0: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999*/iOS 8, *)
466+
@available(System 1.2.0, *)
467467
extension FileDescriptor {
468468
/// Truncates or extends the file referenced by this file descriptor.
469469
///
@@ -485,7 +485,7 @@ extension FileDescriptor {
485485
/// associated with the file.
486486
///
487487
/// The corresponding C function is `ftruncate`.
488-
@available(/*System 1.2.0: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999*/iOS 8, *)
488+
@available(System 1.2.0, *)
489489
@_alwaysEmitIntoClient
490490
public func resize(
491491
to newSize: Int64,
@@ -497,7 +497,7 @@ extension FileDescriptor {
497497
).get()
498498
}
499499

500-
@available(/*System 1.2.0: macOS 9999, iOS 9999, watchOS 9999, tvOS 9999*/iOS 8, *)
500+
@available(System 1.2.0, *)
501501
@usableFromInline
502502
internal func _resize(
503503
to newSize: Int64,

0 commit comments

Comments
 (0)