-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
289 lines (237 loc) · 11.1 KB
/
build.zig
File metadata and controls
289 lines (237 loc) · 11.1 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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const feature_options = b.addOptions();
feature_options.addOption(bool, "ice_udp", b.option(bool, "ice_udp", "Enable ICE over UDP") orelse true);
feature_options.addOption(bool, "ice_tcp", b.option(bool, "ice_tcp", "Enable ICE over TCP") orelse false);
feature_options.addOption(bool, "turn", b.option(bool, "turn", "Enable TURN support") orelse false);
feature_options.addOption(bool, "turn_tcp", b.option(bool, "turn_tcp", "Enable TURN over TCP support") orelse false);
feature_options.addOption(bool, "trickle", b.option(bool, "trickle", "Enable Trickle ICE support") orelse true);
feature_options.addOption(bool, "consent", b.option(bool, "consent", "Enable consent freshness checks") orelse false);
feature_options.addOption(bool, "reliable", b.option(bool, "reliable", "Enable reliable/bytestream mode") orelse false);
feature_options.addOption(bool, "upnp", b.option(bool, "upnp", "Enable UPnP integration") orelse false);
// Create the libdice module
const libdice_module = b.createModule(.{
.root_source_file = b.path("lib/libdice.zig"),
.target = target,
.optimize = optimize,
});
libdice_module.addOptions("build_options", feature_options);
// Export the module so it can be used by other projects
_ = b.addModule("libdice", .{
.root_source_file = b.path("lib/libdice.zig"),
.target = target,
.optimize = optimize,
});
// Build the library
const lib = b.addLibrary(.{
.name = "dice",
.root_module = libdice_module,
.linkage = .static,
});
b.installArtifact(lib);
// Unit tests
const lib_unit_tests = b.addTest(.{
.root_module = libdice_module,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
// Bootstrap regression subset
const dual_mode_module = b.createModule(.{
.root_source_file = b.path("lib/dual_mode_regression_test.zig"),
.target = target,
.optimize = optimize,
});
dual_mode_module.addImport("libdice", libdice_module);
const dual_mode_tests = b.addTest(.{
.root_module = dual_mode_module,
});
const run_dual_mode_tests = b.addRunArtifact(dual_mode_tests);
const dual_mode_step = b.step("test-dual-mode-regression", "Run bootstrap regression tests");
dual_mode_step.dependOn(&run_dual_mode_tests.step);
// Optional coturn integration smoke test (requires running coturn)
const coturn_integration_module = b.createModule(.{
.root_source_file = b.path("lib/integration/coturn_smoke_test.zig"),
.target = target,
.optimize = optimize,
});
coturn_integration_module.addImport("libdice", libdice_module);
const coturn_integration_tests = b.addTest(.{
.root_module = coturn_integration_module,
});
const run_coturn_integration = b.addRunArtifact(coturn_integration_tests);
const coturn_integration_step = b.step("test-coturn-integration", "Run coturn integration smoke test");
coturn_integration_step.dependOn(&run_coturn_integration.step);
// Examples
// Smoke server A
const smoke_server_a_module = b.createModule(.{
.root_source_file = b.path("examples/smoke_server_a.zig"),
.target = target,
.optimize = optimize,
});
smoke_server_a_module.addImport("libdice", libdice_module);
const smoke_server_a = b.addExecutable(.{
.name = "smoke_server_a",
.root_module = smoke_server_a_module,
});
b.installArtifact(smoke_server_a);
const run_smoke_server_a = b.addRunArtifact(smoke_server_a);
const smoke_server_a_step = b.step("run-smoke-server-a", "Run smoke server example A");
smoke_server_a_step.dependOn(&run_smoke_server_a.step);
// Smoke client A
const smoke_client_a_module = b.createModule(.{
.root_source_file = b.path("examples/smoke_client_a.zig"),
.target = target,
.optimize = optimize,
});
smoke_client_a_module.addImport("libdice", libdice_module);
const smoke_client_a = b.addExecutable(.{
.name = "smoke_client_a",
.root_module = smoke_client_a_module,
});
b.installArtifact(smoke_client_a);
const run_smoke_client_a = b.addRunArtifact(smoke_client_a);
const smoke_client_a_step = b.step("run-smoke-client-a", "Run smoke client example A");
smoke_client_a_step.dependOn(&run_smoke_client_a.step);
// Smoke server B
const smoke_server_b_module = b.createModule(.{
.root_source_file = b.path("examples/smoke_server_b.zig"),
.target = target,
.optimize = optimize,
});
smoke_server_b_module.addImport("libdice", libdice_module);
const smoke_server_b = b.addExecutable(.{
.name = "smoke_server_b",
.root_module = smoke_server_b_module,
});
b.installArtifact(smoke_server_b);
const run_smoke_server_b = b.addRunArtifact(smoke_server_b);
const smoke_server_b_step = b.step("run-smoke-server-b", "Run smoke server example B");
smoke_server_b_step.dependOn(&run_smoke_server_b.step);
// Smoke client B
const smoke_client_b_module = b.createModule(.{
.root_source_file = b.path("examples/smoke_client_b.zig"),
.target = target,
.optimize = optimize,
});
smoke_client_b_module.addImport("libdice", libdice_module);
const smoke_client_b = b.addExecutable(.{
.name = "smoke_client_b",
.root_module = smoke_client_b_module,
});
b.installArtifact(smoke_client_b);
const run_smoke_client_b = b.addRunArtifact(smoke_client_b);
const smoke_client_b_step = b.step("run-smoke-client-b", "Run smoke client example B");
smoke_client_b_step.dependOn(&run_smoke_client_b.step);
// ICE pump demo
const ice_pump_demo_module = b.createModule(.{
.root_source_file = b.path("examples/ice_pump_demo.zig"),
.target = target,
.optimize = optimize,
});
ice_pump_demo_module.addImport("libdice", libdice_module);
const ice_pump_demo = b.addExecutable(.{
.name = "ice_pump_demo",
.root_module = ice_pump_demo_module,
});
b.installArtifact(ice_pump_demo);
const run_ice_pump_demo = b.addRunArtifact(ice_pump_demo);
const ice_pump_demo_step = b.step("run-ice-pump-demo", "Run ICE pump demo example");
ice_pump_demo_step.dependOn(&run_ice_pump_demo.step);
// ICE timeout demo
const ice_timeout_demo_module = b.createModule(.{
.root_source_file = b.path("examples/ice_timeout_demo.zig"),
.target = target,
.optimize = optimize,
});
ice_timeout_demo_module.addImport("libdice", libdice_module);
const ice_timeout_demo = b.addExecutable(.{
.name = "ice_timeout_demo",
.root_module = ice_timeout_demo_module,
});
b.installArtifact(ice_timeout_demo);
const run_ice_timeout_demo = b.addRunArtifact(ice_timeout_demo);
const ice_timeout_demo_step = b.step("run-ice-timeout-demo", "Run ICE timeout demo example");
ice_timeout_demo_step.dependOn(&run_ice_timeout_demo.step);
// ICE drive demo
const ice_drive_demo_module = b.createModule(.{
.root_source_file = b.path("examples/ice_drive_demo.zig"),
.target = target,
.optimize = optimize,
});
ice_drive_demo_module.addImport("libdice", libdice_module);
const ice_drive_demo = b.addExecutable(.{
.name = "ice_drive_demo",
.root_module = ice_drive_demo_module,
});
b.installArtifact(ice_drive_demo);
const run_ice_drive_demo = b.addRunArtifact(ice_drive_demo);
const ice_drive_demo_step = b.step("run-ice-drive-demo", "Run ICE drive-loop demo example");
ice_drive_demo_step.dependOn(&run_ice_drive_demo.step);
// ICE demo selector
const ice_demo_selector_module = b.createModule(.{
.root_source_file = b.path("examples/ice_demo_selector.zig"),
.target = target,
.optimize = optimize,
});
ice_demo_selector_module.addImport("libdice", libdice_module);
const ice_demo_selector = b.addExecutable(.{
.name = "ice_demo_selector",
.root_module = ice_demo_selector_module,
});
b.installArtifact(ice_demo_selector);
const run_ice_demo_selector = b.addRunArtifact(ice_demo_selector);
if (b.args) |args| {
run_ice_demo_selector.addArgs(args);
}
const ice_demo_selector_step = b.step("run-ice-demo", "Run ICE demo selector (pump|timeout|drive|sdp|simple)");
ice_demo_selector_step.dependOn(&run_ice_demo_selector.step);
// Simple minimal demo
const simple_example_module = b.createModule(.{
.root_source_file = b.path("examples/simple_example.zig"),
.target = target,
.optimize = optimize,
});
simple_example_module.addImport("libdice", libdice_module);
const simple_example = b.addExecutable(.{
.name = "simple_example",
.root_module = simple_example_module,
});
b.installArtifact(simple_example);
const run_simple_example = b.addRunArtifact(simple_example);
const simple_example_step = b.step("run-simple-example", "Run minimal simple example");
simple_example_step.dependOn(&run_simple_example.step);
// SDP-style signaling demo
const sdp_example_module = b.createModule(.{
.root_source_file = b.path("examples/sdp_example.zig"),
.target = target,
.optimize = optimize,
});
sdp_example_module.addImport("libdice", libdice_module);
const sdp_example = b.addExecutable(.{
.name = "sdp_example",
.root_module = sdp_example_module,
});
b.installArtifact(sdp_example);
const run_sdp_example = b.addRunArtifact(sdp_example);
const sdp_example_step = b.step("run-sdp-example", "Run SDP-style signaling example");
sdp_example_step.dependOn(&run_sdp_example.step);
const run_ice_demo_pump_summary = b.addRunArtifact(ice_demo_selector);
run_ice_demo_pump_summary.addArgs(&.{ "pump", "--summary" });
const run_ice_demo_timeout_summary = b.addRunArtifact(ice_demo_selector);
run_ice_demo_timeout_summary.addArgs(&.{ "timeout", "--summary" });
const run_ice_demo_drive_summary = b.addRunArtifact(ice_demo_selector);
run_ice_demo_drive_summary.addArgs(&.{ "drive", "--summary" });
const run_ice_demo_sdp_summary = b.addRunArtifact(ice_demo_selector);
run_ice_demo_sdp_summary.addArgs(&.{ "sdp", "--summary" });
const run_ice_demo_simple_summary = b.addRunArtifact(ice_demo_selector);
run_ice_demo_simple_summary.addArgs(&.{ "simple", "--summary" });
const examples_smoke_step = b.step("test-examples-smoke", "Run nonblocking example smoke scenarios");
examples_smoke_step.dependOn(&run_ice_demo_pump_summary.step);
examples_smoke_step.dependOn(&run_ice_demo_timeout_summary.step);
examples_smoke_step.dependOn(&run_ice_demo_drive_summary.step);
examples_smoke_step.dependOn(&run_ice_demo_sdp_summary.step);
examples_smoke_step.dependOn(&run_ice_demo_simple_summary.step);
}