Skip to content

Commit e542d90

Browse files
authored
Update macro usage bookkeeping when replacing a target with a dynamic variant (#90)
1 parent 2dc9494 commit e542d90

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Sources/SWBTaskConstruction/ProductPlanning/ProductPlan.swift

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
8181
}
8282

8383
/// Maps targets to the set of macro implementations they should load when compiling Swift code.
84-
let swiftMacroImplementationDescriptorsByTarget: [ConfiguredTarget: Set<SwiftMacroImplementationDescriptor>]
84+
package private(set) var swiftMacroImplementationDescriptorsByTarget: [ConfiguredTarget: Set<SwiftMacroImplementationDescriptor>]
8585

8686
/// The set of targets which must build during prepare-for-indexing.
87-
package let targetsRequiredToBuildForIndexing: Set<ConfiguredTarget>
87+
package private(set) var targetsRequiredToBuildForIndexing: Set<ConfiguredTarget>
8888

8989
/// The set of targets which need to build a swiftmodule during installAPI
90-
package let targetsWhichShouldBuildModulesDuringInstallAPI: Set<ConfiguredTarget>?
90+
package private(set) var targetsWhichShouldBuildModulesDuringInstallAPI: Set<ConfiguredTarget>?
9191

9292
/// All targets in the product plan.
9393
/// - remark: This property is preferred over the `TargetBuildGraph` in the `BuildPlanRequest` as it performs additional computations for Swift packages.
@@ -787,6 +787,17 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
787787
let impartedBuildProperties = self.impartedBuildPropertiesByTarget[matchingTarget]
788788
self.impartedBuildPropertiesByTarget.removeValue(forKey: matchingTarget)
789789
self.impartedBuildPropertiesByTarget[dynamicConfiguredTarget] = impartedBuildProperties
790+
791+
let descriptors = self.swiftMacroImplementationDescriptorsByTarget.removeValue(forKey: matchingTarget)
792+
self.swiftMacroImplementationDescriptorsByTarget[dynamicConfiguredTarget] = descriptors
793+
794+
if self.targetsRequiredToBuildForIndexing.remove(matchingTarget) != nil {
795+
self.targetsRequiredToBuildForIndexing.insert(dynamicConfiguredTarget)
796+
}
797+
798+
if self.targetsWhichShouldBuildModulesDuringInstallAPI?.remove(matchingTarget) != nil {
799+
self.targetsWhichShouldBuildModulesDuringInstallAPI?.insert(dynamicConfiguredTarget)
800+
}
790801
}
791802
}
792803

0 commit comments

Comments
 (0)