-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
111 lines (87 loc) · 2.9 KB
/
build.zig
File metadata and controls
111 lines (87 loc) · 2.9 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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
const std = @import("std");
const std_options: std.Options = .{
.enable_segfault_handler = true,
.page_size_min = std.wasm.Limits.min,
// .page_size_min = 96,
// .page_size_min = "wrong type entirely",
};
// References used when making this:
// https://github.com/SimonLSchlee/zig15game/blob/5d0a33d753528df890f0ab5dd56cd04ff6d0e1c2/build.zig#L77
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const target_wasm = b.resolveTargetQuery(.{
.cpu_arch = .wasm32, //std.Target.Cpu.Arch
.os_tag = .freestanding,
});
// const target_wgl = b.resolveTargetQuery(.{
// .cpu_arch = .wasm32,
// .os_tag = .opengl,
// });
const optimize = b.standardOptimizeOption(.{});
const optimize_wasm = std.builtin.OptimizeMode.ReleaseSmall;
const zap_mod = b.dependency("zap", .{
.target = target,
.optimize = optimize,
.openssl = false,
});
// const checks_mod = b.createModule(.{
_ = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const server_mod = b.createModule(.{
.root_source_file = b.path("src/server.zig"),
.target = target,
.optimize = optimize,
});
const checks_mod = b.createModule(.{
// _ = b.createModule(.{
.root_source_file = b.path("src/checks.zig"),
.target = target_wasm,
.optimize = optimize_wasm,
});
const root_mod = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
// .target = target_wgl,
.target = target_wasm,
.optimize = optimize_wasm,
});
const checks = b.addExecutable(.{
.name = "checkerboard",
.root_module = checks_mod,
});
checks.global_base = 6560;
checks.entry = .disabled;
checks.rdynamic = true;
checks.import_memory = true;
checks.stack_size = std.wasm.page_size;
checks.initial_memory = std.wasm.page_size * 2;
checks.max_memory = std.wasm.page_size * 300;
b.installArtifact(checks);
const root = b.addExecutable(.{
.name = "root",
.root_module = root_mod,
});
root.global_base = 6560;
root.entry = .disabled;
root.rdynamic = true;
root.import_memory = true;
root.stack_size = std.wasm.page_size;
root.initial_memory = std.wasm.page_size * 2;
root.max_memory = std.wasm.page_size * 300;
b.installArtifact(root);
const server = b.addExecutable(.{
.name = "server",
.root_module = server_mod,
});
server.root_module.addImport("zap", zap_mod.module("zap"));
b.installArtifact(server);
const run_cmd = b.addRunArtifact(server);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}