Skip to content

Commit 6a6b1f8

Browse files
committed
DependenciesScanner: differentiate Swift and Clang module more explicitly in batch scan input
1 parent 29e655b commit 6a6b1f8

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/FrontendTool/ScanDependencies.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct BatchScanInput {
4545
StringRef moduleName;
4646
StringRef arguments;
4747
StringRef outputPath;
48+
bool isSwift;
4849
};
4950

5051
static std::string getScalaNodeText(Node *N) {
@@ -54,7 +55,7 @@ static std::string getScalaNodeText(Node *N) {
5455

5556
/// Parse an entry like this, where the "platforms" key-value pair is optional:
5657
/// {
57-
/// "module": "Foo.pcm",
58+
/// "swiftModuleName": "Foo",
5859
/// "arguments": "-target 10.15",
5960
/// "output": "../Foo.json"
6061
/// },
@@ -70,8 +71,12 @@ static bool parseBatchInputEntries(ASTContext &Ctx, llvm::StringSaver &saver,
7071
for (auto &Pair: *MN) {
7172
auto Key = getScalaNodeText(Pair.getKey());
7273
auto* Value = Pair.getValue();
73-
if (Key == "module") {
74+
if (Key == "clangModuleName") {
7475
entry.moduleName = saver.save(getScalaNodeText(Value));
76+
entry.isSwift = false;
77+
} else if (Key == "swiftModuleName") {
78+
entry.moduleName = saver.save(getScalaNodeText(Value));
79+
entry.isSwift = true;
7580
} else if (Key == "arguments") {
7681
entry.arguments = saver.save(getScalaNodeText(Value));
7782
} else if (Key == "output") {
@@ -85,9 +90,6 @@ static bool parseBatchInputEntries(ASTContext &Ctx, llvm::StringSaver &saver,
8590
return true;
8691
if (entry.outputPath.empty())
8792
return true;
88-
auto ext = llvm::sys::path::extension(entry.moduleName);
89-
if (ext != ".swiftmodule" && ext != ".pcm")
90-
return true;
9193
result.emplace_back(std::move(entry));
9294
}
9395
return false;
@@ -699,10 +701,8 @@ bool swift::batchScanModuleDependencies(CompilerInstance &instance,
699701
if (!results.hasValue())
700702
return true;
701703
for (auto &entry: *results) {
702-
auto moduleName = llvm::sys::path::stem(entry.moduleName);
703-
auto isClang = llvm::sys::path::extension(entry.moduleName) == ".pcm";
704-
if (scanModuleDependencies(instance, moduleName, entry.arguments, isClang,
705-
entry.outputPath))
704+
if (scanModuleDependencies(instance, entry.moduleName, entry.arguments,
705+
!entry.isSwift, entry.outputPath))
706706
return true;
707707
}
708708
return false;

test/ScanDependencies/batch_module_scan.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@
44
// RUN: mkdir -p %t/clang-module-cache
55

66
// RUN: echo "[{" > %/t/inputs/input.json
7-
// RUN: echo "\"module\": \"F.swiftmodule\"," >> %/t/inputs/input.json
7+
// RUN: echo "\"swiftModuleName\": \"F\"," >> %/t/inputs/input.json
88
// RUN: echo "\"arguments\": \"-target x86_64-apple-macosx10.9\"," >> %/t/inputs/input.json
99
// RUN: echo "\"output\": \"%/t/outputs/F.swiftmodule.json\"" >> %/t/inputs/input.json
1010
// RUN: echo "}," >> %/t/inputs/input.json
1111
// RUN: echo "{" >> %/t/inputs/input.json
12-
// RUN: echo "\"module\": \"F.pcm\"," >> %/t/inputs/input.json
12+
// RUN: echo "\"clangModuleName\": \"F\"," >> %/t/inputs/input.json
1313
// RUN: echo "\"arguments\": \"-target x86_64-apple-macosx10.9\"," >> %/t/inputs/input.json
1414
// RUN: echo "\"output\": \"%/t/outputs/F.pcm.json\"" >> %/t/inputs/input.json
1515
// RUN: echo "}]" >> %/t/inputs/input.json

0 commit comments

Comments
 (0)