|
10 | 10 | * |
11 | 11 | * Vix.cpp |
12 | 12 | * |
13 | | - * Production-safe target-aware build graph executor |
| 13 | + * Compatibility adapter for the engine graph executor |
14 | 14 | * |
15 | 15 | */ |
16 | 16 |
|
17 | 17 | #ifndef VIX_CLI_BUILD_BUILD_GRAPH_EXECUTOR_HPP |
18 | 18 | #define VIX_CLI_BUILD_BUILD_GRAPH_EXECUTOR_HPP |
19 | 19 |
|
20 | | -#include <cstddef> |
21 | | -#include <filesystem> |
22 | | -#include <string> |
23 | | -#include <vector> |
24 | | - |
25 | | -#include <vix/cli/build/BuildGraph.hpp> |
26 | | -#include <vix/cli/build/BuildScheduler.hpp> |
| 20 | +#include <vix/engine/BuildGraphExecutor.hpp> |
27 | 21 |
|
28 | 22 | namespace vix::cli::build |
29 | 23 | { |
30 | | - namespace fs = std::filesystem; |
31 | | - |
32 | | - enum class BuildGraphExecutorStatus |
33 | | - { |
34 | | - Success, |
35 | | - UpToDate, |
36 | | - DelegatedToNinja, |
37 | | - InvalidRequest, |
38 | | - InvalidGraph, |
39 | | - UnsupportedTarget, |
40 | | - CompileFailed, |
41 | | - NinjaFailed, |
42 | | - CacheFailed |
43 | | - }; |
44 | | - |
45 | | - inline const char *to_string(BuildGraphExecutorStatus status) |
46 | | - { |
47 | | - switch (status) |
48 | | - { |
49 | | - case BuildGraphExecutorStatus::Success: |
50 | | - return "success"; |
51 | | - case BuildGraphExecutorStatus::UpToDate: |
52 | | - return "up-to-date"; |
53 | | - case BuildGraphExecutorStatus::DelegatedToNinja: |
54 | | - return "delegated-to-ninja"; |
55 | | - case BuildGraphExecutorStatus::InvalidRequest: |
56 | | - return "invalid-request"; |
57 | | - case BuildGraphExecutorStatus::InvalidGraph: |
58 | | - return "invalid-graph"; |
59 | | - case BuildGraphExecutorStatus::UnsupportedTarget: |
60 | | - return "unsupported-target"; |
61 | | - case BuildGraphExecutorStatus::CompileFailed: |
62 | | - return "compile-failed"; |
63 | | - case BuildGraphExecutorStatus::NinjaFailed: |
64 | | - return "ninja-failed"; |
65 | | - case BuildGraphExecutorStatus::CacheFailed: |
66 | | - return "cache-failed"; |
67 | | - default: |
68 | | - return "unknown"; |
69 | | - } |
70 | | - } |
71 | | - |
72 | | - struct BuildGraphExecutorOptions |
73 | | - { |
74 | | - fs::path buildDir; |
75 | | - std::string target; |
76 | | - |
77 | | - int jobs{0}; |
78 | | - bool quiet{false}; |
79 | | - bool verbose{false}; |
80 | | - |
81 | | - /* |
82 | | - * Production rule: |
83 | | - * The graph executor is an optimization layer. |
84 | | - * Ninja remains the source of truth when the graph is incomplete, |
85 | | - * ambiguous, unsupported or too risky. |
86 | | - */ |
87 | | - bool allowNinjaFallback{true}; |
88 | | - |
89 | | - /* |
90 | | - * 0 means no artificial limit. |
91 | | - * Production builds should not fail just because many files are dirty. |
92 | | - * Large dirty sets can be delegated to Ninja instead. |
93 | | - */ |
94 | | - std::size_t maxGraphDirtyCompileTasks{0}; |
95 | | - }; |
96 | | - |
97 | | - struct BuildGraphExecutorResult |
98 | | - { |
99 | | - bool ok{false}; |
100 | | - |
101 | | - BuildGraphExecutorStatus status{BuildGraphExecutorStatus::InvalidRequest}; |
102 | | - |
103 | | - std::string target; |
104 | | - std::string reason; |
105 | | - |
106 | | - bool usedGraph{false}; |
107 | | - bool usedNinja{false}; |
108 | | - bool usedFallback{false}; |
109 | | - |
110 | | - std::size_t selectedTasks{0}; |
111 | | - std::size_t selectedCompileTasks{0}; |
112 | | - std::size_t dirtyCompileTasks{0}; |
113 | | - std::size_t executedCompileTasks{0}; |
114 | | - std::size_t skippedCompileTasks{0}; |
115 | | - |
116 | | - int exitCode{0}; |
117 | | - std::string output; |
118 | | - |
119 | | - bool success() const |
120 | | - { |
121 | | - return ok && exitCode == 0; |
122 | | - } |
123 | | - }; |
124 | | - |
125 | | - class BuildGraphExecutor |
126 | | - { |
127 | | - public: |
128 | | - explicit BuildGraphExecutor(BuildGraphExecutorOptions options); |
129 | | - |
130 | | - const BuildGraphExecutorOptions &options() const; |
131 | | - |
132 | | - BuildGraphExecutorResult run_target(BuildGraph &graph) const; |
133 | | - |
134 | | - private: |
135 | | - BuildGraphExecutorOptions options_; |
136 | | - }; |
| 24 | + using vix::engine::BuildGraphCompileExecutor; |
| 25 | + using vix::engine::BuildGraphExecutor; |
| 26 | + using vix::engine::BuildGraphExecutorDependencies; |
| 27 | + using vix::engine::BuildGraphExecutorEvent; |
| 28 | + using vix::engine::BuildGraphExecutorEventKind; |
| 29 | + using vix::engine::BuildGraphExecutorEventSink; |
| 30 | + using vix::engine::BuildGraphExecutorNinjaRequest; |
| 31 | + using vix::engine::BuildGraphExecutorNinjaResult; |
| 32 | + using vix::engine::BuildGraphExecutorOptions; |
| 33 | + using vix::engine::BuildGraphExecutorResult; |
| 34 | + using vix::engine::BuildGraphExecutorStatus; |
| 35 | + using vix::engine::BuildGraphNinjaExecutor; |
| 36 | + using vix::engine::to_string; |
137 | 37 |
|
138 | 38 | } // namespace vix::cli::build |
139 | 39 |
|
|
0 commit comments