mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CAS] Workaround the missing file system dependency from clang importer
This commit is contained in:
@@ -409,6 +409,11 @@ public:
|
||||
/// Reads the original source file name from PCH.
|
||||
std::string getOriginalSourceFile(StringRef PCHFilename);
|
||||
|
||||
/// Add clang dependency file names.
|
||||
///
|
||||
/// \param files The list of file to append dependencies to.
|
||||
void addClangInvovcationDependencies(std::vector<std::string> &files);
|
||||
|
||||
/// Makes a temporary replica of the ClangImporter's CompilerInstance, reads a
|
||||
/// module map into the replica and emits a PCM file for one of the modules it
|
||||
/// declares. Delegates to clang for everything except construction of the
|
||||
|
||||
@@ -446,6 +446,11 @@ void SwiftDependencyScanningService::setupCachingDependencyScanningService(
|
||||
}
|
||||
}
|
||||
|
||||
// Fetch some dependency files from clang importer.
|
||||
auto clangImporter = static_cast<ClangImporter *>(
|
||||
Instance.getASTContext().getClangModuleLoader());
|
||||
clangImporter->addClangInvovcationDependencies(CommonDependencyFiles);
|
||||
|
||||
auto CachingFS =
|
||||
llvm::cas::createCachingOnDiskFileSystem(Instance.getObjectStore());
|
||||
if (!CachingFS) {
|
||||
|
||||
@@ -939,6 +939,27 @@ std::string ClangImporter::getOriginalSourceFile(StringRef PCHFilename) {
|
||||
Impl.Instance->getPCHContainerReader(), Impl.Instance->getDiagnostics());
|
||||
}
|
||||
|
||||
void ClangImporter::addClangInvovcationDependencies(
|
||||
std::vector<std::string> &files) {
|
||||
auto addFiles = [&files](const auto &F) {
|
||||
files.insert(files.end(), F.begin(), F.end());
|
||||
};
|
||||
auto &invocation = *Impl.Invocation;
|
||||
// FIXME: Add file dependencies that are not accounted. The long term solution
|
||||
// is to do a dependency scanning for clang importer and use that directly.
|
||||
SmallVector<std::string, 4> HeaderMapFileNames;
|
||||
Impl.Instance->getPreprocessor().getHeaderSearchInfo().getHeaderMapFileNames(
|
||||
HeaderMapFileNames);
|
||||
addFiles(HeaderMapFileNames);
|
||||
addFiles(invocation.getHeaderSearchOpts().VFSOverlayFiles);
|
||||
// FIXME: Should not depend on working directory. Build system/swift driver
|
||||
// should not pass working directory here but if that option is passed,
|
||||
// repect that and add that into CASFS.
|
||||
auto CWD = invocation.getFileSystemOpts().WorkingDir;
|
||||
if (!CWD.empty())
|
||||
files.push_back(CWD);
|
||||
}
|
||||
|
||||
Optional<std::string>
|
||||
ClangImporter::getPCHFilename(const ClangImporterOptions &ImporterOptions,
|
||||
StringRef SwiftPCHHash, bool &isExplicit) {
|
||||
|
||||
Reference in New Issue
Block a user