mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user