Extends canImport to check for submodule availability

This commit is contained in:
ApolloZhu
2021-07-05 22:13:37 -04:00
committed by Apollo Zhu
parent d1bb98b11e
commit 683d469fcd
24 changed files with 294 additions and 51 deletions

View File

@@ -179,13 +179,16 @@ Optional<ModuleDependencies> SerializedModuleLoaderBase::getModuleDependencies(
{ModuleDependenciesKind::SwiftPlaceholder, currentSearchPathSet}))
return found;
auto moduleId = Ctx.getIdentifier(moduleName);
ImportPath::Module::Builder builder(Ctx, moduleName, /*separator=*/'.');
auto modulePath = builder.get();
auto moduleId = modulePath.front().Item;
// Instantiate dependency scanning "loaders".
SmallVector<std::unique_ptr<ModuleDependencyScanner>, 2> scanners;
// Placeholder dependencies must be resolved first, to prevent the ModuleDependencyScanner
// from first discovering artifacts of a previous build. Such artifacts are captured
// as compiledModuleCandidates in the dependency graph of the placeholder dependency module
// itself.
// Placeholder dependencies must be resolved first, to prevent the
// ModuleDependencyScanner from first discovering artifacts of a previous
// build. Such artifacts are captured as compiledModuleCandidates in the
// dependency graph of the placeholder dependency module itself.
// FIXME: submodules?
scanners.push_back(std::make_unique<PlaceholderSwiftModuleScanner>(
Ctx, LoadMode, moduleId, Ctx.SearchPathOpts.PlaceholderDependencyModuleMap,
delegate));
@@ -196,8 +199,7 @@ Optional<ModuleDependencies> SerializedModuleLoaderBase::getModuleDependencies(
assert(isa<PlaceholderSwiftModuleScanner>(scanners[0].get()) &&
"Expected PlaceholderSwiftModuleScanner as the first dependency scanner loader.");
for (auto &scanner : scanners) {
if (scanner->canImportModule({moduleId, SourceLoc()},
llvm::VersionTuple(), false)) {
if (scanner->canImportModule(modulePath, llvm::VersionTuple(), false)) {
// Record the dependencies.
cache.recordDependencies(moduleName, *(scanner->dependencies));
return std::move(scanner->dependencies);