Skip to content

Commit e7ccb19

Browse files
committed
Add build setting to enable version-independent APINotes processing mode
1 parent f49864e commit e7ccb19

File tree

3 files changed

+69
-0
lines changed

3 files changed

+69
-0
lines changed

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,6 +1028,7 @@ public final class BuiltinMacros {
10281028
public static let SWIFT_ENABLE_EXPLICIT_MODULES = BuiltinMacros.declareEnumMacro("SWIFT_ENABLE_EXPLICIT_MODULES") as EnumMacroDeclaration<SwiftEnableExplicitModulesSetting>
10291029
public static let _SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP = BuiltinMacros.declareBooleanMacro("_SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP")
10301030
public static let _SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5 = BuiltinMacros.declareBooleanMacro("_SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5")
1031+
public static let SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES")
10311032
public static let _EXPERIMENTAL_SWIFT_EXPLICIT_MODULES = BuiltinMacros.declareEnumMacro("_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES") as EnumMacroDeclaration<SwiftEnableExplicitModulesSetting>
10321033
public static let SWIFT_ENABLE_TESTABILITY = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_TESTABILITY")
10331034
public static let SWIFT_EXEC = BuiltinMacros.declarePathMacro("SWIFT_EXEC")
@@ -2200,6 +2201,7 @@ public final class BuiltinMacros {
22002201
SWIFT_ENABLE_EXPLICIT_MODULES,
22012202
_SWIFT_EXPLICIT_MODULES_ALLOW_CXX_INTEROP,
22022203
_SWIFT_EXPLICIT_MODULES_ALLOW_BEFORE_SWIFT_5,
2204+
SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES,
22032205
_EXPERIMENTAL_SWIFT_EXPLICIT_MODULES,
22042206
SWIFT_ENABLE_BARE_SLASH_REGEX,
22052207
SWIFT_ENABLE_EMIT_CONST_VALUES,

Sources/SWBUniversalPlatform/Specs/Swift.xcspec

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,19 @@
13541354
};
13551355
},
13561356

1357+
{
1358+
Name = "SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES";
1359+
Type = Boolean;
1360+
DefaultValue = NO;
1361+
CommandLineArgs = {
1362+
YES = (
1363+
"-Xfrontend",
1364+
"-version-independent-apinotes",
1365+
);
1366+
NO = ();
1367+
};
1368+
},
1369+
13571370
// Hidden clang importer options to control C++ behavior
13581371
// in the clang importer, not visible in build settings.
13591372
{

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,60 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
16921692
}
16931693
}
16941694

1695+
@Test(.requireSDKs(.macOS))
1696+
func enableVersionIndependentAPINotes() async throws {
1697+
let testProject = try await TestProject(
1698+
"aProject",
1699+
groupTree: TestGroup(
1700+
"SomeFiles", path: "Sources",
1701+
children: [
1702+
TestFile("main.swift"),
1703+
]),
1704+
buildConfigurations: [
1705+
TestBuildConfiguration(
1706+
"Debug",
1707+
buildSettings: [
1708+
"PRODUCT_NAME": "$(TARGET_NAME)",
1709+
"SWIFT_ENABLE_EXPLICIT_MODULES": "YES",
1710+
"SWIFT_VERSION": "4.2"
1711+
]),
1712+
],
1713+
targets: [
1714+
TestStandardTarget(
1715+
"Exec", type: .commandLineTool,
1716+
buildConfigurations: [
1717+
TestBuildConfiguration("Debug",
1718+
buildSettings: [
1719+
"SWIFT_EXEC": swiftCompilerPath.str,
1720+
]),
1721+
],
1722+
buildPhases: [
1723+
TestSourcesBuildPhase([
1724+
"main.swift",
1725+
]),
1726+
])
1727+
])
1728+
let tester = try await TaskConstructionTester(getCore(), testProject)
1729+
1730+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES": "YES"]), runDestination: .macOS) { results in
1731+
results.checkTarget("Exec") { target in
1732+
results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation")) { task in
1733+
task.checkCommandLineContains(["-Xfrontend", "-version-independent-apinotes"])
1734+
}
1735+
}
1736+
results.checkNoDiagnostics()
1737+
}
1738+
1739+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["SWIFT_ENABLE_VERSION_INDEPENDENT_APINOTES": "NO"]), runDestination: .macOS) { results in
1740+
results.checkTarget("Exec") { target in
1741+
results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation")) { task in
1742+
task.checkCommandLineDoesNotContain("-version-independent-apinotes")
1743+
}
1744+
}
1745+
results.checkNoDiagnostics()
1746+
}
1747+
}
1748+
16951749
/// Check control of whether Swift module is copied for other targets to use.
16961750
@Test(.requireSDKs(.macOS))
16971751
func swiftModuleNotCopiedWhenAskedNotTo() async throws {

0 commit comments

Comments
 (0)