@@ -26,6 +26,18 @@ public struct BuildParameters: Encodable {
26
26
case auto
27
27
}
28
28
29
+ /// The destination for which code should be compiled for.
30
+ public enum Destination : Encodable {
31
+ /// The destination for which build tools are compiled.
32
+ case host
33
+
34
+ /// The destination for which end products are compiled.
35
+ case target
36
+ }
37
+
38
+ /// The destination these parameters are going to be used for.
39
+ public let destination : Destination
40
+
29
41
/// The path to the data directory.
30
42
public var dataPath : AbsolutePath
31
43
@@ -118,6 +130,7 @@ public struct BuildParameters: Encodable {
118
130
public var testingParameters : Testing
119
131
120
132
public init (
133
+ destination: Destination ,
121
134
dataPath: AbsolutePath ,
122
135
configuration: BuildConfiguration ,
123
136
toolchain: Toolchain ,
@@ -144,6 +157,7 @@ public struct BuildParameters: Encodable {
144
157
omitFramePointers: nil
145
158
)
146
159
160
+ self . destination = destination
147
161
self . dataPath = dataPath
148
162
self . configuration = configuration
149
163
self . _toolchain = _Toolchain ( toolchain: toolchain)
@@ -243,18 +257,18 @@ public struct BuildParameters: Encodable {
243
257
244
258
/// Returns the path to the dynamic library of a product for the current build parameters.
245
259
func potentialDynamicLibraryPath( for product: ResolvedProduct ) throws -> RelativePath {
246
- try RelativePath ( validating: " \( self . triple. dynamicLibraryPrefix) \( product. name) \( self . suffix ( triple : product . buildTriple ) ) \( self . triple. dynamicLibraryExtension) " )
260
+ try RelativePath ( validating: " \( self . triple. dynamicLibraryPrefix) \( product. name) \( self . suffix) \( self . triple. dynamicLibraryExtension) " )
247
261
}
248
262
249
263
/// Returns the path to the binary of a product for the current build parameters, relative to the build directory.
250
264
public func binaryRelativePath( for product: ResolvedProduct ) throws -> RelativePath {
251
- let potentialExecutablePath = try RelativePath ( validating: " \( product. name) \( self . suffix ( triple : product . buildTriple ) ) \( self . triple. executableExtension) " )
265
+ let potentialExecutablePath = try RelativePath ( validating: " \( product. name) \( self . suffix) \( self . triple. executableExtension) " )
252
266
253
267
switch product. type {
254
268
case . executable, . snippet:
255
269
return potentialExecutablePath
256
270
case . library( . static) :
257
- return try RelativePath ( validating: " lib \( product. name) \( self . suffix ( triple : product . buildTriple ) ) \( self . triple. staticLibraryExtension) " )
271
+ return try RelativePath ( validating: " lib \( product. name) \( self . suffix) \( self . triple. staticLibraryExtension) " )
258
272
case . library( . dynamic) :
259
273
return try potentialDynamicLibraryPath ( for: product)
260
274
case . library( . automatic) , . plugin:
@@ -333,7 +347,7 @@ extension Triple {
333
347
extension BuildParameters {
334
348
/// Suffix appended to build manifest nodes to distinguish nodes created for tools from nodes created for
335
349
/// end products, i.e. nodes for host vs target triples.
336
- package func suffix( triple : BuildTriple ) -> String {
337
- if triple == . tools { " -tool " } else { " " }
350
+ package var suffix : String {
351
+ if destination == . host { " -tool " } else { " " }
338
352
}
339
353
}
0 commit comments