Skip to content

Commit a4ff7a7

Browse files
committed
Fix a number of callsites to get ConfiguredTarget settings from the GlobalProductPlan instead of the BuildRequestContext
1 parent 469349f commit a4ff7a7

File tree

6 files changed

+9
-19
lines changed

6 files changed

+9
-19
lines changed

Sources/SWBCore/WorkspaceSettingsCache.swift

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ final class WorkspaceSettingsCache: Sendable {
7070
}
7171

7272
/// Get the cached settings for the given parameters, without considering the context of any project/target.
73-
public func getCachedSettings(_ parameters: BuildParameters, buildRequestContext: BuildRequestContext, purpose: SettingsPurpose = .build, filesSignature: ([Path]) -> FilesSignature) -> Settings {
73+
public func getCachedSettings(_ parameters: BuildParameters, buildRequestContext: BuildRequestContext, purpose: SettingsPurpose, filesSignature: ([Path]) -> FilesSignature) -> Settings {
7474
let key = SettingsCacheKey(parameters: parameters, projectGUID: nil, targetGUID: nil, purpose: purpose, provisioningTaskInputs: nil, impartedBuildProperties: nil)
7575

7676
// Check if there were any changes in used xcconfigs
@@ -80,20 +80,10 @@ final class WorkspaceSettingsCache: Sendable {
8080
}
8181
}
8282

83-
/// Get the cached settings for the given parameters and project.
84-
public func getCachedSettings(_ parameters: BuildParameters, project: Project, purpose: SettingsPurpose = .build, provisioningTaskInputs: ProvisioningTaskInputs? = nil, impartedBuildProperties: [ImpartedBuildProperties]? = nil, buildRequestContext: BuildRequestContext, filesSignature: ([Path]) -> FilesSignature) -> Settings {
85-
return getCachedSettings(parameters, project: project, target: nil, purpose: purpose, provisioningTaskInputs: provisioningTaskInputs, impartedBuildProperties: impartedBuildProperties, buildRequestContext: buildRequestContext, filesSignature: filesSignature)
86-
}
87-
88-
/// Get the cached settings for the given parameters and target.
89-
public func getCachedSettings(_ parameters: BuildParameters, target: Target, purpose: SettingsPurpose = .build, provisioningTaskInputs: ProvisioningTaskInputs? = nil, impartedBuildProperties: [ImpartedBuildProperties]? = nil, buildRequestContext: BuildRequestContext, filesSignature: ([Path]) -> FilesSignature) -> Settings {
90-
return getCachedSettings(parameters, project: workspaceContext.workspace.project(for: target), target: target, purpose: purpose, provisioningTaskInputs: provisioningTaskInputs, impartedBuildProperties: impartedBuildProperties, buildRequestContext: buildRequestContext, filesSignature: filesSignature)
91-
}
92-
9383
/// Private method to get the cached settings for the given parameters, project, and target.
9484
///
9585
/// - remark: This is internal so that clients don't somehow call this with a project which doesn't match the target, except for `BuildRequestContext` which has a cover method for it. There are public methods covering this one.
96-
internal func getCachedSettings(_ parameters: BuildParameters, project: Project, target: Target? = nil, purpose: SettingsPurpose = .build, provisioningTaskInputs: ProvisioningTaskInputs? = nil, impartedBuildProperties: [ImpartedBuildProperties]? = nil, buildRequestContext: BuildRequestContext, filesSignature: ([Path]) -> FilesSignature) -> Settings {
86+
internal func getCachedSettings(_ parameters: BuildParameters, project: Project, target: Target?, purpose: SettingsPurpose, provisioningTaskInputs: ProvisioningTaskInputs?, impartedBuildProperties: [ImpartedBuildProperties]?, buildRequestContext: BuildRequestContext, filesSignature: ([Path]) -> FilesSignature) -> Settings {
9787
let key = SettingsCacheKey(parameters: parameters, projectGUID: project.guid, targetGUID: target?.guid, purpose: purpose, provisioningTaskInputs: provisioningTaskInputs, impartedBuildProperties: impartedBuildProperties)
9888

9989
// Check if there were any changes in used xcconfigs

Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/CopyFilesTaskProducer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class CopyFilesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, FilesBasedBui
290290
}
291291
}
292292
}
293-
let settings = context.globalProductPlan.planRequest.buildRequestContext.getCachedSettings(producingTarget.parameters, target: producingTarget.target)
293+
let settings = context.globalProductPlan.getTargetSettings(producingTarget)
294294
// We want to not exclude the binary if DONT_EMBED_REEXPORTED_MERGEABLE_LIBRARIES is enabled in debug builds. If we get here then we know this is a mergeable library, but if MAKE_MERGEABLE is enabled on the producing target then we expect this to be a debug build. (We want to check MAKE_MERGEABLE because it's possible that setting was enabled manually, and in that case DONT_EMBED_REEXPORTED_MERGEABLE_LIBRARIES doesn't apply.)
295295
if !settings.globalScope.evaluate(BuiltinMacros.MAKE_MERGEABLE) && scope.evaluate(BuiltinMacros.DONT_EMBED_REEXPORTED_MERGEABLE_LIBRARIES) {
296296
shouldSkipCopyingBinary = false
@@ -336,7 +336,7 @@ class CopyFilesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, FilesBasedBui
336336
if let resolvedLinkedBuildFile = try? context.resolveBuildFileReference(linkedBuildFile), resolvedLinkedBuildFile.fileType.identifier == "wrapper.xcframework", resolvedBuildFile.absolutePath == resolvedLinkedBuildFile.absolutePath {
337337
// Here we know that this is an XCFramework which is being linked by us or one of our dependencies, and that this XCFramework is marked as mergeable. So we decide what we want to do with it.
338338
didFindBuildFile = true
339-
let cTargetSettings = context.globalProductPlan.planRequest.buildRequestContext.getCachedSettings(cTarget.parameters, target: cTarget.target)
339+
let cTargetSettings = context.globalProductPlan.getTargetSettings(cTarget)
340340
let mergeLinkedLibraries = cTargetSettings.globalScope.evaluate(BuiltinMacros.MERGE_LINKED_LIBRARIES)
341341
if mergeLinkedLibraries {
342342
shouldSkipCopyingBinary = true

Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/SourcesTaskProducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,7 +1440,7 @@ package final class SourcesTaskProducer: FilesBasedBuildPhaseTaskProducerBase, F
14401440
// Compute the subpaths of the linked item we want to copy. This means we need to get the scope for the producing target.
14411441
// FIXME: We should unify this as much as possible with the logic in CopyFilesTaskProducer.
14421442
if let producingTarget = context.globalProductPlan.productPathsToProducingTargets[libraryPath] {
1443-
let copiedFileSettings = context.globalProductPlan.planRequest.buildRequestContext.getCachedSettings(producingTarget.parameters, target: producingTarget.target)
1443+
let copiedFileSettings = context.globalProductPlan.getTargetSettings(producingTarget)
14441444

14451445
if let productType = copiedFileSettings.productType {
14461446
// If this is a standalone binary product then we just copy it. Otherwise PBXCp will include the subpaths we assemble here.

Sources/SWBTaskConstruction/TaskProducers/OtherTaskProducers/InfoPlistTaskProducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ extension TaskProducerContext {
295295
}
296296

297297
return clients.compactMap {
298-
let scope = self.globalProductPlan.planRequest.buildRequestContext.getCachedSettings($0.parameters, target: $0.target).globalScope
298+
let scope = self.globalProductPlan.getTargetSettings($0).globalScope
299299
// Filter non-library clients.
300300
let machOType = scope.evaluate(BuiltinMacros.MACH_O_TYPE)
301301
guard ["mh_bundle", "mh_dylib", "mh_object", "staticlib"].contains(machOType) else {

Sources/SWBTaskExecution/BuildDescriptionManager.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ package final class BuildDescriptionManager: Sendable {
193193
staleFileRemovalIdentifierPerTarget[nil] = plan.staleFileRemovalTaskIdentifier(for: nil)
194194

195195
for target in buildGraph.allTargets {
196-
let settings = planRequest.buildRequestContext.getCachedSettings(target.parameters, target: target.target)
196+
let settings = plan.globalProductPlan.getTargetSettings(target)
197197
rootPathsPerTarget[target] = [
198198
settings.globalScope.evaluate(BuiltinMacros.DSTROOT),
199199
settings.globalScope.evaluate(BuiltinMacros.OBJROOT),
@@ -227,7 +227,7 @@ package final class BuildDescriptionManager: Sendable {
227227
let definingTargetsByModuleName = {
228228
var definingTargetsByModuleName: [String: OrderedSet<ConfiguredTarget>] = [:]
229229
for target in buildGraph.allTargets {
230-
let settings = planRequest.buildRequestContext.getCachedSettings(target.parameters, target: target.target)
230+
let settings = plan.globalProductPlan.getTargetSettings(target)
231231
let moduleInfo = plan.globalProductPlan.getModuleInfo(target)
232232
let specLookupContext = SpecLookupCtxt(specRegistry: planRequest.workspaceContext.core.specRegistry, platform: settings.platform)
233233
let buildingAnySwiftSourceFiles = (target.target as? BuildPhaseTarget)?.sourcesBuildPhase?.containsSwiftSources(planRequest.workspaceContext.workspace, specLookupContext, settings.globalScope, settings.filePathResolver) ?? false

Sources/SWBUniversalPlatform/TestEntryPointTaskProducer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class TestEntryPointTaskProducer: PhasedTaskProducer, TaskProducer {
3232
var indexUnitBasePaths: OrderedSet<Path> = []
3333
var binaryPaths: OrderedSet<Path> = []
3434
for directDependency in context.globalProductPlan.dependencies(of: configuredTarget) {
35-
let settings = context.globalProductPlan.planRequest.buildRequestContext.getCachedSettings(directDependency.parameters, target: directDependency.target)
35+
let settings = context.globalProductPlan.getTargetSettings(directDependency)
3636
guard settings.productType?.conformsTo(identifier: "com.apple.product-type.bundle.unit-test") == true else {
3737
continue
3838
}

0 commit comments

Comments
 (0)