Skip to content

Commit 9c84003

Browse files
committed
Driver: further generalise #1088
It seems that a similar problem has impacted the generation of serialised diagnostics for modules. Follow the adage of CS inherently having 3 numbers: 0, 1, N and generalise the path to a penultimate fallback. We should always have the swift dependency information on hand to locate the build directory as that is the "master dependency". This should hopefully prevent accidental cases of files leaking into the current directory.
1 parent c73d652 commit 9c84003

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

Sources/SwiftDriver/Driver/Driver.swift

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

30153015
// Emit-module discovered dependencies are always specified as a single-output
30163016
// file
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-
}
3017+
if type == .emitModuleDependencies,
3018+
let path = outputFileMap?.existingOutputForSingleInput(outputType: type) {
3019+
return path
30323020
}
30333021

30343022
// If there is an output argument, derive the name from there.
@@ -3046,6 +3034,16 @@ extension Driver {
30463034
.intern()
30473035
}
30483036

3037+
// If an explicit path is not provided by the output file map, attempt to
3038+
// synthesize a path from the master swift dependency path. This is
3039+
// important as we may otherwise emit this file at the location where the
3040+
// driver was invoked, which is normally the root of the package.
3041+
if let path = outputFileMap?.existingOutputForSingleInput(outputType: .swiftDeps) {
3042+
return VirtualPath.lookup(path)
3043+
.parentDirectory
3044+
.appending(component: "\(moduleName).\(type.rawValue)")
3045+
.intern()
3046+
}
30493047
return try VirtualPath.intern(path: moduleName.appendingFileTypeExtension(type))
30503048
}
30513049

0 commit comments

Comments
 (0)