-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
136 lines (112 loc) · 4.36 KB
/
build.zig
File metadata and controls
136 lines (112 loc) · 4.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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const libsafe_dep = b.dependency("libsafe", .{
.target = target,
.optimize = optimize,
});
const libsafe_module = libsafe_dep.module("libsafe");
// Create the libfast module
const libfast_module = b.createModule(.{
.root_source_file = b.path("lib/libfast.zig"),
.target = target,
.optimize = optimize,
});
libfast_module.addImport("libsafe", libsafe_module);
// Export the module so it can be used by other projects
const exported = b.addModule("libfast", .{
.root_source_file = b.path("lib/libfast.zig"),
.target = target,
.optimize = optimize,
});
exported.addImport("libsafe", libsafe_module);
// Build the library
const lib = b.addLibrary(.{
.name = "fast",
.root_module = libfast_module,
.linkage = .static,
});
b.installArtifact(lib);
// Unit tests
const lib_unit_tests = b.addTest(.{
.root_module = libfast_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);
// Dual-mode 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("libfast", libfast_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 paired TLS/SSH regression tests");
dual_mode_step.dependOn(&run_dual_mode_tests.step);
// Examples
// SSH echo server
const ssh_server_module = b.createModule(.{
.root_source_file = b.path("examples/ssh_echo_server.zig"),
.target = target,
.optimize = optimize,
});
ssh_server_module.addImport("libfast", libfast_module);
const ssh_server = b.addExecutable(.{
.name = "ssh_echo_server",
.root_module = ssh_server_module,
});
b.installArtifact(ssh_server);
const run_ssh_server = b.addRunArtifact(ssh_server);
const ssh_server_step = b.step("run-ssh-server", "Run SSH/QUIC echo server example");
ssh_server_step.dependOn(&run_ssh_server.step);
// SSH echo client
const ssh_client_module = b.createModule(.{
.root_source_file = b.path("examples/ssh_echo_client.zig"),
.target = target,
.optimize = optimize,
});
ssh_client_module.addImport("libfast", libfast_module);
const ssh_client = b.addExecutable(.{
.name = "ssh_echo_client",
.root_module = ssh_client_module,
});
b.installArtifact(ssh_client);
const run_ssh_client = b.addRunArtifact(ssh_client);
const ssh_client_step = b.step("run-ssh-client", "Run SSH/QUIC echo client example");
ssh_client_step.dependOn(&run_ssh_client.step);
// TLS echo server
const tls_server_module = b.createModule(.{
.root_source_file = b.path("examples/tls_echo_server.zig"),
.target = target,
.optimize = optimize,
});
tls_server_module.addImport("libfast", libfast_module);
const tls_server = b.addExecutable(.{
.name = "tls_echo_server",
.root_module = tls_server_module,
});
b.installArtifact(tls_server);
const run_tls_server = b.addRunArtifact(tls_server);
const tls_server_step = b.step("run-tls-server", "Run TLS/QUIC echo server example");
tls_server_step.dependOn(&run_tls_server.step);
// TLS echo client
const tls_client_module = b.createModule(.{
.root_source_file = b.path("examples/tls_echo_client.zig"),
.target = target,
.optimize = optimize,
});
tls_client_module.addImport("libfast", libfast_module);
const tls_client = b.addExecutable(.{
.name = "tls_echo_client",
.root_module = tls_client_module,
});
b.installArtifact(tls_client);
const run_tls_client = b.addRunArtifact(tls_client);
const tls_client_step = b.step("run-tls-client", "Run TLS/QUIC echo client example");
tls_client_step.dependOn(&run_tls_client.step);
}