@@ -173,6 +173,7 @@ fileprivate class ModuleCompileDelegate: JobExecutionDelegate {
173
173
var failingCriticalOutputs : Set < VirtualPath >
174
174
let logPath : AbsolutePath ?
175
175
let jsonDelegate : JSONOutputDelegate
176
+ var compiledModules : [ String : Int ] = [ : ]
176
177
init ( _ jobs: [ Job ] , _ diagnosticsEngine: DiagnosticsEngine , _ verbose: Bool ,
177
178
_ logPath: AbsolutePath ? , _ jsonDelegate: JSONOutputDelegate ) {
178
179
self . diagnosticsEngine = diagnosticsEngine
@@ -201,13 +202,40 @@ fileprivate class ModuleCompileDelegate: JobExecutionDelegate {
201
202
return !failingCriticalOutputs. isEmpty
202
203
}
203
204
205
+ public func checkCriticalModulesGenerated( ) -> Bool {
206
+ let sortedModules = compiledModules. sorted ( by: < )
207
+ Driver . stdErrQueue. sync {
208
+ stderrStream. send ( " =================================================== \n " )
209
+ sortedModules. forEach {
210
+ stderrStream. send ( " \( $0. key) : \( $0. value) \n " )
211
+ }
212
+ stderrStream. send ( " =================================================== \n " )
213
+ stderrStream. flush ( )
214
+ }
215
+ let keyModules = [ " Swift " , " SwiftUI " , " Foundation " ]
216
+ return keyModules. allSatisfy {
217
+ if compiledModules. keys. contains ( $0) {
218
+ return true
219
+ }
220
+ stderrStream. send ( " Missing critical module: \( $0) \n " )
221
+ return false
222
+ }
223
+ }
224
+
204
225
public func jobFinished( job: Job , result: ProcessResult , pid: Int ) {
205
226
self . jsonDelegate. jobFinished ( job, result)
206
227
switch result. exitStatus {
207
228
case . terminated( code: let code) :
208
229
if code == 0 {
209
230
printJobInfo ( job, false , verbose)
210
231
failingCriticalOutputs. remove ( job. outputs [ 0 ] . file)
232
+
233
+ // Keep track of Swift modules that have been already generated.
234
+ if let seen = compiledModules [ job. moduleName] {
235
+ compiledModules [ job. moduleName] = seen + 1
236
+ } else {
237
+ compiledModules [ job. moduleName] = 1
238
+ }
211
239
} else {
212
240
failingModules. insert ( job. moduleName)
213
241
let result : String = try ! result. utf8stderrOutput ( )
@@ -317,6 +345,9 @@ public class PrebuiltModuleGenerationDelegate: JobExecutionDelegate {
317
345
public var hasCriticalFailure : Bool {
318
346
return compileDelegate. hasCriticalFailure
319
347
}
348
+ public func checkCriticalModulesGenerated( ) -> Bool {
349
+ return compileDelegate. checkCriticalModulesGenerated ( )
350
+ }
320
351
public func emitJsonOutput( to path: AbsolutePath ) throws {
321
352
let data = try JSONEncoder ( ) . encode ( self . jsonDelegate)
322
353
if let json = try ? JSONSerialization . jsonObject ( with: data, options: . mutableContainers) ,
0 commit comments