Skip to content

Commit 27e8d59

Browse files
committed
Add support for -file-prefix-map
1 parent 45ae4a6 commit 27e8d59

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

Sources/SwiftDriver/Driver/Driver.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2020,6 +2020,14 @@ extension Driver {
20202020
}
20212021
}
20222022

2023+
for filePrefixMap in parsedOptions.arguments(for: .filePrefixMap) {
2024+
let value = filePrefixMap.argument.asSingle
2025+
let parts = value.split(separator: "=", maxSplits: 1, omittingEmptySubsequences: false)
2026+
if parts.count != 2 {
2027+
diagnosticsEngine.emit(.error_opt_invalid_mapping(option: filePrefixMap.option, value: value))
2028+
}
2029+
}
2030+
20232031
// Determine the debug level.
20242032
let level: DebugInfo.Level?
20252033
if let levelOption = parsedOptions.getLast(in: .g), levelOption.option != .gnone {

Sources/SwiftDriver/Jobs/FrontendJobHelpers.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ extension Driver {
204204
try commandLine.appendAll(.debugPrefixMap, from: &parsedOptions)
205205
try commandLine.appendAllArguments(.Xfrontend, from: &parsedOptions)
206206
try commandLine.appendAll(.coveragePrefixMap, from: &parsedOptions)
207+
try commandLine.appendAll(.filePrefixMap, from: &parsedOptions)
207208
try commandLine.appendLast(.warnConcurrency, from: &parsedOptions)
208209
try commandLine.appendAll(.moduleAlias, from: &parsedOptions)
209210
if isFrontendArgSupported(.enableBareSlashRegex) {

Sources/SwiftOptions/Options.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ extension Option {
362362
public static let FEQ: Option = Option("-F=", .joined, alias: Option.F, attributes: [.frontend, .argumentIsPath])
363363
public static let fileCompilationDir: Option = Option("-file-compilation-dir", .separate, attributes: [.frontend], metaVar: "<path>", helpText: "The compilation directory to embed in the debug info. Coverage mapping is not supported yet.")
364364
public static let filelist: Option = Option("-filelist", .separate, attributes: [.frontend, .noDriver], helpText: "Specify source inputs in a file rather than on the command line")
365+
public static let filePrefixMap: Option = Option("-file-prefix-map", .separate, attributes: [.frontend], metaVar: "<prefix=replacement>", helpText: "Remap source paths in debug, coverage, and index info")
365366
public static let findUsr: Option = Option("-find-usr", .flag, attributes: [.noDriver], helpText: "Find USR for decls by given condition")
366367
public static let findUsr_: Option = Option("--find-usr", .flag, alias: Option.findUsr, attributes: [.noDriver], helpText: "Find USR for decls by given condition")
367368
public static let fixitAll: Option = Option("-fixit-all", .flag, attributes: [.frontend, .noInteractive, .doesNotAffectIncrementalBuild], helpText: "Apply all fixits from diagnostics without any filtering")
@@ -1031,6 +1032,7 @@ extension Option {
10311032
Option.FEQ,
10321033
Option.fileCompilationDir,
10331034
Option.filelist,
1035+
Option.filePrefixMap,
10341036
Option.findUsr,
10351037
Option.findUsr_,
10361038
Option.fixitAll,

0 commit comments

Comments
 (0)