-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathbuild.mcpp
More file actions
45 lines (41 loc) · 2.01 KB
/
Copy pathbuild.mcpp
File metadata and controls
45 lines (41 loc) · 2.01 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
import std;
import mcpp;
import mcpp.tools.island;
// The lowest rung: the generated boundary module IS the interface, and this
// project contains no seam and no header.
//
// ONE ROOT, AND IT IS A TREE. `scan` reads every marked entry point under it
// and the directories below it extend the namespace, so `src/kernels/vec` is
// reached as `boundary::kernels::vec`. A root is also what makes ADDING a file
// re-run this program: declared inputs are hashed contents, and a new file
// changes none of them, so the root is registered as a glob as well.
//
// A single root is also the layout root, so nothing here has to say which tree
// decides where entry points live. `../cuda` has two and says so.
int main() {
mcpp::tools::island::options opt;
opt.module_name = "boundary.kernels";
opt.out_dir = std::string(mcpp::out_dir()) + "/island";
opt.produced_by = "the boundary example";
opt.roots = { std::string(mcpp::manifest_dir()) + "/src/kernels" };
// An island's symbol is global to the whole program, so an entry point
// carries a prefix whether or not it sits in a namespace, and the namespace
// then repeats it. This emits `saxpy` beside `boundary_saxpy`; the authored
// name is the symbol and stays canonical.
opt.strip_prefix = "boundary_";
const auto entries = mcpp::tools::island::scan(opt);
if (!entries) return 1;
const auto out = mcpp::tools::island::emit(*entries, opt);
if (!out) return 1;
// The island reads the generated header through a forced-include flag, so
// no source in this project names a generated file.
//
// `cflag` and not `cxxflag`: the island is C, and forcing a header into
// every C++ translation unit would put declarations ahead of the
// `export module` line of a module interface, which is ill-formed.
for (auto const& f : mcpp::tools::island::force_include_flags(
out->header_file, mcpp::compiler()))
mcpp::cflag(f.c_str());
mcpp::generated(out->interface_file.c_str());
return 0;
}