Skip to content

Commit c73d652

Browse files
authored
Merge pull request #1088 from compnerd/module-diagnostics
Driver: provide a more suitable default for `emit-module.d`
2 parents 1153cb9 + 4d8cc2a commit c73d652

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3014,10 +3014,21 @@ extension Driver {
30143014

30153015
// Emit-module discovered dependencies are always specified as a single-output
30163016
// file
3017-
if type == .emitModuleDependencies,
3018-
let singleOutputPath = outputFileMap?.existingOutputForSingleInput(
3019-
outputType: type) {
3020-
return singleOutputPath
3017+
if type == .emitModuleDependencies {
3018+
if let path = outputFileMap?.existingOutputForSingleInput(outputType: type) {
3019+
return path
3020+
}
3021+
3022+
// If an explicit path is not provided by the output file map, attempt to
3023+
// synthesize a path from the master swift dependency path. This is
3024+
// important as we may other emit this file at the location where the
3025+
// driver was invoked, which is normally the root of the package.
3026+
if let path = outputFileMap?.existingOutputForSingleInput(outputType: .swiftDeps) {
3027+
return VirtualPath.lookup(path)
3028+
.parentDirectory
3029+
.appending(component: "\(moduleName).\(type.rawValue)")
3030+
.intern()
3031+
}
30213032
}
30223033

30233034
// If there is an output argument, derive the name from there.

0 commit comments

Comments
 (0)