-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
197 lines (172 loc) · 6.36 KB
/
build.zig
File metadata and controls
197 lines (172 loc) · 6.36 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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const mod = b.addModule("websocket", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
const mod_tests = b.addTest(.{ .root_module = mod });
const run_mod_tests = b.addRunArtifact(mod_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_mod_tests.step);
const echo_server = b.addExecutable(.{
.name = "echo-server",
.root_module = b.createModule(.{
.root_source_file = b.path("test/echo_server.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{
.{ .name = "websocket", .module = mod },
},
}),
});
echo_server.root_module.linkSystemLibrary("zlib", .{ .use_pkg_config = .force });
b.installArtifact(echo_server);
const echo_run = b.addRunArtifact(echo_server);
if (b.args) |args| {
echo_run.addArgs(args);
}
const echo_step = b.step("echo-server", "Run the Autobahn echo server");
echo_step.dependOn(&echo_run.step);
const echo_client = b.addExecutable(.{
.name = "echo-client",
.root_module = b.createModule(.{
.root_source_file = b.path("test/echo_client.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{
.{ .name = "websocket", .module = mod },
},
}),
});
echo_client.root_module.linkSystemLibrary("zlib", .{ .use_pkg_config = .force });
b.installArtifact(echo_client);
const examples_step = b.step("examples", "Build all examples");
const blocking_echo = b.addExecutable(.{
.name = "blocking-echo",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/blocking-echo.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "websocket", .module = mod },
},
}),
});
b.installArtifact(blocking_echo);
examples_step.dependOn(&blocking_echo.step);
const http_upgrade = b.addExecutable(.{
.name = "http-upgrade",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/http-upgrade.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "websocket", .module = mod },
},
}),
});
b.installArtifact(http_upgrade);
examples_step.dependOn(&http_upgrade.step);
const blocking_client = b.addExecutable(.{
.name = "blocking-client",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/blocking-client.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "websocket", .module = mod },
},
}),
});
b.installArtifact(blocking_client);
examples_step.dependOn(&blocking_client.step);
const run_autobahn = b.path("scripts/run-autobahn.nu").getPath(b);
const conformance_script = b.addSystemCommand(&.{
"nu",
run_autobahn,
b.getInstallPath(.bin, "echo-server"),
"9002",
"echo-server",
"fast",
});
conformance_script.step.dependOn(&b.addInstallArtifact(echo_server, .{}).step);
const conformance_step = b.step("conformance", "Run the fast Autobahn conformance suite");
conformance_step.dependOn(&conformance_script.step);
const conformance_full_script = b.addSystemCommand(&.{
"nu",
run_autobahn,
b.getInstallPath(.bin, "echo-server"),
"9002",
"echo-server",
"full",
});
conformance_full_script.step.dependOn(&b.addInstallArtifact(echo_server, .{}).step);
const conformance_full_step = b.step(
"conformance-full",
"Run the full Autobahn conformance test suite",
);
conformance_full_step.dependOn(&conformance_full_script.step);
const run_autobahn_client = b.path("scripts/run-autobahn-client.nu").getPath(b);
const conformance_client_script = b.addSystemCommand(&.{
"nu",
run_autobahn_client,
b.getInstallPath(.bin, "echo-client"),
"9001",
"echo-client",
"fast",
});
conformance_client_script.step.dependOn(&b.addInstallArtifact(echo_client, .{}).step);
const conformance_client_step = b.step(
"conformance-client",
"Run the fast Autobahn client conformance suite",
);
conformance_client_step.dependOn(&conformance_client_script.step);
const conformance_client_full_script = b.addSystemCommand(&.{
"nu",
run_autobahn_client,
b.getInstallPath(.bin, "echo-client"),
"9001",
"echo-client",
"full",
});
conformance_client_full_script.step.dependOn(&b.addInstallArtifact(echo_client, .{}).step);
const conformance_client_full_step = b.step(
"conformance-client-full",
"Run the full Autobahn client conformance test suite",
);
conformance_client_full_step.dependOn(&conformance_client_full_script.step);
if (b.lazyDependency("libxev", .{})) |xev_dep| {
const xev_echo = b.addExecutable(.{
.name = "xev-echo",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/xev-echo.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "websocket", .module = mod },
.{ .name = "xev", .module = xev_dep.module("xev") },
},
}),
});
const xev_install = b.addInstallArtifact(xev_echo, .{});
examples_step.dependOn(&xev_install.step);
const xev_conformance = b.addSystemCommand(&.{
"nu",
run_autobahn,
b.getInstallPath(.bin, "xev-echo"),
"9003",
"xev-echo",
"fast",
});
xev_conformance.step.dependOn(&xev_install.step);
const xev_conf_step = b.step(
"conformance-xev",
"Run Autobahn against xev echo server",
);
xev_conf_step.dependOn(&xev_conformance.step);
}
}