@@ -29,7 +29,7 @@ public struct StaticBuildConfiguration: Codable {
29
29
customConditions: Set < String > = [ ] ,
30
30
features: Set < String > = [ ] ,
31
31
attributes: Set < String > = [ ] ,
32
- targetOSNames : Set < String > = [ ] ,
32
+ targetOSs : Set < String > = [ ] ,
33
33
targetArchitectures: Set < String > = [ ] ,
34
34
targetEnvironments: Set < String > = [ ] ,
35
35
targetRuntimes: Set < String > = [ ] ,
@@ -44,7 +44,7 @@ public struct StaticBuildConfiguration: Codable {
44
44
self . customConditions = customConditions
45
45
self . features = features
46
46
self . attributes = attributes
47
- self . targetOSNames = targetOSNames
47
+ self . targetOSs = targetOSs
48
48
self . targetArchitectures = targetArchitectures
49
49
self . targetEnvironments = targetEnvironments
50
50
self . targetRuntimes = targetRuntimes
@@ -53,7 +53,7 @@ public struct StaticBuildConfiguration: Codable {
53
53
self . targetPointerBitWidth = targetPointerBitWidth
54
54
self . targetAtomicBitWidths = targetAtomicBitWidths
55
55
self . endianness = endianness
56
- self . languageVersion = languageVersion
56
+ self . languageMode = languageVersion
57
57
self . compilerVersion = compilerVersion
58
58
}
59
59
@@ -95,22 +95,76 @@ public struct StaticBuildConfiguration: Codable {
95
95
/// ```
96
96
public var attributes : Set < String > = [ ]
97
97
98
- /// The active target OS names, e.g., "Windows", "iOS".
99
- public var targetOSNames : Set < String > = [ ]
98
+ /// The active target OS, e.g., "Windows", "iOS".
99
+ ///
100
+ /// The target operating system can be queried with `os(<name>)`, e.g.,
101
+ ///
102
+ /// ```swift
103
+ /// #if os(Linux)
104
+ /// // Linux-specific implementation
105
+ /// #endif
106
+ /// ```
107
+ public var targetOSs : Set < String > = [ ]
100
108
101
109
/// The active target architectures, e.g., "x64_64".
110
+ ///
111
+ /// The target processor architecture can be queried with `arch(<name>)`, e.g.,
112
+ ///
113
+ /// ```swift
114
+ /// #if arch(x86_64)
115
+ /// // 64-bit x86 Intel-specific code
116
+ /// #endif
117
+ /// ```
102
118
public var targetArchitectures : Set < String > = [ ]
103
119
104
120
/// The active target environments, e.g., "simulator".
121
+ ///
122
+ /// The target environment can be queried with `targetEnvironment(<name>)`,
123
+ /// e.g.,
124
+ ///
125
+ /// ```swift
126
+ /// #if targetEnvironment(simulator)
127
+ /// // Simulator-specific code
128
+ /// #endif
129
+ /// ```
105
130
public var targetEnvironments : Set < String > = [ ]
106
131
107
132
/// The active target runtimes, e.g., _ObjC.
133
+ ///
134
+ /// The target runtime can only be queried by an experimental syntax
135
+ /// `_runtime(<name>)`, e.g.,
136
+ ///
137
+ /// ```swift
138
+ /// #if _runtime(_ObjC)
139
+ /// // Code that depends on Swift being built for use with the Objective-C
140
+ /// // runtime, e.g., on Apple platforms.
141
+ /// #endif
142
+ /// ```
108
143
public var targetRuntimes : Set < String > = [ ]
109
144
110
145
/// The active target's pointer authentication schemes, e.g., "arm64e".
146
+ ///
147
+ /// The target pointer authentication scheme describes how pointers are
148
+ /// signed, as a security mitigation. This scheme can only be queried by
149
+ /// an experimental syntax `_ptrath(<name>)`, e.g.,
150
+ ///
151
+ /// ```swift
152
+ /// #if _ptrauth(arm64e)
153
+ /// // Special logic for arm64e pointer signing
154
+ /// #endif
155
+ /// ```
111
156
public var targetPointerAuthenticationSchemes : Set < String > = [ ]
112
157
113
158
/// The active target's object file formats, e.g., "COFF"
159
+ ///
160
+ /// The target object file format can only be queried by an experimental
161
+ /// syntax `_objectFileFormat(<name>)`, e.g.,
162
+ ///
163
+ /// ```swift
164
+ /// #if _objectFileFormat(ELF)
165
+ /// // Special logic for ELF object file formats
166
+ /// #endif
167
+ /// ```
114
168
public var targetObjectFileFormats : Set < String > = [ ]
115
169
116
170
/// The bit width of a data pointer for the target architecture.
@@ -151,17 +205,17 @@ public struct StaticBuildConfiguration: Codable {
151
205
/// ```
152
206
public var endianness : Endianness = . little
153
207
154
- /// The effective language version , which can be set by the user (e.g., 5.0).
208
+ /// The effective language mode , which can be set by the user (e.g., 5.0).
155
209
///
156
210
/// The language version can be queried with the `swift` directive that checks
157
211
/// how the supported language version compares, as described by
158
212
/// [SE-0212](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0212-compiler-version-directive.md). For example:
159
213
///
160
214
/// ```swift
161
- /// #if swift(>=5.5 )
215
+ /// #if swift(>=6.0 )
162
216
/// // Hooray, we can use tasks!
163
217
/// ```
164
- public var languageVersion : VersionTuple
218
+ public var languageMode : VersionTuple
165
219
166
220
/// The version of the compiler (e.g., 5.9).
167
221
///
@@ -264,7 +318,7 @@ extension StaticBuildConfiguration: BuildConfiguration {
264
318
/// - Returns: Whether the given operating system name is the target operating
265
319
/// system, i.e., the operating system for which code is being generated.
266
320
public func isActiveTargetOS( name: String ) -> Bool {
267
- targetOSNames . contains ( name)
321
+ targetOSs . contains ( name)
268
322
}
269
323
270
324
/// Determine whether the given name is the active target architecture
@@ -363,6 +417,12 @@ extension StaticBuildConfiguration: BuildConfiguration {
363
417
public func isActiveTargetObjectFileFormat( name: String ) -> Bool {
364
418
targetObjectFileFormats. contains ( name)
365
419
}
420
+
421
+ /// Equivalent to `languageMode`, but required for conformance to the
422
+ /// `BuildConfiguration` protocol.
423
+ public var languageVersion : VersionTuple {
424
+ languageMode
425
+ }
366
426
}
367
427
368
428
extension StaticBuildConfiguration {
@@ -376,11 +436,11 @@ extension StaticBuildConfiguration {
376
436
extension StaticBuildConfiguration {
377
437
/// The Swift version that can be set for the parser.
378
438
public var parserSwiftVersion : Parser . SwiftVersion {
379
- if languageVersion < VersionTuple ( 5 ) {
439
+ if languageMode < VersionTuple ( 5 ) {
380
440
return . v4
381
- } else if languageVersion < VersionTuple ( 6 ) {
441
+ } else if languageMode < VersionTuple ( 6 ) {
382
442
return . v5
383
- } else if languageVersion < VersionTuple ( 7 ) {
443
+ } else if languageMode < VersionTuple ( 7 ) {
384
444
return . v6
385
445
} else {
386
446
return Parser . defaultSwiftVersion
0 commit comments