Make the function to compute the prebuilt module cache path public

so it can be called by LLDB. (NFC).

rdar://76112632
This commit is contained in:
Adrian Prantl
2021-04-06 17:17:32 -07:00
parent ed16e1bd1c
commit ab3da1625e
2 changed files with 27 additions and 15 deletions

View File

@@ -101,6 +101,25 @@ getVersionedPrebuiltModulePath(Optional<llvm::VersionTuple> sdkVer,
} while(true);
}
std::string CompilerInvocation::computePrebuiltCachePath(
StringRef RuntimeResourcePath, llvm::Triple target,
Optional<llvm::VersionTuple> sdkVer) {
SmallString<64> defaultPrebuiltPath{RuntimeResourcePath};
StringRef platform;
if (tripleIsMacCatalystEnvironment(target)) {
// The prebuilt cache for macCatalyst is the same as the one for macOS, not
// iOS or a separate location of its own.
platform = "macosx";
} else {
platform = getPlatformNameForTriple(target);
}
llvm::sys::path::append(defaultPrebuiltPath, platform, "prebuilt-modules");
// If the SDK version is given, we should check if SDK-versioned prebuilt
// module cache is available and use it if so.
return getVersionedPrebuiltModulePath(sdkVer, defaultPrebuiltPath);
}
void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
if (!FrontendOpts.PrebuiltModuleCachePath.empty())
@@ -108,21 +127,8 @@ void CompilerInvocation::setDefaultPrebuiltCacheIfNecessary() {
if (SearchPathOpts.RuntimeResourcePath.empty())
return;
SmallString<64> defaultPrebuiltPath{SearchPathOpts.RuntimeResourcePath};
StringRef platform;
if (tripleIsMacCatalystEnvironment(LangOpts.Target)) {
// The prebuilt cache for macCatalyst is the same as the one for macOS, not iOS
// or a separate location of its own.
platform = "macosx";
} else {
platform = getPlatformNameForTriple(LangOpts.Target);
}
llvm::sys::path::append(defaultPrebuiltPath, platform, "prebuilt-modules");
// If the SDK version is given, we should check if SDK-versioned prebuilt
// module cache is available and use it if so.
FrontendOpts.PrebuiltModuleCachePath =
getVersionedPrebuiltModulePath(LangOpts.SDKVersion, defaultPrebuiltPath);
FrontendOpts.PrebuiltModuleCachePath = computePrebuiltCachePath(
SearchPathOpts.RuntimeResourcePath, LangOpts.Target, LangOpts.SDKVersion);
}
static void updateRuntimeLibraryPaths(SearchPathOptions &SearchPathOpts,