[DepScan] Teach dependency scanner to remap path for canonicalization

Allow DependencyScanner to canonicalize path using a prefix map. When
option `-scanner-prefix-map` option is used, dependency scanner will
remap all the input paths in following:
* all the paths in the CAS file system or clang include tree
* all the paths related to input on the command-line returned by scanner

This allows all the input paths to be canonicalized so cache key can be
computed reguardless of the exact on disk path.

The sourceFile field is not remapped so build system can track the exact
file as on the local file system.
This commit is contained in:
Steven Wu
2023-08-29 09:36:18 -07:00
parent e2a210b0c8
commit 7b89afbb6e
20 changed files with 212 additions and 38 deletions

View File

@@ -1809,6 +1809,9 @@ static bool ParseSearchPathArgs(SearchPathOptions &Opts,
auto SplitMap = StringRef(A).split('=');
Opts.DeserializedPathRecoverer.addMapping(SplitMap.first, SplitMap.second);
}
for (StringRef Opt : Args.getAllArgValues(OPT_scanner_prefix_map)) {
Opts.ScannerPrefixMapper.push_back(Opt.str());
}
// Opts.RuntimeIncludePath is set by calls to
// setRuntimeIncludePath() or setMainExecutablePath().
// Opts.RuntimeImportPath is set by calls to