Skip to content

Commit baedcc9

Browse files
author
David Ungar
committed
Allow for relative build record paths
1 parent adfeb40 commit baedcc9

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ public struct Driver {
435435
self.buildRecordInfo = BuildRecordInfo(
436436
actualSwiftVersion: self.frontendTargetInfo.compilerVersion,
437437
compilerOutputType: compilerOutputType,
438+
workingDirectory: self.workingDirectory ?? fileSystem.currentWorkingDirectory,
438439
diagnosticEngine: diagnosticEngine,
439440
fileSystem: fileSystem,
440441
moduleOutputInfo: moduleOutputInfo,

Sources/SwiftDriver/Incremental Compilation/BuildRecordInfo.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import SwiftOptions
3030
init?(
3131
actualSwiftVersion: String,
3232
compilerOutputType: FileType?,
33+
workingDirectory: AbsolutePath?,
3334
diagnosticEngine: DiagnosticsEngine,
3435
fileSystem: FileSystem,
3536
moduleOutputInfo: ModuleOutputInfo,
@@ -41,6 +42,7 @@ import SwiftOptions
4142
guard let buildRecordPath = Self.computeBuildRecordPath(
4243
outputFileMap: outputFileMap,
4344
compilerOutputType: compilerOutputType,
45+
workingDirectory: workingDirectory,
4446
diagnosticEngine: diagnosticEngine)
4547
else {
4648
return nil
@@ -80,6 +82,7 @@ import SwiftOptions
8082
private static func computeBuildRecordPath(
8183
outputFileMap: OutputFileMap?,
8284
compilerOutputType: FileType?,
85+
workingDirectory: AbsolutePath?,
8386
diagnosticEngine: DiagnosticsEngine
8487
) -> VirtualPath? {
8588
// FIXME: This should work without an output file map. We should have
@@ -93,7 +96,7 @@ import SwiftOptions
9396
diagnosticEngine.emit(.warning_incremental_requires_build_record_entry)
9497
return nil
9598
}
96-
return partialBuildRecordPath
99+
return partialBuildRecordPath.resolveRelativePath(workingDirectory)
97100
}
98101

99102
/// Write out the build record.
@@ -175,3 +178,12 @@ import SwiftOptions
175178
}
176179
}
177180
}
181+
182+
extension VirtualPath {
183+
fileprivate func resolveRelativePath(_ workingDirectory: AbsolutePath?) -> VirtualPath {
184+
switch (workingDirectory, self) {
185+
case let (wd?, .relative(relPath)): return .absolute(.init(wd, relPath))
186+
default: return self
187+
}
188+
}
189+
}

0 commit comments

Comments
 (0)