Skip to content

Commit ae67dde

Browse files
committed
Move updateConfiguration out of package diamond detection loop
1 parent 10cf4ea commit ae67dde

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

Sources/SWBTaskConstruction/ProductPlanning/ProductPlan.swift

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -936,37 +936,6 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
936936
// This only suppresses duplicate diagnostics.
937937
var packageTargetsToIgnore = Set<ConfiguredTarget>()
938938

939-
let updateConfiguration = { (configuredTarget: ConfiguredTarget, dynamicTarget: SWBCore.Target) in
940-
// If the `targetTaskInfo` for the static target isn't present, we already made the decision to make this target dynamic.
941-
if self.targetGateNodes[configuredTarget] == nil { return }
942-
943-
// There can be multiple configured targets for the dynamic target, we have to update all of them.
944-
let matchingConfiguredTargets = self.targetGateNodes.keys.filter { $0.target.guid == configuredTarget.target.guid }
945-
946-
for matchingTarget in matchingConfiguredTargets {
947-
guard let taskInfo = self.targetGateNodes[matchingTarget] else { return }
948-
let dynamicConfiguredTarget = matchingTarget.replacingTarget(dynamicTarget)
949-
950-
self.targetGateNodes.removeValue(forKey: matchingTarget)
951-
self.targetGateNodes[dynamicConfiguredTarget] = taskInfo
952-
953-
let impartedBuildProperties = self.impartedBuildPropertiesByTarget[matchingTarget]
954-
self.impartedBuildPropertiesByTarget.removeValue(forKey: matchingTarget)
955-
self.impartedBuildPropertiesByTarget[dynamicConfiguredTarget] = impartedBuildProperties
956-
957-
let descriptors = self.swiftMacroImplementationDescriptorsByTarget.removeValue(forKey: matchingTarget)
958-
self.swiftMacroImplementationDescriptorsByTarget[dynamicConfiguredTarget] = descriptors
959-
960-
if self.targetsRequiredToBuildForIndexing.remove(matchingTarget) != nil {
961-
self.targetsRequiredToBuildForIndexing.insert(dynamicConfiguredTarget)
962-
}
963-
964-
if self.targetsWhichShouldBuildModulesDuringInstallAPI?.remove(matchingTarget) != nil {
965-
self.targetsWhichShouldBuildModulesDuringInstallAPI?.insert(dynamicConfiguredTarget)
966-
}
967-
}
968-
}
969-
970939
for (product, topLevelTargets) in packageLinkingTargets.products {
971940
if let andOther = checkLinkage(topLevelTargets: topLevelTargets) {
972941
packageTargetsToIgnore.formUnion(dependenciesByTarget[product]?.map { $0.target } ?? [])
@@ -1002,6 +971,37 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
1002971

1003972
// MARK: - Apply the collected replacement candidates to the build graph
1004973

974+
let updateConfiguration = { (configuredTarget: ConfiguredTarget, dynamicTarget: SWBCore.Target) in
975+
// If the `targetTaskInfo` for the static target isn't present, we already made the decision to make this target dynamic.
976+
if self.targetGateNodes[configuredTarget] == nil { return }
977+
978+
// There can be multiple configured targets for the dynamic target, we have to update all of them.
979+
let matchingConfiguredTargets = self.targetGateNodes.keys.filter { $0.target.guid == configuredTarget.target.guid }
980+
981+
for matchingTarget in matchingConfiguredTargets {
982+
guard let taskInfo = self.targetGateNodes[matchingTarget] else { return }
983+
let dynamicConfiguredTarget = matchingTarget.replacingTarget(dynamicTarget)
984+
985+
self.targetGateNodes.removeValue(forKey: matchingTarget)
986+
self.targetGateNodes[dynamicConfiguredTarget] = taskInfo
987+
988+
let impartedBuildProperties = self.impartedBuildPropertiesByTarget[matchingTarget]
989+
self.impartedBuildPropertiesByTarget.removeValue(forKey: matchingTarget)
990+
self.impartedBuildPropertiesByTarget[dynamicConfiguredTarget] = impartedBuildProperties
991+
992+
let descriptors = self.swiftMacroImplementationDescriptorsByTarget.removeValue(forKey: matchingTarget)
993+
self.swiftMacroImplementationDescriptorsByTarget[dynamicConfiguredTarget] = descriptors
994+
995+
if self.targetsRequiredToBuildForIndexing.remove(matchingTarget) != nil {
996+
self.targetsRequiredToBuildForIndexing.insert(dynamicConfiguredTarget)
997+
}
998+
999+
if self.targetsWhichShouldBuildModulesDuringInstallAPI?.remove(matchingTarget) != nil {
1000+
self.targetsWhichShouldBuildModulesDuringInstallAPI?.insert(dynamicConfiguredTarget)
1001+
}
1002+
}
1003+
}
1004+
10051005
for (product, (packageProductTarget, dynamicTarget)) in packageDiamondUpdates.productsToBuildDynamically {
10061006
updateConfiguration(product, dynamicTarget)
10071007
self.dynamicallyBuildingTargetsWithDiamondLinkage[packageProductTarget] = dynamicTarget

0 commit comments

Comments
 (0)