Skip to content

Commit 28f5df3

Browse files
committed
Add an end-to-end test for the option to print compile jobs for module dependencies
discovered by the fast dependency scanner.
1 parent 0d10e67 commit 28f5df3

File tree

15 files changed

+138
-12
lines changed

15 files changed

+138
-12
lines changed

Sources/SwiftDriver/Jobs/Planning.swift

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,14 @@ extension Driver {
3434
private mutating func planStandardCompile() throws -> [Job] {
3535
var jobs = [Job]()
3636

37-
// If we've been asked to prebuild module dependencies, prescan the source
38-
// files to produce a module dependency graph and turn it into a set
39-
// of jobs required to build all dependencies.
40-
// For the time being, just prints the jobs' compile commands.
37+
// If we've been asked to prebuild module dependencies,
38+
// for the time being, just print the jobs' compile commands.
4139
if parsedOptions.contains(.driverPrintModuleDependenciesJobs) {
42-
let moduleDependencyGraph = try computeModuleDependencyGraph()
40+
let modulePrebuildJobs = try generateExplicitModuleBuildJobs()
4341
let forceResponseFiles = parsedOptions.contains(.driverForceResponseFiles)
44-
if let dependencyGraph = moduleDependencyGraph {
45-
let modulePrebuildJobs =
46-
try planExplicitModuleDependenciesCompile(dependencyGraph: dependencyGraph)
47-
for job in modulePrebuildJobs {
48-
try Self.printJob(job, resolver: try ArgsResolver(),
49-
forceResponseFiles: forceResponseFiles)
50-
}
42+
for job in modulePrebuildJobs {
43+
try Self.printJob(job, resolver: try ArgsResolver(),
44+
forceResponseFiles: forceResponseFiles)
5145
}
5246
}
5347

@@ -216,6 +210,18 @@ extension Driver {
216210
return jobs
217211
}
218212

213+
/// Prescan the source files to produce a module dependency graph and turn it into a set
214+
/// of jobs required to build all dependencies.
215+
public mutating func generateExplicitModuleBuildJobs() throws -> [Job] {
216+
let moduleDependencyGraph = try computeModuleDependencyGraph()
217+
if let dependencyGraph = moduleDependencyGraph {
218+
let modulePrebuildJobs =
219+
try planExplicitModuleDependenciesCompile(dependencyGraph: dependencyGraph)
220+
return modulePrebuildJobs
221+
}
222+
return []
223+
}
224+
219225
/// Create a job if needed for simple requests that can be immediately
220226
/// forwarded to the frontend.
221227
public mutating func immediateForwardingJob() throws -> Job? {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcA(void);
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#include <A.h>
2+
3+
void funcB(void);
4+
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "BridgingOther.h"
2+
3+
int bridging_other(void);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include "F.h"
2+
3+
int bridging_other(void);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <B.h>
2+
3+
void funcC(void);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcD(void);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcF(void);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void funcG(void);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module A {
2+
header "A.h"
3+
export *
4+
}
5+
6+
module B {
7+
header "B.h"
8+
export *
9+
}
10+
11+
module C {
12+
header "C.h"
13+
export *
14+
}
15+
16+
module D {
17+
header "D.h"
18+
export *
19+
}
20+
21+
module F {
22+
header "F.h"
23+
export *
24+
}
25+
26+
module G {
27+
header "G.h"
28+
export *
29+
}

0 commit comments

Comments
 (0)