Skip to content

Commit 657315a

Browse files
author
David Ungar
authored
Merge pull request swiftlang#14907 from davidungar/PR-18-8-dependencies
[Batch mode] When emitting dependencies, only emit supplementary outputs for the current input.
2 parents a4eb32c + 31dd56b commit 657315a

File tree

2 files changed

+32
-13
lines changed

2 files changed

+32
-13
lines changed

lib/Frontend/FrontendOptions.cpp

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,15 @@ void FrontendOptions::forAllOutputPaths(
116116
else
117117
fn(input.outputFilename());
118118
}
119-
(void)InputsAndOutputs.forEachInputProducingSupplementaryOutput(
120-
[&](const InputFile &inp) -> bool {
121-
const SupplementaryOutputPaths &outs =
122-
inp.getPrimarySpecificPaths().SupplementaryOutputs;
123-
const std::string *outputs[] = {&outs.ModuleOutputPath,
124-
&outs.ModuleDocOutputPath,
125-
&outs.ObjCHeaderOutputPath};
126-
for (const std::string *next : outputs) {
127-
if (!next->empty())
128-
fn(*next);
129-
}
130-
return false;
131-
});
119+
const SupplementaryOutputPaths &outs =
120+
input.getPrimarySpecificPaths().SupplementaryOutputs;
121+
const std::string *outputs[] = {&outs.ModuleOutputPath,
122+
&outs.ModuleDocOutputPath,
123+
&outs.ObjCHeaderOutputPath};
124+
for (const std::string *next : outputs) {
125+
if (!next->empty())
126+
fn(*next);
127+
}
132128
}
133129

134130
const char *
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// This test verifies that, in batch-mode (i.e. >1 primary input),
2+
// we have fixed a bug that caused every primary input to be a dependent
3+
// of every ModuleOutputPath, etc.
4+
5+
// RUN: %empty-directory(%t)
6+
// RUN: echo 'public func a() { }' >%t/a.swift
7+
// RUN: echo 'public func main() {a()}' >%t/main.swift
8+
// RUN: %target-swift-frontend -c -enable-batch-mode -bypass-batch-mode-checks -module-name foo -primary-file %t/a.swift -primary-file %t/main.swift -emit-dependencies-path %t/a.d -emit-dependencies-path %t/main.d -o %t/a.o -o %t/main.o -emit-module-path %t/a.swiftmodule -emit-module-path %t/main.swiftmodule
9+
// RUN: %FileCheck -check-prefix=CHECK-MAIN %s <%t/main.d
10+
// RUN: %FileCheck -check-prefix=NEGATIVE-MAIN %s <%t/main.d
11+
//
12+
// CHECK-MAIN-DAG: main.swiftmodule :
13+
// CHECK-MAIN-DAG: main.o :
14+
// NEGATIVE-MAIN-NOT: a.swiftmodule
15+
// NEGATIVE-MAIN-NOT: a.o
16+
//
17+
// RUN: %FileCheck -check-prefix=CHECK-A %s <%t/a.d
18+
// RUN: %FileCheck -check-prefix=NEGATIVE-A %s <%t/a.d
19+
//
20+
// CHECK-A-DAG: a.swiftmodule :
21+
// CHECK-A-DAG: a.o :
22+
// NEGATIVE-A-NOT: main.swiftmodule
23+
// NEGATIVE-A-NOT: main.o

0 commit comments

Comments
 (0)