diff --git a/Sources/SwiftIfConfig/BuildConfiguration.swift b/Sources/SwiftIfConfig/BuildConfiguration.swift index dfa90599340..51daaaeac84 100644 --- a/Sources/SwiftIfConfig/BuildConfiguration.swift +++ b/Sources/SwiftIfConfig/BuildConfiguration.swift @@ -39,11 +39,14 @@ public enum CanImportVersion { enum BuildConfigurationError: Error, CustomStringConvertible { case experimentalFeature(name: String) + case notImplemented(name: String) var description: String { switch self { case .experimentalFeature(let name): return "'\(name)' is an experimental feature" + case .notImplemented(let name): + return "'\(name)' not implemented" } } } @@ -228,18 +231,17 @@ public protocol BuildConfiguration { /// Determine whether the given name is the active target object file format (e.g., ELF). /// /// The target object file format can only be queried by an experimental - /// syntax `_objectFileFormat()`, e.g., + /// syntax `objectFormat()`, e.g., /// /// ```swift - /// #if _objectFileFormat(ELF) + /// #if objectFormat(ELF) /// // Special logic for ELF object file formats /// #endif /// ``` /// - Parameters: /// - name: The name of the object file format. /// - Returns: Whether the target object file format matches the given name. - @_spi(ExperimentalLanguageFeatures) - func isActiveTargetObjectFileFormat(name: String) throws -> Bool + func isActiveTargetObjectFormat(name: String) throws -> Bool /// The bit width of a data pointer for the target architecture. /// @@ -307,9 +309,8 @@ public protocol BuildConfiguration { /// Default implementation of BuildConfiguration, to avoid a revlock with the /// swift repo, and breaking clients with the new addition to the protocol. extension BuildConfiguration { - /// FIXME: This should be @_spi(ExperimentalLanguageFeatures) but cannot due - /// to rdar://147943518, https://github.com/swiftlang/swift/issues/80313 - public func isActiveTargetObjectFileFormat(name: String) throws -> Bool { - throw BuildConfigurationError.experimentalFeature(name: "_objectFileFormat") + @available(*, deprecated, message: "`BuildConfiguration` conformance must implement `isActiveTargetObjectFormat`") + public func isActiveTargetObjectFormat(name: String) throws -> Bool { + throw BuildConfigurationError.notImplemented(name: "isActiveTargetObjectFormat") } } diff --git a/Sources/SwiftIfConfig/IfConfigEvaluation.swift b/Sources/SwiftIfConfig/IfConfigEvaluation.swift index 3abb915f3bc..50c28802544 100644 --- a/Sources/SwiftIfConfig/IfConfigEvaluation.swift +++ b/Sources/SwiftIfConfig/IfConfigEvaluation.swift @@ -307,8 +307,8 @@ func evaluateIfConfig( case .targetEnvironment: return doSingleIdentifierArgumentCheck(configuration.isActiveTargetEnvironment, role: "environment") - case ._objectFileFormat: - return doSingleIdentifierArgumentCheck(configuration.isActiveTargetObjectFileFormat, role: "object file format") + case .objectFormat: + return doSingleIdentifierArgumentCheck(configuration.isActiveTargetObjectFormat, role: "object file format") case ._runtime: return doSingleIdentifierArgumentCheck(configuration.isActiveTargetRuntime, role: "runtime") @@ -821,8 +821,8 @@ private struct CanImportSuppressingBuildConfiguration return try other.isActiveTargetPointerAuthentication(name: name) } - func isActiveTargetObjectFileFormat(name: String) throws -> Bool { - return try other.isActiveTargetObjectFileFormat(name: name) + func isActiveTargetObjectFormat(name: String) throws -> Bool { + return try other.isActiveTargetObjectFormat(name: name) } var targetPointerBitWidth: Int { return other.targetPointerBitWidth } diff --git a/Sources/SwiftIfConfig/IfConfigFunctions.swift b/Sources/SwiftIfConfig/IfConfigFunctions.swift index f129af35ca4..66407751360 100644 --- a/Sources/SwiftIfConfig/IfConfigFunctions.swift +++ b/Sources/SwiftIfConfig/IfConfigFunctions.swift @@ -50,7 +50,7 @@ enum IfConfigFunctions: String { case _pointerBitWidth /// A check for the target object file format (e.g., ELF) - case _objectFileFormat + case objectFormat /// A check for the target runtime paired with the Swift runtime (e.g., _ObjC) /// via `_runtime()`. @@ -72,7 +72,7 @@ enum IfConfigFunctions: String { return true case .hasAttribute, .hasFeature, .canImport, .os, .arch, .targetEnvironment, - ._hasAtomicBitWidth, ._endian, ._pointerBitWidth, ._objectFileFormat, ._runtime, ._ptrauth, .defined: + ._hasAtomicBitWidth, ._endian, ._pointerBitWidth, .objectFormat, ._runtime, ._ptrauth, .defined: return false } } diff --git a/Sources/SwiftIfConfig/StaticBuildConfiguration.swift b/Sources/SwiftIfConfig/StaticBuildConfiguration.swift index 1af7cffda07..f15ffdd3f06 100644 --- a/Sources/SwiftIfConfig/StaticBuildConfiguration.swift +++ b/Sources/SwiftIfConfig/StaticBuildConfiguration.swift @@ -413,8 +413,7 @@ extension StaticBuildConfiguration: BuildConfiguration { /// - Parameters: /// - name: The name of the object file format. /// - Returns: Whether the target object file format matches the given name. - @_spi(ExperimentalLanguageFeatures) - public func isActiveTargetObjectFileFormat(name: String) -> Bool { + public func isActiveTargetObjectFormat(name: String) -> Bool { targetObjectFileFormats.contains(name) } diff --git a/Tests/SwiftIfConfigTest/EvaluateTests.swift b/Tests/SwiftIfConfigTest/EvaluateTests.swift index 849806dd218..82b85c1f49e 100644 --- a/Tests/SwiftIfConfigTest/EvaluateTests.swift +++ b/Tests/SwiftIfConfigTest/EvaluateTests.swift @@ -228,8 +228,8 @@ public class EvaluateTests: XCTestCase { assertIfConfig("_pointerBitWidth(_32)", .inactive) assertIfConfig("_hasAtomicBitWidth(_64)", .active) assertIfConfig("_hasAtomicBitWidth(_128)", .inactive) - assertIfConfig("_objectFileFormat(ELF)", .active) - assertIfConfig("_objectFileFormat(MachO)", .inactive) + assertIfConfig("objectFormat(ELF)", .active) + assertIfConfig("objectFormat(MachO)", .inactive) assertIfConfig( "_endian(mid)", diff --git a/Tests/SwiftIfConfigTest/TestingBuildConfiguration.swift b/Tests/SwiftIfConfigTest/TestingBuildConfiguration.swift index 1cc40f1f3bf..a4724ccc84e 100644 --- a/Tests/SwiftIfConfigTest/TestingBuildConfiguration.swift +++ b/Tests/SwiftIfConfigTest/TestingBuildConfiguration.swift @@ -99,7 +99,7 @@ struct TestingBuildConfiguration: BuildConfiguration { name == "arm64e" } - func isActiveTargetObjectFileFormat(name: String) throws -> Bool { + func isActiveTargetObjectFormat(name: String) throws -> Bool { name == "ELF" }