Skip to content

Commit d015784

Browse files
Merge pull request swiftlang#579 from swiftlang/automerge/merge-main-2025-06-12_03-56
Merge `release/6.2` into `main`
2 parents 590f502 + 4963400 commit d015784

File tree

4 files changed

+27
-8
lines changed

4 files changed

+27
-8
lines changed

Sources/SWBApplePlatform/AssetCatalogCompiler.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,12 @@ public final class ActoolCompilerSpec : GenericCompilerSpec, SpecIdentifierType,
119119
return true
120120
}
121121

122+
public override var requiresTextBasedAPI: Bool {
123+
// Don't enforce `SUPPORTS_TEXT_BASED_API` setting if the group only contains
124+
// asset catalogs since generated symbols code doesn't export API. Related: rdar://108210630, rdar://108379090.
125+
return false
126+
}
127+
122128
/// Override to compute the special arguments.
123129
public override func constructTasks(_ cbc: CommandBuildContext, _ delegate: any TaskGenerationDelegate) async {
124130
let buildComponents = cbc.scope.evaluate(BuiltinMacros.BUILD_COMPONENTS)

Sources/SWBCore/BuildRuleAction.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public protocol BuildRuleAction: AnyObject, CustomStringConvertible, Sendable {
3030
/// Whether actions of this type should run during `InstallHeaders`.
3131
var supportsInstallHeaders: Bool { get }
3232

33+
/// True if the presence of actions of this type requires the target to use TAPI.
34+
var requiresTextBasedAPI: Bool { get }
35+
3336
/// Identifier of the rule.
3437
var identifier: String { get }
3538

@@ -73,6 +76,10 @@ public final class BuildRuleTaskAction: BuildRuleAction {
7376
return toolSpec.supportsInstallHeaders
7477
}
7578

79+
public var requiresTextBasedAPI: Bool {
80+
return toolSpec.requiresTextBasedAPI
81+
}
82+
7683
public var identifier: String {
7784
return toolSpec.identifier
7885
}
@@ -137,6 +144,11 @@ public final class BuildRuleScriptAction: BuildRuleAction {
137144
return runDuringInstallHeaders
138145
}
139146

147+
public var requiresTextBasedAPI: Bool {
148+
// In general anything that might install symbols for other projects should use TAPI.
149+
return supportsInstallAPI || supportsInstallHeaders
150+
}
151+
140152
public var identifier: String {
141153
return guid
142154
}

Sources/SWBCore/SpecImplementations/CommandLineToolSpec.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ open class CommandLineToolSpec : PropertyDomainSpec, SpecType, TaskTypeDescripti
389389
return false
390390
}
391391

392+
/// True if the presence of tasks of this type requires the target to use TAPI.
393+
open var requiresTextBasedAPI: Bool {
394+
// In general anything that might install symbols for other projects should use TAPI.
395+
return supportsInstallAPI || supportsInstallHeaders
396+
}
397+
392398
open var enableSandboxing: Bool {
393399
return false
394400
}

Sources/SWBTaskConstruction/TaskProducers/BuildPhaseTaskProducers/FilesBasedBuildPhaseTaskProducer.swift

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -650,15 +650,10 @@ class FilesBasedBuildPhaseTaskProducerBase: PhasedTaskProducer {
650650

651651
// If this target itself hasn't adopted Install API, then it is an error (since presumably it is required).
652652
if !scope.evaluate(BuiltinMacros.SUPPORTS_TEXT_BASED_API) {
653-
// If TAPI support errors are disabled, ignore the error.
654-
if !scope.evaluate(BuiltinMacros.ALLOW_UNSUPPORTED_TEXT_BASED_API) {
655-
// Don't enforce `SUPPORTS_TEXT_BASED_API` setting if the group only contains
656-
// asset catalogs since generated symbols code doesn't export API. Related: rdar://108210630, rdar://108379090.
657-
658-
// xcassets get grouped together.
659-
let isAllCatalogs = group.files.allSatisfy({ $0.fileType.conformsTo(identifier: "folder.abstractassetcatalog") })
653+
// If TAPI support errors are disabled or this task type doesn't actually require it, ignore the error.
654+
if !scope.evaluate(BuiltinMacros.ALLOW_UNSUPPORTED_TEXT_BASED_API) && group.assignedBuildRuleAction?.requiresTextBasedAPI ?? false {
660655
let productType: ProductTypeSpec? = try? context.getSpec(scope.evaluate(BuiltinMacros.PRODUCT_TYPE))
661-
if let productType = productType, productType.supportsInstallAPI && !generatedRequiresAPIError && !isAllCatalogs {
656+
if let productType = productType, productType.supportsInstallAPI && !generatedRequiresAPIError {
662657
producer.context.error("\(productType.name) requested to generate API, but has not adopted SUPPORTS_TEXT_BASED_API", location: .buildSetting(BuiltinMacros.SUPPORTS_TEXT_BASED_API))
663658
generatedRequiresAPIError = true
664659
}

0 commit comments

Comments
 (0)