Skip to content

Commit

Permalink
Merge pull request #1526 from cachemeifyoucan/eng/PR-121206439
Browse files Browse the repository at this point in the history
  • Loading branch information
cachemeifyoucan authored Jan 24, 2024
2 parents c81e03c + f2ad68b commit 49daa7e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
14 changes: 12 additions & 2 deletions Sources/SwiftDriver/Driver/Driver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -638,8 +638,18 @@ public struct Driver {
diagnosticEngine: diagnosticsEngine,
compilerMode: compilerMode)

let cachingEnableOverride = parsedOptions.hasArgument(.driverExplicitModuleBuild) && env.keys.contains("SWIFT_ENABLE_CACHING")
self.enableCaching = parsedOptions.hasArgument(.cacheCompileJob) || cachingEnableOverride
let cachingEnabled = parsedOptions.hasArgument(.cacheCompileJob) || env.keys.contains("SWIFT_ENABLE_CACHING")
if cachingEnabled {
if !parsedOptions.hasArgument(.driverExplicitModuleBuild) {
diagnosticsEngine.emit(.warning("-cache-compile-job cannot be used without explicit module build, turn off caching"),
location: nil)
self.enableCaching = false
} else {
self.enableCaching = true
}
} else {
self.enableCaching = false
}
self.useClangIncludeTree = !parsedOptions.hasArgument(.noClangIncludeTree) && !env.keys.contains("SWIFT_CACHING_USE_CLANG_CAS_FS")
self.scannerPrefixMap = try Self.computeScanningPrefixMapper(&parsedOptions)
if let sdkMapping = parsedOptions.getLastArgument(.scannerPrefixMapSdk)?.asSingle {
Expand Down
7 changes: 7 additions & 0 deletions Tests/SwiftDriverTests/SwiftDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7609,6 +7609,13 @@ final class SwiftDriverTests: XCTestCase {
}
}
}

func testCachingBuildOptions() throws {
try assertDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-cache-compile-job") {
$1.expect(.warning("-cache-compile-job cannot be used without explicit module build, turn off caching"))
}
try assertNoDriverDiagnostics(args: "swiftc", "foo.swift", "-emit-module", "-cache-compile-job", "-explicit-module-build")
}
}

func assertString(
Expand Down

0 comments on commit 49daa7e

Please sign in to comment.