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
|
const std = @import("std");
pub const Options = struct {
root_source_file: std.Build.LazyPath,
target: std.Build.ResolvedTarget,
};
mod: *std.Build.Module,
wasm: struct {
mod: *std.Build.Module,
exe: *std.Build.Step.Compile,
},
pub fn init(b: *std.Build, options: Options, zilch_mod: *std.Build.Module) @This() {
const module = b.addModule("site", .{
.root_source_file = options.root_source_file,
.target = options.target,
.imports = &.{ .{ .name = "zilch", .module = zilch_mod } },
});
const wasm_module = b.createModule(.{
.root_source_file = options.root_source_file,
.target = b.resolveTargetQuery(.{
.cpu_arch = .wasm32,
.os_tag = .freestanding,
}),
.imports = &.{ .{ .name = "zilch", .module = zilch_mod } },
});
const exe = b.addExecutable(.{
.name = "runtime",
.root_module = wasm_module,
});
exe.rdynamic = true;
exe.entry = .disabled;
return .{
.mod = module,
.wasm = .{
.exe = exe,
.mod = wasm_module,
},
};
}
pub fn getEmittedWasm(self: *const @This()) std.Build.LazyPath {
return self.wasm.exe.getEmittedBin();
}
|