From a5646e1351ef8a99adec498a87629a343f950ebd Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Mon, 18 May 2020 08:53:00 -0700 Subject: [PATCH] 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. --- lib/Serialization/SerializedModuleLoader.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/Serialization/SerializedModuleLoader.cpp b/lib/Serialization/SerializedModuleLoader.cpp index 8aca189d454b5..93288b423e063 100644 --- a/lib/Serialization/SerializedModuleLoader.cpp +++ b/lib/Serialization/SerializedModuleLoader.cpp @@ -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) - return; - if (!checkTargetFiles(path)) + + if (pathExt != moduleSuffix) + if (requireTargetSpecificModule || pathExt != suffix) 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));