Serialization: permit the directory layout on non-Apple targets

Permit the directory style `.swiftmodule` on non-Apple targets.  This
allows all platforms to use the directory layout enabling
multi-architecture SDKs.  This not only unifies the layout of the SDK
across the various targets, it also enables Windows to have a single
unified SDK.

The complexity here is due to the compatibility for older layouts.  This
change does not break compatibility on Linux/Android/Windows for the old
style layout.
This commit is contained in:
Saleem Abdulrasool
2020-05-18 08:53:00 -07:00
parent 0c403fe766
commit a5646e1351

View File

@@ -196,18 +196,20 @@ void SerializedModuleLoaderBase::collectVisibleTopLevelModuleNamesImpl(
bool requireTargetSpecificModule = Ctx.LangOpts.Target.isOSDarwin();
forEachDirectoryEntryPath(searchPath, [&](StringRef path) {
auto pathExt = llvm::sys::path::extension(path);
if (requireTargetSpecificModule) {
if (pathExt != moduleSuffix)
if (pathExt != moduleSuffix)
if (requireTargetSpecificModule || pathExt != suffix)
return;
if (!checkTargetFiles(path))
return;
} else {
if (suffix != pathExt)
if (!checkTargetFiles(path)) {
if (requireTargetSpecificModule)
return;
auto stat = fs.status(path);
if (!stat || stat->isDirectory())
return;
}
// Extract module name.
auto name = llvm::sys::path::filename(path).drop_back(pathExt.size());
names.push_back(Ctx.getIdentifier(name));