2424#include " swift/Basic/OutputFileMap.h"
2525#include " swift/Basic/Statistic.h"
2626#include " swift/Driver/Driver.h"
27+ #include " swift/Driver/FineGrainedDependencyDriverGraph.h"
2728#include " swift/Driver/Job.h"
2829#include " swift/Driver/Util.h"
2930#include " llvm/ADT/StringRef.h"
@@ -78,6 +79,29 @@ using CommandSet = llvm::SmallPtrSet<const Job *, 16>;
7879
7980class Compilation {
8081public:
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+
81105 class IncrementalSchemeComparator {
82106 const bool EnableIncrementalBuildWhenConstructed;
83107 const bool &EnableIncrementalBuild;
@@ -490,7 +514,7 @@ class Compilation {
490514 // /
491515 // / \returns result code for the Compilation's Jobs; 0 indicates success and
492516 // / -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);
494518
495519 // / Returns whether the callee is permitted to pass -emit-loaded-module-trace
496520 // / to a frontend job.
@@ -534,13 +558,11 @@ class Compilation {
534558private:
535559 // / Perform all jobs.
536560 // /
537- // / \param[out] abnormalExit Set to true if any job exits abnormally (i.e.
538- // / crashes).
539561 // / \param TQ The task queue on which jobs will be scheduled.
540562 // /
541563 // / \returns exit code of the first failed Job, or 0 on success. If a Job
542564 // / 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);
544566
545567 // / Performs a single Job by executing in place, if possible.
546568 // /
@@ -550,7 +572,7 @@ class Compilation {
550572 // / will no longer exist, or it will call exit() if the program was
551573 // / successfully executed. In the event of an error, this function will return
552574 // / a negative value indicating a failure to execute.
553- int performSingleCommand (const Job *Cmd);
575+ Compilation::Result performSingleCommand (const Job *Cmd);
554576};
555577
556578} // end namespace driver
0 commit comments