Skip to content

[6.0 🍒][Dependency Scanning] Apply -clang-scanner-module-cache-path to header Clang module dependencies #74874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/ClangImporter/ClangModuleDependencyScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -485,11 +485,11 @@ bool ClangImporter::addHeaderDependencies(
std::error_code(errno, std::generic_category()));
}
std::string workingDir = *optionalWorkingDir;
auto moduleCachePath = getModuleCachePathFromClang(getClangInstance());
auto moduleOutputPath = cache.getModuleOutputPath();
auto lookupModuleOutput =
[moduleCachePath](const ModuleID &MID,
ModuleOutputKind MOK) -> std::string {
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleCachePath);
[moduleOutputPath](const ModuleID &MID,
ModuleOutputKind MOK) -> std::string {
return moduleCacheRelativeLookupModuleOutput(MID, MOK, moduleOutputPath);
};
auto dependencies = clangScanningTool.getTranslationUnitDependencies(
commandLineArgs, workingDir, cache.getAlreadySeenClangModules(),
Expand Down
26 changes: 26 additions & 0 deletions test/ScanDependencies/separate_clang_scan_cache_bridging.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// RUN: %empty-directory(%t.module-cache)
// RUN: %empty-directory(%t.scanner-cache)

// RUN: %target-swift-frontend -scan-dependencies -module-cache-path %t.module-cache -clang-scanner-module-cache-path %t.scanner-cache %s -o %t.deps.json -I %S/Inputs/SwiftDifferent -import-objc-header %S/Inputs/CHeaders/Bridging.h -dump-clang-diagnostics 2>&1 | %FileCheck %s --check-prefix=CHECK-CLANG-COMMAND
// RUN: %validate-json %t.deps.json | %FileCheck %s --check-prefix=CHECK-DEPS

// Ensure we prefer clang scanner module cache path
// CHECK-CLANG-COMMAND: '-fmodules-cache-path={{.*}}.scanner-cache'

// Ensure we the modules' output path is set to the module cache
// CHECK-DEPS: "swift": "A"
// CHECK-DEPS: "clang": "F"

// CHECK-DEPS: "clang": "F"
// CHECK-DEPS-NEXT: },
// CHECK-DEPS-NEXT: {
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}F-{{.*}}.pcm"

// CHECK-DEPS: "swift": "A"
// CHECK-DEPS-NEXT: },
// CHECK-DEPS-NEXT: {
// CHECK-DEPS-NEXT: "modulePath": "{{.*}}separate_clang_scan_cache_bridging.swift.tmp.module-cache{{/|\\\\}}A-{{.*}}.swiftmodule"



import A