10
10
//
11
11
//===----------------------------------------------------------------------===//
12
12
13
+ public import SWBMacro
13
14
public import SWBUtil
14
15
import Foundation
15
16
17
+ public struct ClangBlocklists : Sendable {
18
+
19
+ public struct CachingBlocklistInfo : ProjectFailuresBlockList , Codable , Sendable {
20
+ /// A blocklist of project names that do not support the `CLANG_ENABLE_COMPILE_CACHE` build setting.
21
+ let KnownFailures : [ String ]
22
+
23
+ enum CodingKeys : String , CodingKey {
24
+ case KnownFailures
25
+ }
26
+ }
27
+
28
+ var caching : CachingBlocklistInfo ? = nil
29
+
30
+ func isBlocked< BlockListT: ProjectFailuresBlockList > ( _ scope: MacroEvaluationScope , info: BlockListT ? ) -> Bool {
31
+ guard let blocklistInfo = info else { return false }
32
+ return blocklistInfo. isProjectListed ( scope)
33
+ }
34
+ }
35
+
16
36
public struct DiscoveredClangToolSpecInfo : DiscoveredCommandLineToolSpecInfo {
17
37
public let toolPath : Path
18
38
public let clangVersion : Version ?
@@ -21,8 +41,8 @@ public struct DiscoveredClangToolSpecInfo: DiscoveredCommandLineToolSpecInfo {
21
41
22
42
public var toolVersion : Version ? { return self . clangVersion }
23
43
24
- /// `compilerClientsConfig` Clang caching blocklist
25
- public let clangCachingBlocklist : ClangCachingBlockListInfo ?
44
+ /// `compilerClientsConfig` blocklists for Clang
45
+ public let blocklists : ClangBlocklists
26
46
27
47
public enum FeatureFlag : String , CaseIterable , Sendable {
28
48
case allowPcmWithCompilerErrors = " allow-pcm-with-compiler-errors "
@@ -66,14 +86,10 @@ public struct DiscoveredClangToolSpecInfo: DiscoveredCommandLineToolSpecInfo {
66
86
public func deploymentTargetEnvironmentVariableNames( ) -> Set < String > {
67
87
Set ( toolFeatures. value ( . deploymentTargetEnvironmentVariables) ? . stringArrayValue ?? [ ] )
68
88
}
69
- }
70
-
71
- public struct ClangCachingBlockListInfo : ProjectFailuresBlockList , Codable , Sendable {
72
- let KnownFailures : [ String ]
73
89
74
- enum CodingKeys : String , CodingKey {
75
- case KnownFailures
76
- }
90
+ public func isCachingBlocked ( _ scope : MacroEvaluationScope ) -> Bool {
91
+ return blocklists . isBlocked ( scope , info : blocklists . caching )
92
+ }
77
93
}
78
94
79
95
private let clangVersionRe = RegEx ( patternLiteral: #""(?<llvm>[0-9]+(?:\.[0-9]+){0,}) \(clang-(?<clang>[0-9]+(?:\.[0-9]+){0,})\)(?: ((\[.+\])|(\(.+\)))+)?""# )
@@ -91,7 +107,7 @@ public func discoveredClangToolInfo(
91
107
) async throws -> DiscoveredClangToolSpecInfo {
92
108
// Check that we call a clang variant, 'clang', 'clang++' etc. Note that a test sets `CC` to `/usr/bin/yes` so avoid calling that here.
93
109
guard toolPath. basename. starts ( with: " clang " ) else {
94
- return DiscoveredClangToolSpecInfo ( toolPath: toolPath, clangVersion: nil , llvmVersion: nil , isAppleClang: false , clangCachingBlocklist : nil , toolFeatures: . none)
110
+ return DiscoveredClangToolSpecInfo ( toolPath: toolPath, clangVersion: nil , llvmVersion: nil , isAppleClang: false , blocklists : ClangBlocklists ( ) , toolFeatures: . none)
95
111
}
96
112
97
113
// Construct the command line to invoke.
@@ -169,13 +185,15 @@ public func discoveredClangToolInfo(
169
185
delegate: delegate
170
186
)
171
187
}
188
+ var blocklists = ClangBlocklists ( )
189
+ blocklists. caching = getBlocklist ( type: ClangBlocklists . CachingBlocklistInfo. self, toolchainFilename: " clang-caching.json " , delegate: delegate)
172
190
173
191
return DiscoveredClangToolSpecInfo (
174
192
toolPath: toolPath,
175
193
clangVersion: clangVersion,
176
194
llvmVersion: llvmVersion,
177
195
isAppleClang: isAppleClang,
178
- clangCachingBlocklist : getBlocklist ( type : ClangCachingBlockListInfo . self , toolchainFilename : " clang-caching.json " , delegate : delegate ) ,
196
+ blocklists : blocklists ,
179
197
toolFeatures: getFeatures ( at: toolPath)
180
198
)
181
199
} )
0 commit comments