Skip to content

Commit e1b047d

Browse files
authored
Merge pull request #601 from nkcsgexi/gate-dangling-jobs
PrebuiltModuleGen: run dangling jobs only when Foundation is built successfully for macabi
2 parents 8a0dcbf + 3fa51ac commit e1b047d

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Sources/SwiftDriver/Jobs/PrebuiltModulesJob.swift

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,15 @@
1212
import TSCBasic
1313
import SwiftOptions
1414

15+
func isIosMac(_ path: TypedVirtualPath) -> Bool {
16+
// Infer macabi interfaces by the file name.
17+
// FIXME: more robust way to do this.
18+
return path.file.basenameWithoutExt.contains("macabi")
19+
}
20+
1521
public class PrebuitModuleGenerationDelegate: JobExecutionDelegate {
1622
var failingModules = Set<String>()
23+
var succeededJobs: [Job] = []
1724
var commandMap: [Int: String] = [:]
1825
let diagnosticsEngine: DiagnosticsEngine
1926
let verbose: Bool
@@ -22,6 +29,13 @@ public class PrebuitModuleGenerationDelegate: JobExecutionDelegate {
2229
self.verbose = verbose
2330
}
2431

32+
/// Dangling jobs are macabi-only modules. We should run those jobs if foundation
33+
/// is built successfully for macabi.
34+
public var shouldRunDanglingJobs: Bool {
35+
return succeededJobs.contains { job in
36+
return isIosMac(job.outputs[0]) && job.moduleName == "Foundation"
37+
}
38+
}
2539
func printJobInfo(_ job: Job, _ start: Bool) {
2640
guard verbose else {
2741
return
@@ -54,6 +68,7 @@ public class PrebuitModuleGenerationDelegate: JobExecutionDelegate {
5468
case .terminated(code: let code):
5569
if code == 0 {
5670
printJobInfo(job, false)
71+
succeededJobs.append(job)
5772
} else {
5873
failingModules.insert(job.moduleName)
5974
let result: String = try! result.utf8stderrOutput()
@@ -224,11 +239,6 @@ extension Driver {
224239
_ inputPath: PrebuiltModuleInput, _ outputPath: PrebuiltModuleOutput,
225240
_ dependencies: [TypedVirtualPath]) throws -> Job {
226241
assert(inputPath.path.file.basenameWithoutExt == outputPath.path.file.basenameWithoutExt)
227-
func isIosMac(_ path: TypedVirtualPath) -> Bool {
228-
// Infer macabi interfaces by the file name.
229-
// FIXME: more robust way to do this.
230-
return path.file.basenameWithoutExt.contains("macabi")
231-
}
232242
var commandLine: [Job.ArgTemplate] = []
233243
commandLine.appendFlag(.compileModuleFromInterface)
234244
commandLine.appendFlag(.sdk)

Sources/swift-build-sdk-interfaces/main.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ do {
118118
}
119119
}
120120
do {
121-
try executor.execute(workload: DriverExecutorWorkload.init(danglingJobs, nil, continueBuildingAfterErrors: true), delegate: delegate, numParallelJobs: 128)
121+
if !danglingJobs.isEmpty && delegate.shouldRunDanglingJobs {
122+
try executor.execute(workload: DriverExecutorWorkload.init(danglingJobs, nil, continueBuildingAfterErrors: true), delegate: delegate, numParallelJobs: 128)
123+
}
122124
} catch {
123125
// Failing of dangling jobs don't fail the process.
124126
exit(0)

0 commit comments

Comments
 (0)