-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProcess.hpp
More file actions
249 lines (202 loc) · 5.49 KB
/
Copy pathProcess.hpp
File metadata and controls
249 lines (202 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
/**
*
* @file Process.hpp
* @author Gaspard Kirira
*
* Copyright 2025, Gaspard Kirira. All rights reserved.
* https://github.com/vixcpp/vix
* Use of this source code is governed by a MIT license
* that can be found in the License file.
*
* Vix.cpp
*/
#ifndef VIX_CLI_PROCESS_HPP
#define VIX_CLI_PROCESS_HPP
#include <filesystem>
#include <optional>
#include <string>
#include <utility>
#include <vector>
#include <vix/engine/BuildTools.hpp>
#include <vix/engine/ExecutionPlan.hpp>
#include <vix/engine/Preset.hpp>
#include <vix/engine/SanitizerMode.hpp>
namespace vix::cli::process
{
namespace fs = std::filesystem;
using LinkerMode = vix::engine::LinkerMode;
using LauncherMode = vix::engine::LauncherMode;
using SanitizerMode = vix::engine::SanitizerMode;
/**
* @brief Parsed options for the `vix build` command.
*
* This structure stores all user-facing build configuration flags
* after command-line parsing.
*/
struct Options
{
/**
* @brief Selected embedded preset.
*
* Supported values include:
* - dev
* - dev-ninja
* - release
*/
std::string preset = "dev-ninja";
/**
* @brief Cross-compilation target triple passed with `--target`.
*/
std::string targetTriple;
/**
* @brief Optional sysroot path for cross-compilation.
*/
std::string sysroot;
/**
* @brief Enables static linking when supported by the project.
*/
bool linkStatic = false;
/**
* @brief Number of parallel jobs to use for the build.
*
* A value of 0 means "auto-detect".
*/
int jobs = 0;
/**
* @brief Forces a fresh configure step.
*/
bool clean = false;
/**
* @brief Enables quiet console output.
*/
bool quiet = false;
/**
* @brief Enables detailed build output.
*
* When false, `vix build` should prefer a minimal product-style output.
*/
bool verbose = false;
/** Enables structured internal Vix build diagnostics. */
bool debug = false;
/** Optional focused internal diagnostic scope. */
std::string debugLogScope;
/** Optional captured log scope to display instead of building. */
std::string logScope;
bool showLog = false;
std::string logPath;
/**
* @brief Explains why Vix rebuilds files or targets.
*/
bool explain = false;
/**
* @brief Keep the build process alive and rebuild after project changes.
*/
bool watch = false;
/**
* @brief Optional project directory passed with `--dir`.
*/
std::string dir;
/**
* @brief Enables fast no-op detection before building.
*/
bool fast = false;
/**
* @brief Enables signature/configuration cache reuse.
*/
bool useCache = true;
/**
* @brief Preferred linker mode.
*/
LinkerMode linker = LinkerMode::Auto;
/**
* @brief Preferred compiler launcher mode.
*/
LauncherMode launcher = LauncherMode::Auto;
/**
* @brief Enables Ninja progress status output.
*/
bool status = true;
/**
* @brief Enables Ninja dry-run up-to-date detection.
*/
bool dryUpToDate = true;
/**
* @brief Enables raw CMake verbose configure output.
*/
bool cmakeVerbose = false;
/** Graph executor policy: auto, on, or off. */
std::string graphExecutor = "auto";
bool graphExecutorExplicit = false;
/** Lists detected target toolchains and exits. */
bool listTargets = false;
/** Explicit heartbeat control; unset keeps the legacy/default behavior. */
std::optional<bool> heartbeat;
/**
* @brief Builds only a specific CMake target when provided.
*/
std::string buildTarget;
/**
* @brief Extra arguments forwarded directly to CMake.
*/
std::vector<std::string> cmakeArgs;
/**
* @brief Sanitizer instrumentation selected for this build.
*
* The default build remains uninstrumented.
*/
SanitizerMode sanitizerMode = SanitizerMode::None;
/**
* @brief True when the sanitizer mode was explicitly selected.
*/
bool sanitizerSelectionExplicit = false;
bool withSqlite = false;
bool withMySql = false;
bool exportBin = false;
std::string outPath;
bool singleCpp = false;
fs::path cppFile;
bool warnings{false};
std::size_t warningsPage{1};
std::size_t warningsLimit{10};
bool warningsPageSet{false};
bool warningsLimitSet{false};
bool warningCheck{false};
bool managedSdk{false};
/**
* @brief Submit a Softadastra Cloud build report after the build completes.
*/
bool report{false};
};
/**
* @brief Result of a spawned child process.
*/
struct ExecResult
{
/**
* @brief Normalized process exit code.
*/
int exitCode = 0;
/**
* @brief User-readable reconstructed command line.
*/
std::string displayCommand;
/**
* @brief True if the process produced any stdout/stderr output.
*/
bool producedOutput = false;
/**
* @brief Captured first output line when available.
*/
std::string capturedFirstLine;
};
using Preset = vix::engine::Preset;
using Plan = vix::engine::ExecutionPlan;
/**
* @brief Normalizes a raw process exit status into a standard exit code.
*
* @param raw Raw process status value returned by the OS.
* @return Normalized integer exit code.
*/
[[nodiscard]] int normalize_exit_code(int raw) noexcept;
} // namespace vix::cli::process
#endif