Skip to content

Update macro usage bookkeeping when replacing a target with a dynamic variant #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions Sources/SWBTaskConstruction/ProductPlanning/ProductPlan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
}

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

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

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

/// All targets in the product plan.
/// - remark: This property is preferred over the `TargetBuildGraph` in the `BuildPlanRequest` as it performs additional computations for Swift packages.
Expand Down Expand Up @@ -787,6 +787,17 @@ package final class GlobalProductPlan: GlobalTargetInfoProvider
let impartedBuildProperties = self.impartedBuildPropertiesByTarget[matchingTarget]
self.impartedBuildPropertiesByTarget.removeValue(forKey: matchingTarget)
self.impartedBuildPropertiesByTarget[dynamicConfiguredTarget] = impartedBuildProperties

let descriptors = self.swiftMacroImplementationDescriptorsByTarget.removeValue(forKey: matchingTarget)
self.swiftMacroImplementationDescriptorsByTarget[dynamicConfiguredTarget] = descriptors

if self.targetsRequiredToBuildForIndexing.remove(matchingTarget) != nil {
self.targetsRequiredToBuildForIndexing.insert(dynamicConfiguredTarget)
}

if self.targetsWhichShouldBuildModulesDuringInstallAPI?.remove(matchingTarget) != nil {
self.targetsWhichShouldBuildModulesDuringInstallAPI?.insert(dynamicConfiguredTarget)
}
}
}

Expand Down