Repository navigation
Expand file tree
/
Copy pathbuild.mcpp
More file actions
97 lines (93 loc) · 4.66 KB
/
Copy pathbuild.mcpp
File metadata and controls
97 lines (93 loc) · 4.66 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
// Imports every rule and calls it. The call matters as much as the import: a
// module can be well-formed and still hold a template or an `if constexpr`
// branch that is only instantiated at a call site, and a rule that refuses to
// build the host it is being compiled for should say so here rather than in
// someone's project.
import std;
import mcpp;
import mcpp.rules.ascendc;
import mcpp.rules.cuda;
import mcpp.rules.hip;
import mcpp.rules.metal;
import mcpp.rules.qt;
import mcpp.rules.slang;
import mcpp.rules.spirv;
import mcpp.rules.swift;
import mcpp.rules.sycl;
import mcpp.tools.embed;
import mcpp.tools.island;
import mcpp.dist.appimage;
import mcpp.dist.wix;
import mcpp.dist.apple;
import mcpp.dist.web;
import mcpp.dist.apk;
import mcpp.deps;
import mcpp.deps.vcpkg;
import mcpp.deps.cmake;
import mcpp.deps.archive;
int main() {
// No accelerator is named, so each of these returns true without looking
// for a payload. What is asserted is that the module compiled and the
// entry point resolved on this host.
bool ok = mcpp::rules::ascendc::compile()
&& mcpp::rules::cuda::compile()
&& mcpp::rules::hip::compile()
// No `.metal` source is named, so the Metal rule plans nothing and
// never asks `xcrun`, on the hosts that have it and the ones that
// do not.
&& mcpp::rules::metal::compile()
&& mcpp::rules::slang::compile()
&& mcpp::rules::spirv::compile()
// No `.swift` source is named, so the Swift rule plans nothing and
// never asks `xcrun`, as the Metal rule above.
&& mcpp::rules::swift::compile()
&& mcpp::rules::sycl::compile();
// `tools::embed` has no accelerator gate, so it is asked the one question
// that writes nothing: where it WOULD put a header. `embed::file` is not
// called, because a fixture whose point is a compilation should not also
// produce output.
ok = ok && !mcpp::tools::embed::header_path("probe.bin").empty();
// Same question of `table()`, added beside `file()`'s: it is a second
// entry point in one module, not a second module, and this fixture's
// whole point is that everything this package exports compiles for the
// host running the build.
ok = ok && !mcpp::tools::embed::table_header_path().empty();
// Same question of the island generator: the one call that writes
// nothing. `entry_name` is where its only parsing lives.
ok = ok && mcpp::tools::island::entry_name("int f(int a)") == "f";
// `dist-wix`, `dist-apple` and `dist-web` are neither rules nor tools, but the same
// property is worth asserting on every platform for the same reason: a
// plan on a build that is not `mcpp pack --format <name>` must return
// `applies == false` and print nothing, on every host, including the two
// whose format this is not. `pack_format()` is empty here exactly as
// `accel()` is empty above, so both refusals are silent -- neither
// module's Windows-only or macOS-only diagnostic fires, because neither
// reaches the check that would print it.
auto appimagePlan = mcpp::dist::appimage::plan_for();
ok = ok && !appimagePlan.applies;
auto wixPlan = mcpp::dist::wix::plan_for();
ok = ok && !wixPlan.applies;
auto applePlan = mcpp::dist::apple::plan_for();
ok = ok && !applePlan.applies;
auto webPlan = mcpp::dist::web::plan_for();
ok = ok && !webPlan.applies;
// `dist-apk`'s own gate is the target ENVIRONMENT (`cfg(env = "android")`
// on its payload table, `mcpp::target_env() != "android"` in
// `plan_for` itself), not `pack_format()` alone -- this fixture's host
// build satisfies neither, so no payload was ever declared for this run
// and this call reaches no `xpkg_dir` lookup at all.
auto apkPlan = mcpp::dist::apk::plan_for();
ok = ok && !apkPlan.applies;
// `rules-qt` declares no SDK and this fixture declares none, so the
// question that plans nothing is where the SDK would be: nowhere.
ok = ok && mcpp::rules::qt::roots({ .root = "no-such-qt-sdk" }).empty();
// The `deps-*` members install through an action; asked only what they
// derive without one -- the triplet this target defaults to, and the file
// a library name denotes.
ok = ok && !mcpp::deps::vcpkg::default_triplet().empty();
ok = ok && !mcpp::deps::archive::zip_members("mcpp.toml").has_value(); // not a zip: refused, not misread
ok = ok && mcpp::deps::library_file("lib", "fmt", false).filename().string().find("fmt")
!= std::string::npos;
std::println("all-rules-compile: every rule, dist and deps module compiled for this host");
return ok ? 0 : 1;
}