Skip to content

Commit cc24674

Browse files
authored
Merge pull request #186 from artemcm/CompiledCandidates
[Explicit Module Builds] Pass down pre-built module candidates to the -compile-module-from-interface jobs
2 parents a62bc1a + ef2b446 commit cc24674

File tree

4 files changed

+26
-1
lines changed

4 files changed

+26
-1
lines changed

Sources/SwiftDriver/Explicit Module Builds/ExplicitModuleBuildHandler.swift

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,17 @@ import Foundation
157157
inputs.append(TypedVirtualPath(file: try VirtualPath(path: moduleInterfacePath),
158158
type: .swiftInterface))
159159

160+
// Add precompiled module candidates, if present
161+
if let compiledCandidateList = moduleDetails.compiledModuleCandidates {
162+
for compiledCandidate in compiledCandidateList {
163+
commandLine.appendFlag("-candidate-module-file")
164+
let compiledCandidatePath = try VirtualPath(path: compiledCandidate)
165+
commandLine.appendPath(compiledCandidatePath)
166+
inputs.append(TypedVirtualPath(file: compiledCandidatePath,
167+
type: .swiftModule))
168+
}
169+
}
170+
160171
swiftModuleBuildCache[moduleId] = Job(
161172
moduleName: moduleId.moduleName,
162173
kind: .emitModule,

Sources/SwiftDriver/Explicit Module Builds/InterModuleDependencyGraph.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ extension ModuleDependencyId: Codable {
5858
public var moduleInterfacePath: String?
5959

6060
/// The paths of potentially ready-to-use compiled modules for the interface.
61-
var compiledModuleCandidates: [String]?
61+
public var compiledModuleCandidates: [String]?
6262

6363
/// The path to the already-compiled module.
6464
public var compiledModulePath: String?

Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ private func checkExplicitModuleBuildJob(job: Job,
2929
type: .swiftInterface)
3030
XCTAssertEqual(job.kind, .emitModule)
3131
XCTAssertTrue(job.inputs.contains(moduleInterfacePath))
32+
if let compiledCandidateList = swiftModuleDetails.compiledModuleCandidates {
33+
for compiledCandidate in compiledCandidateList {
34+
let candidatePath = try VirtualPath(path: compiledCandidate)
35+
let typedCandidatePath = TypedVirtualPath(file: candidatePath,
36+
type: .swiftModule)
37+
XCTAssertTrue(job.inputs.contains(typedCandidatePath))
38+
XCTAssertTrue(job.commandLine.contains(.path(candidatePath)))
39+
}
40+
XCTAssertTrue(job.commandLine.filter {$0 == .flag("-candidate-module-file")}.count == compiledCandidateList.count)
41+
}
3242
case .clang(let clangModuleDetails):
3343
guard case .swift(let mainModuleSwiftDetails) = moduleDependencyGraph.mainModule.details else {
3444
XCTFail("Main module does not have Swift details field")

Tests/SwiftDriverTests/Inputs/ExplicitModuleDependencyBuildInputs.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ enum ModuleDependenciesInputs {
147147
"details": {
148148
"swift": {
149149
"moduleInterfacePath": "/Volumes/Compiler/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftinterface",
150+
"compiledModuleCandidates": [
151+
"/dummy/path1/SwiftOnoneSupport.swiftmodule",
152+
"/dummy/path2/SwiftOnoneSupport.swiftmodule"
153+
],
150154
"contextHash": "1PC0P8MX6CFZA",
151155
"commandLine": [
152156
"-compile-module-from-interface",

0 commit comments

Comments
 (0)