-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbuild.mcpp
More file actions
39 lines (36 loc) · 1.74 KB
/
Copy pathbuild.mcpp
File metadata and controls
39 lines (36 loc) · 1.74 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
import std;
import mcpp;
import mcpp.plugins;
import mcpp.rules.cuda;
import mcpp.rules.spirv;
// TWO RULES IN ONE BUILD PROGRAM, which is what a project with several
// backends needs and what the four examples beside this one never exercised.
//
// Both are called unconditionally. Neither is told which backends this build
// named -- each parses `[build] accel` itself and returns immediately when its
// own is absent, so `mcpp build` with no accel runs both and compiles nothing.
// That is also why the order here carries no meaning.
//
// Each rule takes the device sources whose EXTENSION it claims and leaves the
// rest: `mcpp::device_sources()` is the package's whole device set, and in a
// build that names both backends it holds a `.cu` and a `.comp`. A device
// source no rule claims is not silently dropped -- the engine refuses a device
// source that reached no action.
int main() {
mcpp::rerun_if_changed_glob("src/backends/**/*.cu");
mcpp::rerun_if_changed_glob("src/backends/**/*.comp");
mcpp::rules::cuda::options cu;
cu.includes = { "include" };
if (!mcpp::rules::cuda::compile(cu)) return 1;
mcpp::rules::spirv::options sp;
sp.includes = { "src/backends/vulkan" };
// THE PAYLOAD IS A MODULE. `src/backends/vulkan/host.cpp` opened with
// `#include "saxpy_comp.h"` -- a name no line in this project produced.
// It now imports `opkit.shaders`, named here rather than defaulted so this
// package's modules share the root its library module already uses; the
// default derives from the package name and would give
// `opkit_multi_backend.shaders`.
sp.surface = mcpp::plugins::surface::kind::module_;
sp.module_name = "opkit.shaders";
return mcpp::rules::spirv::compile(sp) ? 0 : 1;
}