mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[NFC] Generalize target-specific module loading…
…from 1-2 target-specific names to 0-N target-specific names.
This commit is contained in:
@@ -167,17 +167,17 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
|
|||||||
ModuleFilenamePair fileNames(moduleName);
|
ModuleFilenamePair fileNames(moduleName);
|
||||||
|
|
||||||
StringRef archName = Ctx.LangOpts.Target.getArchName();
|
StringRef archName = Ctx.LangOpts.Target.getArchName();
|
||||||
ModuleFilenamePair archFileNames(archName);
|
|
||||||
|
SmallVector<ModuleFilenamePair, 4> targetFileNamePairs;
|
||||||
|
targetFileNamePairs.push_back(archName);
|
||||||
|
|
||||||
// FIXME: We used to use "major architecture" names for these files---the
|
// FIXME: We used to use "major architecture" names for these files---the
|
||||||
// names checked in "#if arch(...)". Fall back to that name in the one case
|
// names checked in "#if arch(...)". Fall back to that name in the one case
|
||||||
// where it's different from what Swift 4.2 supported: 32-bit ARM platforms.
|
// where it's different from what Swift 4.2 supported: 32-bit ARM platforms.
|
||||||
// We should be able to drop this once there's an Xcode that supports the
|
// We should be able to drop this once there's an Xcode that supports the
|
||||||
// new names.
|
// new names.
|
||||||
StringRef alternateArchName;
|
|
||||||
if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm)
|
if (Ctx.LangOpts.Target.getArch() == llvm::Triple::ArchType::arm)
|
||||||
alternateArchName = "arm";
|
targetFileNamePairs.push_back(StringRef("arm"));
|
||||||
ModuleFilenamePair alternateArchFileNames(alternateArchName);
|
|
||||||
|
|
||||||
auto &fs = *Ctx.SourceMgr.getFileSystem();
|
auto &fs = *Ctx.SourceMgr.getFileSystem();
|
||||||
isFramework = false;
|
isFramework = false;
|
||||||
@@ -188,30 +188,25 @@ SerializedModuleLoaderBase::findModule(AccessPathElem moduleID,
|
|||||||
/// was diagnosed, or None if neither one happened and the search should
|
/// was diagnosed, or None if neither one happened and the search should
|
||||||
/// continue.
|
/// continue.
|
||||||
auto findTargetSpecificModuleFiles = [&]() -> Optional<bool> {
|
auto findTargetSpecificModuleFiles = [&]() -> Optional<bool> {
|
||||||
auto result = findModuleFilesInDirectory(moduleID, currPath,
|
for (const auto &targetFileNames : targetFileNamePairs) {
|
||||||
archFileNames.module,
|
auto result = findModuleFilesInDirectory(moduleID, currPath,
|
||||||
archFileNames.moduleDoc,
|
targetFileNames.module, targetFileNames.moduleDoc,
|
||||||
moduleBuffer, moduleDocBuffer);
|
moduleBuffer, moduleDocBuffer);
|
||||||
|
if (!result) {
|
||||||
if (result == std::errc::no_such_file_or_directory &&
|
return true;
|
||||||
!alternateArchName.empty()) {
|
} else if (result != std::errc::no_such_file_or_directory) {
|
||||||
result = findModuleFilesInDirectory(moduleID, currPath,
|
return None;
|
||||||
alternateArchFileNames.module,
|
|
||||||
alternateArchFileNames.moduleDoc,
|
|
||||||
moduleBuffer, moduleDocBuffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == std::errc::no_such_file_or_directory) {
|
|
||||||
if (maybeDiagnoseArchitectureMismatch(moduleID.second, moduleName,
|
|
||||||
archName, currPath)) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!result)
|
// We can only get here if all targetFileNamePairs failed with
|
||||||
return true;
|
// 'std::errc::no_such_file_or_directory'.
|
||||||
else
|
if (maybeDiagnoseArchitectureMismatch(moduleID.second,
|
||||||
|
moduleName, archName, currPath)) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
return None;
|
return None;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for (auto path : Ctx.SearchPathOpts.ImportSearchPaths) {
|
for (auto path : Ctx.SearchPathOpts.ImportSearchPaths) {
|
||||||
|
|||||||
Reference in New Issue
Block a user