[Dependency Scanning] Treat resource-directory-discovered modules as stable and make them use the SDK-specific module cache path

This commit is contained in:
Artem Chikin
2025-03-19 14:56:12 -06:00
parent 04015fef77
commit dd4e8c03a5

View File

@@ -2890,13 +2890,18 @@ void setOutputPath(ResultTy &resolvedOutputPath, const StringRef &moduleName,
const CompilerInvocation &CI, const ArgListTy &extraArgs) {
auto &outputPath = resolvedOutputPath.outputPath;
outputPath = CI.getClangModuleCachePath();
auto isPrefixedWith = [interfacePath](StringRef path) {
return !path.empty() &&
hasPrefix(llvm::sys::path::begin(interfacePath.str()),
llvm::sys::path::end(interfacePath.str()),
llvm::sys::path::begin(path), llvm::sys::path::end(path));
};
// 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)))
auto runtimeResourcePath = CI.getSearchPathOptions().RuntimeResourcePath;
if (isPrefixedWith(sdkPath) || isPrefixedWith(runtimeResourcePath))
outputPath = CI.getFrontendOptions().ExplicitSDKModulesOutputPath;
else
outputPath = CI.getFrontendOptions().ExplicitModulesOutputPath;