-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
154 lines (127 loc) · 4.88 KB
/
build.zig
File metadata and controls
154 lines (127 loc) · 4.88 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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) !void {
// Standard target options allows the person running `zig build` to choose
// what target to build for. Here we do not override the defaults, which
// means any target is allowed, and the default is native. Other options
// for restricting supported target set are available.
const target = b.standardTargetOptions(.{});
if (target.result.os.tag != .linux) {
return error.InvalidOS;
}
// Standard optimization options allow the person running `zig build` to select
// between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not
// set a preferred release mode, allowing the user to decide how to optimize.
const optimize = b.standardOptimizeOption(.{});
const libvoid_module = b.createModule(.{
.root_source_file = b.path("lib/libvoid.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
_ = b.addModule("libvoid", .{
.root_source_file = b.path("lib/libvoid.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
const lib = b.addLibrary(.{
.name = "void",
.root_module = libvoid_module,
.linkage = .static,
});
b.installArtifact(lib);
const exe_unit_tests = b.addTest(.{
.root_module = libvoid_module,
});
const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
// Similar to creating the run step earlier, this exposes a `test` step to
// the `zig build --help` menu, providing a way for the user to request
// running the unit tests.
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_exe_unit_tests.step);
const ex_shell_module = b.createModule(.{
.root_source_file = b.path("examples/embedder_launch_shell.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
ex_shell_module.addImport("libvoid", libvoid_module);
const ex_shell = b.addExecutable(.{
.name = "example_embedder_launch_shell",
.root_module = ex_shell_module,
});
const ex_events_module = b.createModule(.{
.root_source_file = b.path("examples/embedder_events.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
ex_events_module.addImport("libvoid", libvoid_module);
const ex_events = b.addExecutable(.{
.name = "example_embedder_events",
.root_module = ex_events_module,
});
const ex_pty_module = b.createModule(.{
.root_source_file = b.path("examples/embedder_pty_isolation.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
ex_pty_module.addImport("libvoid", libvoid_module);
const ex_pty = b.addExecutable(.{
.name = "example_embedder_pty_isolation",
.root_module = ex_pty_module,
});
const ex_showcase_module = b.createModule(.{
.root_source_file = b.path("examples/embedder_isolation_showcase.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
ex_showcase_module.addImport("libvoid", libvoid_module);
const ex_showcase = b.addExecutable(.{
.name = "example_embedder_isolation_showcase",
.root_module = ex_showcase_module,
});
const vb_module = b.createModule(.{
.root_source_file = b.path("bin/vb.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
vb_module.addImport("libvoid", libvoid_module);
const vb_unit_tests = b.addTest(.{
.root_module = vb_module,
});
const run_vb_unit_tests = b.addRunArtifact(vb_unit_tests);
test_step.dependOn(&run_vb_unit_tests.step);
const vb = b.addExecutable(.{
.name = "vb",
.root_module = vb_module,
});
b.installArtifact(vb);
const vb_step = b.step("vb", "Compile vb CLI binary");
vb_step.dependOn(&vb.step);
b.installArtifact(ex_pty);
const ex_landlock_module = b.createModule(.{
.root_source_file = b.path("examples/embedder_landlock.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
ex_landlock_module.addImport("libvoid", libvoid_module);
const ex_landlock = b.addExecutable(.{
.name = "example_embedder_landlock",
.root_module = ex_landlock_module,
});
b.installArtifact(ex_landlock);
const examples_step = b.step("examples", "Compile embedder examples");
examples_step.dependOn(&ex_shell.step);
examples_step.dependOn(&ex_events.step);
examples_step.dependOn(&ex_pty.step);
examples_step.dependOn(&ex_showcase.step);
examples_step.dependOn(&ex_landlock.step);
}