Skip to content

Commit 240581a

Browse files
Merge pull request #1553 from cachemeifyoucan/eng/PR-123654299
[Caching] Move unsupportedCachingConfiguration to be scanning error
2 parents 0d4a430 + 31b469d commit 240581a

File tree

5 files changed

+7
-8
lines changed

5 files changed

+7
-8
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ public struct Driver {
7575
case missingContextHashOnSwiftDependency(String)
7676
case dependencyScanningFailure(Int, String)
7777
case missingExternalDependency(String)
78-
// Compiler Caching Failures
79-
case unsupportedConfigurationForCaching(String)
8078

8179
public var description: String {
8280
switch self {
@@ -138,8 +136,6 @@ public struct Driver {
138136
return "unable to load output file map '\(path)': \(error)"
139137
case .missingExternalDependency(let moduleName):
140138
return "Missing External dependency info for module: \(moduleName)"
141-
case .unsupportedConfigurationForCaching(let reason):
142-
return "unsupported configuration for -cache-compile-job: \(reason)"
143139
case .baselineGenerationRequiresTopLevelModule(let arg):
144140
return "generating a baseline with '\(arg)' is only supported with '-emit-module' or '-emit-module-path'"
145141
case .optionRequiresAnother(let first, let second):

Sources/SwiftDriver/ExplicitModuleBuilds/ExplicitDependencyBuildPlanner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ public typealias ExternalTargetModuleDetailsMap = [ModuleDependencyId: ExternalT
267267

268268
let prebuiltHeaderDependencyPaths = dependencyModule.prebuiltHeaderDependencyPaths ?? []
269269
if cas != nil && !prebuiltHeaderDependencyPaths.isEmpty {
270-
throw Driver.Error.unsupportedConfigurationForCaching("module \(dependencyModule.moduleName) has prebuilt header dependency")
270+
throw DependencyScanningError.unsupportedConfigurationForCaching("module \(dependencyModule.moduleName) has bridging header dependency")
271271
}
272272

273273
for headerDep in prebuiltHeaderDependencyPaths {

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ extension Driver {
475475

476476
assert(pchJob.outputCacheKeys.count == 1, "Expect one and only one cache key from pch job")
477477
guard let bridgingHeaderCacheKey = pchJob.outputCacheKeys.first?.value else {
478-
throw Error.unsupportedConfigurationForCaching("pch job doesn't have an associated cache key")
478+
fatalError("pch job doesn't have an associated cache key")
479479
}
480480
commandLine.appendFlag("-bridging-header-pch-key")
481481
commandLine.appendFlag(bridgingHeaderCacheKey)

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import protocol TSCBasic.DiagnosticData
2222
import struct TSCBasic.AbsolutePath
2323
import struct TSCBasic.Diagnostic
2424

25-
public enum DependencyScanningError: LocalizedError, DiagnosticData {
25+
public enum DependencyScanningError: LocalizedError, DiagnosticData, Equatable {
2626
case missingRequiredSymbol(String)
2727
case dependencyScanFailed(String)
2828
case failedToInstantiateScanner
@@ -34,6 +34,7 @@ public enum DependencyScanningError: LocalizedError, DiagnosticData {
3434
case scanningLibraryInvocationMismatch(AbsolutePath, AbsolutePath)
3535
case scanningLibraryNotFound(AbsolutePath)
3636
case argumentQueryFailed
37+
case unsupportedConfigurationForCaching(String)
3738

3839
public var description: String {
3940
switch self {
@@ -59,6 +60,8 @@ public enum DependencyScanningError: LocalizedError, DiagnosticData {
5960
return "Dependency Scanning library not found at path: \(path)"
6061
case .argumentQueryFailed:
6162
return "Supported compiler argument query failed"
63+
case .unsupportedConfigurationForCaching(let reason):
64+
return "Unsupported configuration for -cache-compile-job, consider turn off swift caching: \(reason)"
6265
}
6366
}
6467

Tests/SwiftDriverTests/CachingBuildTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,7 @@ final class CachingBuildTests: XCTestCase {
585585
interModuleDependencyOracle: dependencyOracle)
586586
// This is currently not supported.
587587
XCTAssertThrowsError(try driver.planBuild()) {
588-
XCTAssertEqual($0 as? Driver.Error, .unsupportedConfigurationForCaching("module Foo has prebuilt header dependency"))
588+
XCTAssertEqual($0 as? DependencyScanningError, .unsupportedConfigurationForCaching("module Foo has bridging header dependency"))
589589
}
590590
}
591591
}

0 commit comments

Comments
 (0)