-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbackend.cppm
More file actions
52 lines (40 loc) · 1.85 KB
/
backend.cppm
File metadata and controls
52 lines (40 loc) · 1.85 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
// mcpp.build.backend — abstract interface separating "what" from "how".
export module mcpp.build.backend;
import std;
import mcpp.build.plan;
export namespace mcpp::build {
enum class BackendKind { Ninja, Native };
struct BuildOptions {
bool verbose = false;
bool dryRun = false;
std::size_t parallelJobs = 0;
};
struct BuildResult {
int exitCode = 0;
std::vector<std::filesystem::path> producedArtifacts;
std::chrono::milliseconds elapsed { 0 };
std::size_t cacheHits = 0;
std::size_t cacheMisses = 0;
std::string ninjaProgram; // P0: cached for fast-path rebuilds
std::string runtimeEnvKey; // cached for fast-path rebuilds
std::string runtimeEnvValue; // cached for fast-path rebuilds
};
struct BuildError {
std::string message;
std::optional<std::filesystem::path> where;
std::string diagnosticOutput;
};
struct Backend {
virtual ~Backend() = default;
virtual std::string_view name() const = 0;
virtual std::expected<BuildResult, BuildError>
build(const BuildPlan& plan, const BuildOptions& opts) = 0;
virtual std::expected<std::vector<std::filesystem::path>, BuildError>
stale_units(const BuildPlan&) {
return std::unexpected(BuildError{"stale_units not implemented for this backend", std::nullopt});
}
};
// Factories live in their respective implementation modules; the CLI
// dispatches at the call site. This avoids a backend.cppm → ninja.cppm
// import which would otherwise create a circular layering.
} // namespace mcpp::build