@@ -173,6 +173,7 @@ fileprivate class ModuleCompileDelegate: JobExecutionDelegate {
173173 var failingCriticalOutputs : Set < VirtualPath >
174174 let logPath : AbsolutePath ?
175175 let jsonDelegate : JSONOutputDelegate
176+ var compiledModules : [ String : Int ] = [ : ]
176177 init ( _ jobs: [ Job ] , _ diagnosticsEngine: DiagnosticsEngine , _ verbose: Bool ,
177178 _ logPath: AbsolutePath ? , _ jsonDelegate: JSONOutputDelegate ) {
178179 self . diagnosticsEngine = diagnosticsEngine
@@ -201,13 +202,40 @@ fileprivate class ModuleCompileDelegate: JobExecutionDelegate {
201202 return !failingCriticalOutputs. isEmpty
202203 }
203204
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+
204225 public func jobFinished( job: Job , result: ProcessResult , pid: Int ) {
205226 self . jsonDelegate. jobFinished ( job, result)
206227 switch result. exitStatus {
207228 case . terminated( code: let code) :
208229 if code == 0 {
209230 printJobInfo ( job, false , verbose)
210231 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+ }
211239 } else {
212240 failingModules. insert ( job. moduleName)
213241 let result : String = try ! result. utf8stderrOutput ( )
@@ -317,6 +345,9 @@ public class PrebuiltModuleGenerationDelegate: JobExecutionDelegate {
317345 public var hasCriticalFailure : Bool {
318346 return compileDelegate. hasCriticalFailure
319347 }
348+ public func checkCriticalModulesGenerated( ) -> Bool {
349+ return compileDelegate. checkCriticalModulesGenerated ( )
350+ }
320351 public func emitJsonOutput( to path: AbsolutePath ) throws {
321352 let data = try JSONEncoder ( ) . encode ( self . jsonDelegate)
322353 if let json = try ? JSONSerialization . jsonObject ( with: data, options: . mutableContainers) ,
0 commit comments