mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[CAS][DependencyScanning] Don't keep a shared state of common file deps
Unlike `swift-frontend -scan-dependencies` option, when dependency scanner is used as a library by swift driver, the SwiftScanningService is shared for multiple driver invocations. It can't keep states (like common file dependencies) that can change from one invocation to another. Instead, the clang/SDK file dependencies are computed from each driver invocations to avoid out-of-date information when scanning service is reused. The test case for a shared Service will be added to swift-driver repo since there is no tool to test it within swift compiler.
This commit is contained in:
@@ -174,6 +174,14 @@ ErrorOr<ModuleDependencyInfo> ModuleDependencyScanner::scanInterfaceFile(
|
||||
std::string RootID;
|
||||
if (dependencyTracker) {
|
||||
dependencyTracker->startTracking();
|
||||
dependencyTracker->addCommonSearchPathDeps(Ctx.SearchPathOpts);
|
||||
std::vector<std::string> clangDependencyFiles;
|
||||
auto clangImporter =
|
||||
static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
|
||||
clangImporter->addClangInvovcationDependencies(clangDependencyFiles);
|
||||
llvm::for_each(clangDependencyFiles, [&](std::string &file) {
|
||||
dependencyTracker->trackFile(file);
|
||||
});
|
||||
dependencyTracker->trackFile(moduleInterfacePath);
|
||||
auto RootOrError = dependencyTracker->createTreeFromDependencies();
|
||||
if (!RootOrError)
|
||||
|
||||
Reference in New Issue
Block a user