Skip to content

[Explicit Module Builds] Pass down pre-built module candidates to the -compile-module-from-interface jobs #186

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ import Foundation
inputs.append(TypedVirtualPath(file: try VirtualPath(path: moduleInterfacePath),
type: .swiftInterface))

// Add precompiled module candidates, if present
if let compiledCandidateList = moduleDetails.compiledModuleCandidates {
for compiledCandidate in compiledCandidateList {
commandLine.appendFlag("-candidate-module-file")
let compiledCandidatePath = try VirtualPath(path: compiledCandidate)
commandLine.appendPath(compiledCandidatePath)
inputs.append(TypedVirtualPath(file: compiledCandidatePath,
type: .swiftModule))
}
}

swiftModuleBuildCache[moduleId] = Job(
moduleName: moduleId.moduleName,
kind: .emitModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ extension ModuleDependencyId: Codable {
public var moduleInterfacePath: String?

/// The paths of potentially ready-to-use compiled modules for the interface.
var compiledModuleCandidates: [String]?
public var compiledModuleCandidates: [String]?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@_spi(Testing) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorporated in:
#181
Since it already heavily modifies the graph structure.


/// The path to the already-compiled module.
public var compiledModulePath: String?
Expand Down
10 changes: 10 additions & 0 deletions Tests/SwiftDriverTests/ExplicitModuleBuildTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ private func checkExplicitModuleBuildJob(job: Job,
type: .swiftInterface)
XCTAssertEqual(job.kind, .emitModule)
XCTAssertTrue(job.inputs.contains(moduleInterfacePath))
if let compiledCandidateList = swiftModuleDetails.compiledModuleCandidates {
for compiledCandidate in compiledCandidateList {
let candidatePath = try VirtualPath(path: compiledCandidate)
let typedCandidatePath = TypedVirtualPath(file: candidatePath,
type: .swiftModule)
XCTAssertTrue(job.inputs.contains(typedCandidatePath))
XCTAssertTrue(job.commandLine.contains(.path(candidatePath)))
}
XCTAssertTrue(job.commandLine.filter {$0 == .flag("-candidate-module-file")}.count == compiledCandidateList.count)
}
case .clang(let clangModuleDetails):
guard case .swift(let mainModuleSwiftDetails) = moduleDependencyGraph.mainModule.details else {
XCTFail("Main module does not have Swift details field")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ enum ModuleDependenciesInputs {
"details": {
"swift": {
"moduleInterfacePath": "/Volumes/Compiler/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/lib/swift/macosx/SwiftOnoneSupport.swiftmodule/x86_64-apple-macos.swiftinterface",
"compiledModuleCandidates": [
"/dummy/path1/SwiftOnoneSupport.swiftmodule",
"/dummy/path2/SwiftOnoneSupport.swiftmodule"
],
"contextHash": "1PC0P8MX6CFZA",
"commandLine": [
"-compile-module-from-interface",
Expand Down