mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Serialization] Apple platforms have default framework search paths. (#8331)
Follow Clang's lead in defining /System/Library/Frameworks and /Library/Frameworks as default framework search paths. I'm doing this manually rather than adding them to the actual list of search paths because Clang will /also/ do this by default, and I don't want to needlessly duplicate that work. rdar://problem/31126655
This commit is contained in:
@@ -131,15 +131,33 @@ findModule(ASTContext &ctx, AccessPathElem moduleID,
|
||||
moduleFramework += ".framework";
|
||||
isFramework = true;
|
||||
|
||||
for (const auto &framepath : ctx.SearchPathOpts.FrameworkSearchPaths) {
|
||||
currPath = framepath.Path;
|
||||
auto tryFrameworkImport = [&](StringRef frameworkPath) -> bool {
|
||||
currPath = frameworkPath;
|
||||
llvm::sys::path::append(currPath, moduleFramework.str(),
|
||||
"Modules", moduleFilename.str());
|
||||
auto err = openModuleFiles(currPath,
|
||||
archFile.str(), archDocFile.str(),
|
||||
moduleBuffer, moduleDocBuffer,
|
||||
scratch);
|
||||
if (!err)
|
||||
return !err;
|
||||
};
|
||||
|
||||
for (const auto &framepath : ctx.SearchPathOpts.FrameworkSearchPaths) {
|
||||
if (tryFrameworkImport(framepath.Path))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (ctx.LangOpts.Target.isOSDarwin()) {
|
||||
// Apple platforms have extra implicit framework search paths:
|
||||
// $SDKROOT/System/Library/Frameworks/ and $SDKROOT/Library/Frameworks/
|
||||
scratch = ctx.SearchPathOpts.SDKPath;
|
||||
llvm::sys::path::append(scratch, "System", "Library", "Frameworks");
|
||||
if (tryFrameworkImport(scratch))
|
||||
return true;
|
||||
|
||||
scratch = ctx.SearchPathOpts.SDKPath;
|
||||
llvm::sys::path::append(scratch, "Library", "Frameworks");
|
||||
if (tryFrameworkImport(scratch))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user