@@ -143,9 +143,9 @@ class GetDependencyTree : public FullDependencyConsumer {
143
143
}
144
144
145
145
GetDependencyTree (llvm::cas::CachingOnDiskFileSystem &FS,
146
- RemapPathCallback RemapPath )
146
+ DepscanPrefixMapping PrefixMapping )
147
147
: FullDependencyConsumer(AlreadySeen, nullptr , /* EagerModules=*/ false ,
148
- &FS, RemapPath ),
148
+ &FS, std::move(PrefixMapping) ),
149
149
FS (FS) {}
150
150
151
151
private:
@@ -157,7 +157,7 @@ class GetDependencyTree : public FullDependencyConsumer {
157
157
llvm::Expected<llvm::cas::ObjectProxy>
158
158
DependencyScanningTool::getDependencyTree (
159
159
const std::vector<std::string> &CommandLine, StringRef CWD) {
160
- GetDependencyTree Consumer (*Worker.getCASFS (), /* RemapPath =*/ nullptr );
160
+ GetDependencyTree Consumer (*Worker.getCASFS (), /* PrefixMapping =*/ {} );
161
161
auto Result = Worker.computeDependencies (CWD, CommandLine, Consumer);
162
162
if (Result)
163
163
return std::move (Result);
@@ -168,8 +168,8 @@ llvm::Expected<llvm::cas::ObjectProxy>
168
168
DependencyScanningTool::getDependencyTreeFromCompilerInvocation (
169
169
std::shared_ptr<CompilerInvocation> Invocation, StringRef CWD,
170
170
DiagnosticConsumer &DiagsConsumer, raw_ostream *VerboseOS,
171
- bool DiagGenerationAsCompilation, RemapPathCallback RemapPath ) {
172
- GetDependencyTree Consumer (*Worker.getCASFS (), RemapPath );
171
+ bool DiagGenerationAsCompilation, DepscanPrefixMapping PrefixMapping ) {
172
+ GetDependencyTree Consumer (*Worker.getCASFS (), std::move (PrefixMapping) );
173
173
Worker.computeDependenciesFromCompilerInvocation (
174
174
std::move (Invocation), CWD, Consumer, DiagsConsumer, VerboseOS,
175
175
DiagGenerationAsCompilation);
@@ -588,6 +588,11 @@ DependencyScanningTool::getFullDependenciesLegacyDriverCommand(
588
588
Error FullDependencyConsumer::initialize (CompilerInstance &ScanInstance,
589
589
CompilerInvocation &NewInvocation) {
590
590
if (CacheFS) {
591
+ // Setup prefix mapping.
592
+ Mapper.emplace (CacheFS);
593
+ if (Error E = PrefixMapping.configurePrefixMapper (NewInvocation, *Mapper))
594
+ return E;
595
+
591
596
CacheFS->trackNewAccesses ();
592
597
if (auto CWD =
593
598
ScanInstance.getVirtualFileSystem ().getCurrentWorkingDirectory ())
@@ -617,8 +622,14 @@ Error FullDependencyConsumer::finalize(CompilerInstance &ScanInstance,
617
622
(void )CacheFS->status (NewInvocation.getCodeGenOpts ().SampleProfileFile );
618
623
(void )CacheFS->status (NewInvocation.getCodeGenOpts ().ProfileRemappingFile );
619
624
620
- if (auto E = CacheFS->createTreeFromNewAccesses (RemapPath).moveInto (
621
- CASFileSystemRootID))
625
+ auto E = CacheFS
626
+ ->createTreeFromNewAccesses (
627
+ [&](const llvm::vfs::CachedDirectoryEntry &Entry,
628
+ SmallVectorImpl<char > &Storage) {
629
+ return Mapper->mapDirEntry (Entry, Storage);
630
+ })
631
+ .moveInto (CASFileSystemRootID);
632
+ if (E)
622
633
return E;
623
634
624
635
configureInvocationForCaching (NewInvocation, CASOpts,
@@ -654,7 +665,14 @@ Error FullDependencyConsumer::finalizeModuleBuild(
654
665
CompilerInstance &ModuleScanInstance) {
655
666
if (CacheFS) {
656
667
std::optional<cas::CASID> RootID;
657
- if (auto E = CacheFS->createTreeFromNewAccesses (RemapPath).moveInto (RootID))
668
+ auto E = CacheFS
669
+ ->createTreeFromNewAccesses (
670
+ [&](const llvm::vfs::CachedDirectoryEntry &Entry,
671
+ SmallVectorImpl<char > &Storage) {
672
+ return Mapper->mapDirEntry (Entry, Storage);
673
+ })
674
+ .moveInto (RootID);
675
+ if (E)
658
676
return E;
659
677
660
678
Module *M = ModuleScanInstance.getPreprocessor ().getCurrentModule ();
0 commit comments