diff --git a/Sources/SWBCore/Settings/BuiltinMacros.swift b/Sources/SWBCore/Settings/BuiltinMacros.swift index a5658e7c..1f7bd4f6 100644 --- a/Sources/SWBCore/Settings/BuiltinMacros.swift +++ b/Sources/SWBCore/Settings/BuiltinMacros.swift @@ -1028,6 +1028,7 @@ public final class BuiltinMacros { public static let SWIFT_ENABLE_EXPLICIT_MODULES = BuiltinMacros.declareEnumMacro("SWIFT_ENABLE_EXPLICIT_MODULES") as EnumMacroDeclaration public static let _SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP = BuiltinMacros.declareBooleanMacro("_SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP") public static let _SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5 = BuiltinMacros.declareBooleanMacro("_SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5") + public static let SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES") public static let _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = BuiltinMacros.declareEnumMacro("_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES") as EnumMacroDeclaration public static let SWIFT_ENABLE_TESTABILITY = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_TESTABILITY") public static let SWIFT_EXEC = BuiltinMacros.declarePathMacro("SWIFT_EXEC") @@ -2200,6 +2201,7 @@ public final class BuiltinMacros { SWIFT_ENABLE_EXPLICIT_MODULES, _SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP, _SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5, + SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES, _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES, SWIFT_ENABLE_BARE_SLASH_REGEX, SWIFT_ENABLE_EMIT_CONST_VALUES, diff --git a/Sources/SWBUniversalPlatform/Specs/Swift.xcspec b/Sources/SWBUniversalPlatform/Specs/Swift.xcspec index 9a2a9855..3162a6f0 100644 --- a/Sources/SWBUniversalPlatform/Specs/Swift.xcspec +++ b/Sources/SWBUniversalPlatform/Specs/Swift.xcspec @@ -1354,6 +1354,19 @@ }; }, + { + Name = "SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES"; + Type = Boolean; + DefaultValue = NO; + CommandLineArgs = { + YES = ( + "-Xfrontend", + "-version-independent-apinotes", + ); + NO = (); + }; + }, + // Hidden clang importer options to control C++ behavior // in the clang importer, not visible in build settings. { diff --git a/Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift b/Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift index 62d4d887..3b730b4a 100644 --- a/Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift +++ b/Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift @@ -1692,6 +1692,60 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests { } } + @Test(.requireSDKs(.macOS)) + func enableVersionIndependentAPINotes() async throws { + let testProject = try await TestProject( + "aProject", + groupTree: TestGroup( + "SomeFiles", path: "Sources", + children: [ + TestFile("main.swift"), + ]), + buildConfigurations: [ + TestBuildConfiguration( + "Debug", + buildSettings: [ + "PRODUCT_NAME": "$(TARGET_NAME)", + "SWIFT_ENABLE_EXPLICIT_MODULES": "YES", + "SWIFT_VERSION": "4.2" + ]), + ], + targets: [ + TestStandardTarget( + "Exec", type: .commandLineTool, + buildConfigurations: [ + TestBuildConfiguration("Debug", + buildSettings: [ + "SWIFT_EXEC": swiftCompilerPath.str, + ]), + ], + buildPhases: [ + TestSourcesBuildPhase([ + "main.swift", + ]), + ]) + ]) + let tester = try await TaskConstructionTester(getCore(), testProject) + + await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES": "YES"]), runDestination: .macOS) { results in + results.checkTarget("Exec") { target in + results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation")) { task in + task.checkCommandLineContains(["-Xfrontend", "-version-independent-apinotes"]) + } + } + results.checkNoDiagnostics() + } + + await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES": "NO"]), runDestination: .macOS) { results in + results.checkTarget("Exec") { target in + results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation")) { task in + task.checkCommandLineDoesNotContain("-version-independent-apinotes") + } + } + results.checkNoDiagnostics() + } + } + /// Check control of whether Swift module is copied for other targets to use. @Test(.requireSDKs(.macOS)) func swiftModuleNotCopiedWhenAskedNotTo() async throws {