24
24
#include " swift/Basic/OutputFileMap.h"
25
25
#include " swift/Basic/Statistic.h"
26
26
#include " swift/Driver/Driver.h"
27
+ #include " swift/Driver/FineGrainedDependencyDriverGraph.h"
27
28
#include " swift/Driver/Job.h"
28
29
#include " swift/Driver/Util.h"
29
30
#include " llvm/ADT/StringRef.h"
@@ -78,6 +79,29 @@ using CommandSet = llvm::SmallPtrSet<const Job *, 16>;
78
79
79
80
class Compilation {
80
81
public:
82
+ struct Result {
83
+ // / Set to true if any job exits abnormally (i.e. crashes).
84
+ bool hadAbnormalExit;
85
+ // / The exit code of this driver process.
86
+ int exitCode;
87
+ // / The dependency graph built up during the compilation of this module.
88
+ // /
89
+ // / This data is used for cross-module module dependencies.
90
+ fine_grained_dependencies::ModuleDepGraph depGraph;
91
+
92
+ Result (const Result &) = delete ;
93
+ Result &operator =(const Result &) = delete ;
94
+
95
+ Result (Result &&) = default ;
96
+ Result &operator =(Result &&) = default ;
97
+
98
+ // / Construct a \c Compilation::Result from just an exit code.
99
+ static Result code (int code) {
100
+ return Compilation::Result{false , code,
101
+ fine_grained_dependencies::ModuleDepGraph ()};
102
+ }
103
+ };
104
+
81
105
class IncrementalSchemeComparator {
82
106
const bool EnableIncrementalBuildWhenConstructed;
83
107
const bool &EnableIncrementalBuild;
@@ -490,7 +514,7 @@ class Compilation {
490
514
// /
491
515
// / \returns result code for the Compilation's Jobs; 0 indicates success and
492
516
// / -2 indicates that one of the Compilation's Jobs crashed during execution
493
- int performJobs (std::unique_ptr<sys::TaskQueue> &&TQ);
517
+ Compilation::Result performJobs (std::unique_ptr<sys::TaskQueue> &&TQ);
494
518
495
519
// / Returns whether the callee is permitted to pass -emit-loaded-module-trace
496
520
// / to a frontend job.
@@ -534,13 +558,11 @@ class Compilation {
534
558
private:
535
559
// / Perform all jobs.
536
560
// /
537
- // / \param[out] abnormalExit Set to true if any job exits abnormally (i.e.
538
- // / crashes).
539
561
// / \param TQ The task queue on which jobs will be scheduled.
540
562
// /
541
563
// / \returns exit code of the first failed Job, or 0 on success. If a Job
542
564
// / crashes during execution, a negative value will be returned.
543
- int performJobsImpl (bool &abnormalExit, std::unique_ptr<sys::TaskQueue> &&TQ);
565
+ Compilation::Result performJobsImpl (std::unique_ptr<sys::TaskQueue> &&TQ);
544
566
545
567
// / Performs a single Job by executing in place, if possible.
546
568
// /
@@ -550,7 +572,7 @@ class Compilation {
550
572
// / will no longer exist, or it will call exit() if the program was
551
573
// / successfully executed. In the event of an error, this function will return
552
574
// / a negative value indicating a failure to execute.
553
- int performSingleCommand (const Job *Cmd);
575
+ Compilation::Result performSingleCommand (const Job *Cmd);
554
576
};
555
577
556
578
} // end namespace driver
0 commit comments