Skip to content

Commit 284250c

Browse files
[CAS] Exposing the CAS creating API instead of the CAS
Expose CAS creating APIs to build system, instead of the created CAS. This allows the build system to create a different CAS if needed.
1 parent 7f5a8d2 commit 284250c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ public struct Driver {
275275
let useClangIncludeTree: Bool
276276

277277
/// CAS instance used for compilation.
278-
public var cas: SwiftScanCAS? = nil
278+
var cas: SwiftScanCAS? = nil
279279

280280
/// Is swift caching enabled.
281281
lazy var isCachingEnabled: Bool = {

Sources/SwiftDriver/ExplicitModuleBuilds/InterModuleDependencies/InterModuleDependencyOracle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class InterModuleDependencyOracle {
165165
return diags.isEmpty ? nil : diags
166166
}
167167

168-
@_spi(Testing) public func createCAS(pluginPath: AbsolutePath?, onDiskPath: AbsolutePath?, pluginOptions: [(String, String)]) throws -> SwiftScanCAS {
168+
public func createCAS(pluginPath: AbsolutePath?, onDiskPath: AbsolutePath?, pluginOptions: [(String, String)]) throws -> SwiftScanCAS {
169169
guard let swiftScan = swiftScanLibInstance else {
170170
fatalError("Attempting to reset scanner cache with no scanner instance.")
171171
}

Tests/SwiftDriverTests/CachingBuildTests.swift

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,17 @@ final class CachingBuildTests: XCTestCase {
487487
let jobs = try driver.planBuild()
488488
try driver.run(jobs: jobs)
489489
XCTAssertFalse(driver.diagnosticEngine.hasErrors)
490-
guard let cas = driver.cas else {
491-
XCTFail("CAS is not available")
490+
491+
let dependencyOracle = InterModuleDependencyOracle()
492+
let scanLibPath = try XCTUnwrap(driver.toolchain.lookupSwiftScanLib())
493+
guard try dependencyOracle
494+
.verifyOrCreateScannerInstance(fileSystem: localFileSystem,
495+
swiftScanLibPath: scanLibPath) else {
496+
XCTFail("Dependency scanner library not found")
492497
return
493498
}
499+
500+
let cas = try dependencyOracle.createCAS(pluginPath: nil, onDiskPath: casPath, pluginOptions: [])
494501
try checkCASForResults(jobs: jobs, cas: cas, fs: driver.fileSystem)
495502
}
496503
}

0 commit comments

Comments
 (0)