@@ -39,6 +39,9 @@ public struct ResolvedProduct: Hashable {
39
39
/// The list of platforms that are supported by this product.
40
40
public let supportedPlatforms : [ SupportedPlatform ]
41
41
42
+ /// Triple for which this resolved product should be compiled for.
43
+ public let buildTriple : BuildTriple
44
+
42
45
public let platformVersionProvider : PlatformVersionProvider
43
46
44
47
/// The main executable target of product.
@@ -60,11 +63,24 @@ public struct ResolvedProduct: Hashable {
60
63
61
64
public init ( product: Product , targets: [ ResolvedTarget ] ) {
62
65
assert ( product. targets. count == targets. count && product. targets. map ( \. name) == targets. map ( \. name) )
63
- let ( supportedPlatforms, platformVersionProvider) = Self . computePlatforms ( targets: targets)
64
66
let defaultLocalization = targets. first? . defaultLocalization
65
-
67
+
68
+ let processedTargets : [ ResolvedTarget ]
69
+ if product. type == . macro || product. type == . plugin {
70
+ self . buildTriple = . buildTools
71
+ processedTargets = targets. map ( \. buildToolsTarget)
72
+ } else {
73
+ self . buildTriple = . buildProducts
74
+ processedTargets = targets
75
+ }
76
+
66
77
self . underlying = product
67
- self . targets = targets
78
+ self . targets = processedTargets
79
+
80
+ let ( supportedPlatforms, platformVersionProvider) = Self . computePlatforms ( targets: targets)
81
+ self . supportedPlatforms = supportedPlatforms
82
+ self . platformVersionProvider = platformVersionProvider
83
+
68
84
self . testEntryPointTarget = product. testEntryPointPath. map { testEntryPointPath in
69
85
// Create an executable resolved target with the entry point file, adding product's targets as dependencies.
70
86
let dependencies : [ Target . Dependency ] = product. targets. map { . target( $0, conditions: [ ] ) }
@@ -88,8 +104,6 @@ public struct ResolvedProduct: Hashable {
88
104
// defaultLocalization is currently shared across the entire package
89
105
// this may need to be enhanced if / when we support localization per target or product
90
106
self . defaultLocalization = defaultLocalization
91
- self . supportedPlatforms = supportedPlatforms
92
- self . platformVersionProvider = platformVersionProvider
93
107
}
94
108
95
109
/// True if this product contains Swift targets.
0 commit comments