mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[AST] Treat platform modules as non-user
Modules defined within the SDK are considered non-user modules, extend this to any module found within the parent platform directory if there is one. This ensures we include modules such as XCTest and Testing. rdar://131854240
This commit is contained in:
@@ -80,6 +80,34 @@ void ModuleSearchPathLookup::rebuildLookupTable(const SearchPathOptions *Opts,
|
||||
State.IsPopulated = true;
|
||||
}
|
||||
|
||||
static std::string computeSDKPlatformPath(StringRef SDKPath,
|
||||
llvm::vfs::FileSystem *FS) {
|
||||
if (SDKPath.empty())
|
||||
return "";
|
||||
|
||||
SmallString<128> platformPath;
|
||||
if (auto err = FS->getRealPath(SDKPath, platformPath))
|
||||
llvm::sys::path::append(platformPath, SDKPath);
|
||||
|
||||
llvm::sys::path::remove_filename(platformPath); // specific SDK
|
||||
llvm::sys::path::remove_filename(platformPath); // SDKs
|
||||
llvm::sys::path::remove_filename(platformPath); // Developer
|
||||
|
||||
if (!llvm::sys::path::filename(platformPath).endswith(".platform"))
|
||||
return "";
|
||||
|
||||
return platformPath.str().str();
|
||||
}
|
||||
|
||||
std::optional<StringRef>
|
||||
SearchPathOptions::getSDKPlatformPath(llvm::vfs::FileSystem *FS) const {
|
||||
if (!SDKPlatformPath)
|
||||
SDKPlatformPath = computeSDKPlatformPath(getSDKPath(), FS);
|
||||
if (SDKPlatformPath->empty())
|
||||
return std::nullopt;
|
||||
return *SDKPlatformPath;
|
||||
}
|
||||
|
||||
void SearchPathOptions::dump(bool isDarwin) const {
|
||||
llvm::errs() << "Module import search paths (non system):\n";
|
||||
for (auto Entry : llvm::enumerate(getImportSearchPaths())) {
|
||||
|
||||
Reference in New Issue
Block a user