Skip to content

Commit c61129b

Browse files
committed
[Explicit Module Builds] Enable incremental dependency scanning\nWith an opt-out build setting SWIFT_DISABLE_INCREMENTAL_SCAN in case early adoption shows any troubles
1 parent ac358da commit c61129b

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

Sources/SWBCore/Settings/BuiltinMacros.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,7 @@ public final class BuiltinMacros {
10031003
public static let SWIFT_EMIT_MODULE_INTERFACE = BuiltinMacros.declareBooleanMacro("SWIFT_EMIT_MODULE_INTERFACE")
10041004
public static let SWIFT_ENABLE_BATCH_MODE = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_BATCH_MODE")
10051005
public static let SWIFT_ENABLE_INCREMENTAL_COMPILATION = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_INCREMENTAL_COMPILATION")
1006+
public static let SWIFT_DISABLE_INCREMENTAL_SCAN = BuiltinMacros.declareBooleanMacro("SWIFT_DISABLE_INCREMENTAL_SCAN")
10061007
public static let SWIFT_ENABLE_LAYOUT_STRING_VALUE_WITNESSES = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_LAYOUT_STRING_VALUE_WITNESSES")
10071008
public static let SWIFT_ENABLE_LIBRARY_EVOLUTION = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_LIBRARY_EVOLUTION")
10081009
public static let SWIFT_ENABLE_BARE_SLASH_REGEX = BuiltinMacros.declareBooleanMacro("SWIFT_ENABLE_BARE_SLASH_REGEX")
@@ -2164,6 +2165,7 @@ public final class BuiltinMacros {
21642165
SWIFT_EMIT_MODULE_INTERFACE,
21652166
SWIFT_ENABLE_BATCH_MODE,
21662167
SWIFT_ENABLE_INCREMENTAL_COMPILATION,
2168+
SWIFT_DISABLE_INCREMENTAL_SCAN,
21672169
SWIFT_ENABLE_LAYOUT_STRING_VALUE_WITNESSES,
21682170
SWIFT_ENABLE_LIBRARY_EVOLUTION,
21692171
SWIFT_USE_INTEGRATED_DRIVER,

Sources/SWBCore/SpecImplementations/Tools/SwiftCompiler.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1743,6 +1743,10 @@ public final class SwiftCompilerSpec : CompilerSpec, SpecIdentifierType, SwiftDi
17431743

17441744
if cbc.scope.evaluate(BuiltinMacros.SWIFT_ENABLE_INCREMENTAL_COMPILATION) {
17451745
args.append("-incremental")
1746+
if LibSwiftDriver.supportsDriverFlag(spelled: "-incremental-dependency-scan"),
1747+
!cbc.scope.evaluate(BuiltinMacros.SWIFT_DISABLE_INCREMENTAL_SCAN) {
1748+
args.append("-incremental-dependency-scan")
1749+
}
17461750
}
17471751
}
17481752

Tests/SWBTaskConstructionTests/SwiftTaskConstructionTests.swift

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,6 +1530,64 @@ fileprivate struct SwiftTaskConstructionTests: CoreBasedTests {
15301530
}
15311531
}
15321532

1533+
@Test(.requireSDKs(.macOS), .enabled(if: LibSwiftDriver.supportsDriverFlag(spelled: "-incremental-dependency-scan")))
1534+
func optOutIncrementalScanning() async throws {
1535+
let testProject = try await TestProject(
1536+
"aProject",
1537+
groupTree: TestGroup(
1538+
"SomeFiles", path: "Sources",
1539+
children: [
1540+
TestFile("main.swift"),
1541+
]),
1542+
buildConfigurations: [
1543+
TestBuildConfiguration(
1544+
"Debug",
1545+
buildSettings: [
1546+
"PRODUCT_NAME": "$(TARGET_NAME)",
1547+
"SWIFT_ENABLE_EXPLICIT_MODULES": "YES",
1548+
]),
1549+
],
1550+
targets: [
1551+
TestStandardTarget(
1552+
"Exec", type: .commandLineTool,
1553+
buildConfigurations: [
1554+
TestBuildConfiguration("Debug",
1555+
buildSettings: [
1556+
"SWIFT_EXEC": swiftCompilerPath.str,
1557+
"SWIFT_VERSION": swiftVersion,
1558+
]),
1559+
],
1560+
buildPhases: [
1561+
TestSourcesBuildPhase([
1562+
"main.swift",
1563+
]),
1564+
])
1565+
])
1566+
let tester = try await TaskConstructionTester(getCore(), testProject)
1567+
1568+
await tester.checkBuild(runDestination: .macOS) { results in
1569+
results.checkTarget("Exec") { target in
1570+
results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation Requirements")) { task in
1571+
task.checkCommandLineContains(["-explicit-module-build"])
1572+
task.checkCommandLineContains(["-incremental"])
1573+
task.checkCommandLineContains(["-incremental-dependency-scan"])
1574+
}
1575+
}
1576+
results.checkNoDiagnostics()
1577+
}
1578+
1579+
await tester.checkBuild(BuildParameters(configuration: "Debug", overrides: ["SWIFT_DISABLE_INCREMENTAL_SCAN": "YES"]), runDestination: .macOS) { results in
1580+
results.checkTarget("Exec") { target in
1581+
results.checkTask(.matchTarget(target), .matchRuleType("SwiftDriver Compilation Requirements")) { task in
1582+
task.checkCommandLineContains(["-explicit-module-build"])
1583+
task.checkCommandLineContains(["-incremental"])
1584+
task.checkCommandLineDoesNotContain("-incremental-dependency-scan")
1585+
}
1586+
}
1587+
results.checkNoDiagnostics()
1588+
}
1589+
}
1590+
15331591
@Test(.requireSDKs(.macOS))
15341592
func swift4DisablesExplicitModules() async throws {
15351593
let testProject = try await TestProject(

0 commit comments

Comments
 (0)