mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
DependenciesScanner: include compiled module candidates for textual module interface in JSON output
Instead of replacing an interface file with its up-to-date compile module, the dep-scanner should report potentially up-to-date module candidates either adjacent to the interface file or in the prebuilt module cache. swift-driver should later pass down these candidates to -compile-module-from-interface invocation and the front-end job will check if one of the candidates is ready to use. The front-end job then either emits a forwarding module to an up-to-date candidate or a binary module.
This commit is contained in:
@@ -44,16 +44,6 @@ public:
|
||||
/*IgnoreSwiftSourceInfoFile=*/true),
|
||||
moduleName(moduleName), astDelegate(astDelegate) { }
|
||||
|
||||
std::string getCompiledModulePath(const SerializedModuleBaseName &BaseName) {
|
||||
if (LoadMode == ModuleLoadingMode::OnlySerialized) {
|
||||
return BaseName.getName(file_types::TY_SwiftModuleFile);
|
||||
}
|
||||
return static_cast<SerializedModuleLoaderBase*>(Ctx
|
||||
.getModuleInterfaceLoader())->getUpToDateCompiledModuleForInterface(
|
||||
moduleName.str(),
|
||||
BaseName.getName(file_types::TY_SwiftModuleInterfaceFile));
|
||||
}
|
||||
|
||||
virtual std::error_code findModuleFilesInDirectory(
|
||||
AccessPathElem ModuleID,
|
||||
const SerializedModuleBaseName &BaseName,
|
||||
@@ -65,26 +55,23 @@ public:
|
||||
|
||||
auto &fs = *Ctx.SourceMgr.getFileSystem();
|
||||
|
||||
// Compute the full path of the module we're looking for.
|
||||
auto ModPath = getCompiledModulePath(BaseName);
|
||||
|
||||
if (fs.exists(ModPath)) {
|
||||
// The module file will be loaded directly.
|
||||
auto dependencies = scanModuleFile(ModPath);
|
||||
if (dependencies) {
|
||||
this->dependencies = std::move(dependencies.get());
|
||||
return std::error_code();
|
||||
}
|
||||
|
||||
return dependencies.getError();
|
||||
}
|
||||
|
||||
// Check whether the .swiftinterface exists.
|
||||
auto ModPath = BaseName.getName(file_types::TY_SwiftModuleFile);
|
||||
auto InPath = BaseName.getName(file_types::TY_SwiftModuleInterfaceFile);
|
||||
|
||||
if (!fs.exists(InPath))
|
||||
return std::make_error_code(std::errc::no_such_file_or_directory);
|
||||
|
||||
if (LoadMode == ModuleLoadingMode::OnlySerialized || !fs.exists(InPath)) {
|
||||
if (fs.exists(ModPath)) {
|
||||
// The module file will be loaded directly.
|
||||
auto dependencies = scanModuleFile(ModPath);
|
||||
if (dependencies) {
|
||||
this->dependencies = std::move(dependencies.get());
|
||||
return std::error_code();
|
||||
}
|
||||
return dependencies.getError();
|
||||
} else {
|
||||
return std::make_error_code(std::errc::no_such_file_or_directory);
|
||||
}
|
||||
}
|
||||
assert(fs.exists(InPath));
|
||||
auto dependencies = scanInterfaceFile(InPath);
|
||||
if (dependencies) {
|
||||
this->dependencies = std::move(dependencies.get());
|
||||
@@ -101,6 +88,14 @@ public:
|
||||
};
|
||||
}
|
||||
|
||||
static std::vector<std::string> getCompiledCandidates(ASTContext &ctx,
|
||||
StringRef moduleName,
|
||||
StringRef interfacePath) {
|
||||
return static_cast<SerializedModuleLoaderBase*>(ctx
|
||||
.getModuleInterfaceLoader())->getCompiledModuleCandidatesForInterface(
|
||||
moduleName.str(), interfacePath);
|
||||
}
|
||||
|
||||
ErrorOr<ModuleDependencies> ModuleDependencyScanner::scanInterfaceFile(
|
||||
Twine moduleInterfacePath) {
|
||||
// Create a module filename.
|
||||
@@ -117,7 +112,11 @@ ErrorOr<ModuleDependencies> ModuleDependencyScanner::scanInterfaceFile(
|
||||
SourceLoc(),
|
||||
[&](ASTContext &Ctx, ArrayRef<StringRef> Args,
|
||||
ArrayRef<StringRef> PCMArgs, StringRef Hash) {
|
||||
Result = ModuleDependencies::forSwiftInterface(moduleInterfacePath.str(),
|
||||
std::string InPath = moduleInterfacePath.str();
|
||||
auto compiledCandidates = getCompiledCandidates(Ctx, moduleName.str(),
|
||||
InPath);
|
||||
Result = ModuleDependencies::forSwiftInterface(InPath,
|
||||
compiledCandidates,
|
||||
Args,
|
||||
PCMArgs,
|
||||
Hash);
|
||||
|
||||
Reference in New Issue
Block a user