@@ -38,7 +38,7 @@ extension DestinationError: CustomStringConvertible {
38
38
/// The compilation destination, has information about everything that's required for a certain destination.
39
39
public struct Destination : Encodable , Equatable {
40
40
41
- /// The clang/LLVM triple describing the target OS and architecture.
41
+ /// The clang/LLVM triple describing the destination's target OS and architecture.
42
42
///
43
43
/// The triple has the general format <arch><sub>-<vendor>-<sys>-<abi>, where:
44
44
/// - arch = x86_64, i386, arm, thumb, mips, etc.
@@ -48,16 +48,41 @@ public struct Destination: Encodable, Equatable {
48
48
/// - abi = eabi, gnu, android, macho, elf, etc.
49
49
///
50
50
/// for more information see //https://clang.llvm.org/docs/CrossCompilation.html
51
- public var target : Triple ?
51
+ public var destinationTriple : Triple ?
52
+
53
+ /// The clang/LLVM triple describing the host platform that supports this destination.
54
+ public let hostTriple : Triple ?
52
55
53
56
/// The architectures to build for. We build for host architecture if this is empty.
54
57
public var archs : [ String ] = [ ]
55
58
56
- /// The SDK used to compile for the destination.
57
- public var sdk : AbsolutePath ?
59
+ /// Root directory path of the SDK used to compile for the destination.
60
+ @available ( * , deprecated, message: " use `sdkRootDir` instead " )
61
+ public var sdk : AbsolutePath ? {
62
+ get {
63
+ sdkRootDir
64
+ }
65
+ set {
66
+ sdkRootDir = newValue
67
+ }
68
+ }
69
+
70
+ /// Root directory path of the SDK used to compile for the destination.
71
+ public var sdkRootDir : AbsolutePath ?
72
+
73
+ /// Path to a directory containing the toolchain (compilers/linker) to be used for the compilation.
74
+ @available ( * , deprecated, message: " use `toolchainBinDir` instead " )
75
+ public var binDir : AbsolutePath {
76
+ get {
77
+ toolchainBinDir
78
+ }
79
+ set {
80
+ toolchainBinDir = newValue
81
+ }
82
+ }
58
83
59
- /// The binDir in the containing the compilers/linker to be used for the compilation.
60
- public var binDir : AbsolutePath
84
+ /// Path to a directory containing the toolchain ( compilers/linker) to be used for the compilation.
85
+ public var toolchainBinDir : AbsolutePath
61
86
62
87
/// Additional flags to be passed to the C compiler.
63
88
@available ( * , deprecated, message: " use `extraFlags.cCompilerFlags` instead " )
@@ -81,7 +106,7 @@ public struct Destination: Encodable, Equatable {
81
106
public let extraFlags : BuildFlags
82
107
83
108
/// Creates a compilation destination with the specified properties.
84
- @available ( * , deprecated, message: " use `init(target:sdk:binDir :extraFlags)` instead " )
109
+ @available ( * , deprecated, message: " use `init(destinationTriple:sdkRootDir:toolchainBinDir :extraFlags)` instead " )
85
110
public init (
86
111
target: Triple ? = nil ,
87
112
sdk: AbsolutePath ? ,
@@ -90,9 +115,10 @@ public struct Destination: Encodable, Equatable {
90
115
extraSwiftCFlags: [ String ] = [ ] ,
91
116
extraCPPFlags: [ String ]
92
117
) {
93
- self . target = target
94
- self . sdk = sdk
95
- self . binDir = binDir
118
+ self . hostTriple = nil
119
+ self . destinationTriple = target
120
+ self . sdkRootDir = sdk
121
+ self . toolchainBinDir = binDir
96
122
self . extraFlags = BuildFlags (
97
123
cCompilerFlags: extraCCFlags,
98
124
cxxCompilerFlags: extraCPPFlags,
@@ -102,14 +128,16 @@ public struct Destination: Encodable, Equatable {
102
128
103
129
/// Creates a compilation destination with the specified properties.
104
130
public init (
105
- target: Triple ? = nil ,
106
- sdk: AbsolutePath ? ,
107
- binDir: AbsolutePath ,
131
+ hostTriple: Triple ? = nil ,
132
+ destinationTriple: Triple ? = nil ,
133
+ sdkRootDir: AbsolutePath ? ,
134
+ toolchainBinDir: AbsolutePath ,
108
135
extraFlags: BuildFlags = BuildFlags ( )
109
136
) {
110
- self . target = target
111
- self . sdk = sdk
112
- self . binDir = binDir
137
+ self . hostTriple = hostTriple
138
+ self . destinationTriple = destinationTriple
139
+ self . sdkRootDir = sdkRootDir
140
+ self . toolchainBinDir = toolchainBinDir
113
141
self . extraFlags = extraFlags
114
142
}
115
143
@@ -180,9 +208,8 @@ public struct Destination: Encodable, Equatable {
180
208
#endif
181
209
182
210
return Destination (
183
- target: nil ,
184
- sdk: sdkPath,
185
- binDir: binDir,
211
+ sdkRootDir: sdkPath,
212
+ toolchainBinDir: binDir,
186
213
extraFlags: BuildFlags ( cCompilerFlags: extraCCFlags, swiftCompilerFlags: extraSwiftCFlags)
187
214
)
188
215
}
@@ -217,13 +244,13 @@ public struct Destination: Encodable, Equatable {
217
244
/// Returns a default destination of a given target environment
218
245
public static func defaultDestination( for triple: Triple , host: Destination ) -> Destination ? {
219
246
if triple. isWASI ( ) {
220
- let wasiSysroot = host. binDir
247
+ let wasiSysroot = host. toolchainBinDir
221
248
. parentDirectory // usr
222
249
. appending ( components: " share " , " wasi-sysroot " )
223
250
return Destination (
224
- target : triple,
225
- sdk : wasiSysroot,
226
- binDir : host. binDir
251
+ destinationTriple : triple,
252
+ sdkRootDir : wasiSysroot,
253
+ toolchainBinDir : host. toolchainBinDir
227
254
)
228
255
}
229
256
return nil
@@ -241,9 +268,9 @@ extension Destination {
241
268
}
242
269
let destination = try decoder. decode ( path: path, fileSystem: fileSystem, as: DestinationInfo . self)
243
270
try self . init (
244
- target : destination. target. map { try Triple ( $0) } ,
245
- sdk : destination. sdk,
246
- binDir : destination. binDir,
271
+ destinationTriple : destination. target. map { try Triple ( $0) } ,
272
+ sdkRootDir : destination. sdk,
273
+ toolchainBinDir : destination. binDir,
247
274
extraFlags: BuildFlags (
248
275
cCompilerFlags: destination. extraCCFlags,
249
276
// maintaining `destination.extraCPPFlags` naming inconsistency for compatibility.
0 commit comments