[Dependency Scanning] Add support for placing explicitly-built SDK modules into a separate module cache

With '-sdk-module-cache-path', Swift textual interfaces found in the SDK will be built into a separate SDK-specific module cache.
Clang modules are not yet affected by this change, pending addition of the required API.
This commit is contained in:
Artem Chikin
2025-02-28 11:05:33 -08:00
parent aeeeb81b60
commit 88dec5199e
20 changed files with 108 additions and 35 deletions

View File

@@ -240,21 +240,22 @@ ModuleDependencyScanningWorker::ModuleDependencyScanningWorker(
ModuleDependencyVector
ModuleDependencyScanningWorker::scanFilesystemForSwiftModuleDependency(
Identifier moduleName, StringRef moduleOutputPath,
llvm::PrefixMapper *prefixMapper, bool isTestableImport) {
StringRef sdkModuleOutputPath, llvm::PrefixMapper *prefixMapper,
bool isTestableImport) {
return swiftScannerModuleLoader->getModuleDependencies(
moduleName, moduleOutputPath,
moduleName, moduleOutputPath, sdkModuleOutputPath,
{}, clangScanningTool, *scanningASTDelegate,
prefixMapper, isTestableImport);
}
ModuleDependencyVector
ModuleDependencyScanningWorker::scanFilesystemForClangModuleDependency(
Identifier moduleName,
StringRef moduleOutputPath,
Identifier moduleName, StringRef moduleOutputPath,
StringRef sdkModuleOutputPath,
const llvm::DenseSet<clang::tooling::dependencies::ModuleID> &alreadySeenModules,
llvm::PrefixMapper *prefixMapper) {
return clangScannerModuleLoader->getModuleDependencies(
moduleName, moduleOutputPath,
moduleName, moduleOutputPath, sdkModuleOutputPath,
alreadySeenModules, clangScanningTool,
*scanningASTDelegate, prefixMapper, false);
}
@@ -519,6 +520,7 @@ ModuleDependencyScanner::getNamedClangModuleDependencyInfo(
[&cache, moduleIdentifier](ModuleDependencyScanningWorker *ScanningWorker) {
return ScanningWorker->scanFilesystemForClangModuleDependency(
moduleIdentifier, cache.getModuleOutputPath(),
cache.getSDKModuleOutputPath(),
cache.getAlreadySeenClangModules(),
cache.getScanService().getPrefixMapper());
});
@@ -557,6 +559,7 @@ ModuleDependencyScanner::getNamedSwiftModuleDependencyInfo(
[&cache, moduleIdentifier](ModuleDependencyScanningWorker *ScanningWorker) {
return ScanningWorker->scanFilesystemForSwiftModuleDependency(
moduleIdentifier, cache.getModuleOutputPath(),
cache.getSDKModuleOutputPath(),
cache.getScanService().getPrefixMapper());
});
if (moduleDependencies.empty())
@@ -911,7 +914,8 @@ ModuleDependencyScanner::resolveAllClangModuleDependencies(
moduleIdentifier](ModuleDependencyScanningWorker *ScanningWorker) {
return ScanningWorker->scanFilesystemForClangModuleDependency(
moduleIdentifier, cache.getModuleOutputPath(),
seenClangModules, cache.getScanService().getPrefixMapper());
cache.getSDKModuleOutputPath(), seenClangModules,
cache.getScanService().getPrefixMapper());
});
// Update the `moduleLookupResult` and cache all discovered dependencies
@@ -1100,6 +1104,7 @@ void ModuleDependencyScanner::resolveSwiftImportsForModule(
isTestable](ModuleDependencyScanningWorker *ScanningWorker) {
return ScanningWorker->scanFilesystemForSwiftModuleDependency(
moduleIdentifier, cache.getModuleOutputPath(),
cache.getSDKModuleOutputPath(),
cache.getScanService().getPrefixMapper(), isTestable);
});
@@ -1288,6 +1293,7 @@ void ModuleDependencyScanner::resolveSwiftOverlayDependenciesForModule(
moduleIdentifier](ModuleDependencyScanningWorker *ScanningWorker) {
return ScanningWorker->scanFilesystemForSwiftModuleDependency(
moduleIdentifier, cache.getModuleOutputPath(),
cache.getSDKModuleOutputPath(),
cache.getScanService().getPrefixMapper());
});
swiftOverlayLookupResult.insert_or_assign(moduleName, moduleDependencies);