1010//
1111//===----------------------------------------------------------------------===//
1212
13+ public import SWBMacro
1314public import SWBUtil
1415import Foundation
1516
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+
1636public struct DiscoveredClangToolSpecInfo : DiscoveredCommandLineToolSpecInfo {
1737 public let toolPath : Path
1838 public let clangVersion : Version ?
@@ -21,8 +41,8 @@ public struct DiscoveredClangToolSpecInfo: DiscoveredCommandLineToolSpecInfo {
2141
2242 public var toolVersion : Version ? { return self . clangVersion }
2343
24- /// `compilerClientsConfig` Clang caching blocklist
25- public let clangCachingBlocklist : ClangCachingBlockListInfo ?
44+ /// `compilerClientsConfig` blocklists for Clang
45+ public let blocklists : ClangBlocklists
2646
2747 public enum FeatureFlag : String , CaseIterable , Sendable {
2848 case allowPcmWithCompilerErrors = " allow-pcm-with-compiler-errors "
@@ -66,14 +86,10 @@ public struct DiscoveredClangToolSpecInfo: DiscoveredCommandLineToolSpecInfo {
6686 public func deploymentTargetEnvironmentVariableNames( ) -> Set < String > {
6787 Set ( toolFeatures. value ( . deploymentTargetEnvironmentVariables) ? . stringArrayValue ?? [ ] )
6888 }
69- }
70-
71- public struct ClangCachingBlockListInfo : ProjectFailuresBlockList , Codable , Sendable {
72- let KnownFailures : [ String ]
7389
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+ }
7793}
7894
7995private let clangVersionRe = RegEx ( patternLiteral: #""(?<llvm>[0-9]+(?:\.[0-9]+){0,}) \(clang-(?<clang>[0-9]+(?:\.[0-9]+){0,})\)(?: ((\[.+\])|(\(.+\)))+)?""# )
@@ -91,7 +107,7 @@ public func discoveredClangToolInfo(
91107) async throws -> DiscoveredClangToolSpecInfo {
92108 // 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.
93109 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)
95111 }
96112
97113 // Construct the command line to invoke.
@@ -169,13 +185,15 @@ public func discoveredClangToolInfo(
169185 delegate: delegate
170186 )
171187 }
188+ var blocklists = ClangBlocklists ( )
189+ blocklists. caching = getBlocklist ( type: ClangBlocklists . CachingBlocklistInfo. self, toolchainFilename: " clang-caching.json " , delegate: delegate)
172190
173191 return DiscoveredClangToolSpecInfo (
174192 toolPath: toolPath,
175193 clangVersion: clangVersion,
176194 llvmVersion: llvmVersion,
177195 isAppleClang: isAppleClang,
178- clangCachingBlocklist : getBlocklist ( type : ClangCachingBlockListInfo . self , toolchainFilename : " clang-caching.json " , delegate : delegate ) ,
196+ blocklists : blocklists ,
179197 toolFeatures: getFeatures ( at: toolPath)
180198 )
181199 } )
0 commit comments