[Dependency Scanning] Add support for placing explicitly-built SDK modules into a separate module cache

With '-sdk-module-cache-path', Swift textual interfaces found in the SDK will be built into a separate SDK-specific module cache.
Clang modules are not yet affected by this change, pending addition of the required API.
This commit is contained in:
Artem Chikin
2025-02-28 11:05:33 -08:00
parent aeeeb81b60
commit 88dec5199e
20 changed files with 108 additions and 35 deletions

View File

@@ -2890,6 +2890,18 @@ void setOutputPath(ResultTy &resolvedOutputPath, const StringRef &moduleName,
const CompilerInvocation &CI, const ArgListTy &extraArgs) {
auto &outputPath = resolvedOutputPath.outputPath;
outputPath = CI.getClangModuleCachePath();
// Dependency-scanner-specific module output path handling
if ((CI.getFrontendOptions().RequestedAction ==
FrontendOptions::ActionType::ScanDependencies)) {
if (!sdkPath.empty() &&
hasPrefix(llvm::sys::path::begin(interfacePath.str()), llvm::sys::path::end(interfacePath.str()),
llvm::sys::path::begin(sdkPath), llvm::sys::path::end(sdkPath)))
outputPath = CI.getFrontendOptions().ExplicitSDKModulesOutputPath;
else
outputPath = CI.getFrontendOptions().ExplicitModulesOutputPath;
}
llvm::sys::path::append(outputPath, moduleName);
outputPath.append("-");
auto hashStart = outputPath.size();