-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
148 lines (130 loc) · 5.03 KB
/
build.zig
File metadata and controls
148 lines (130 loc) · 5.03 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const libself_dep = b.dependency("libself", .{
.target = target,
.optimize = optimize,
});
const libmesh_dep = b.dependency("libmesh", .{
.target = target,
.optimize = optimize,
});
const libdice_dep = b.dependency("libdice", .{
.target = target,
.optimize = optimize,
});
const libfast_dep = b.dependency("libfast", .{
.target = target,
.optimize = optimize,
});
const libvine_module = b.createModule(.{
.root_source_file = b.path("lib/libvine.zig"),
.target = target,
.optimize = optimize,
});
libvine_module.addImport("libself", libself_dep.module("libself"));
libvine_module.addImport("libmesh", libmesh_dep.module("libmesh"));
libvine_module.addImport("libdice", libdice_dep.module("libdice"));
libvine_module.addImport("libfast", libfast_dep.module("libfast"));
const libvine_export = b.addModule("libvine", .{
.root_source_file = b.path("lib/libvine.zig"),
.target = target,
.optimize = optimize,
});
libvine_export.addImport("libself", libself_dep.module("libself"));
libvine_export.addImport("libmesh", libmesh_dep.module("libmesh"));
libvine_export.addImport("libdice", libdice_dep.module("libdice"));
libvine_export.addImport("libfast", libfast_dep.module("libfast"));
const lib = b.addLibrary(.{
.name = "vine",
.root_module = libvine_module,
.linkage = .static,
});
b.installArtifact(lib);
const vine_cli = b.addExecutable(.{
.name = "vine",
.root_module = b.createModule(.{
.root_source_file = b.path("bin/vine.zig"),
.target = target,
.optimize = optimize,
}),
});
vine_cli.root_module.addImport("libvine", libvine_export);
b.installArtifact(vine_cli);
const vine_step = b.step("vine", "Build the vine binary");
vine_step.dependOn(&vine_cli.step);
const lib_unit_tests = b.addTest(.{
.root_module = libvine_module,
});
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const vine_cli_test_module = b.createModule(.{
.root_source_file = b.path("bin/vine.zig"),
.target = target,
.optimize = optimize,
});
const vine_cli_tests = b.addTest(.{
.root_module = vine_cli_test_module,
});
const run_vine_cli_tests = b.addRunArtifact(vine_cli_tests);
const smoke_test_module = b.createModule(.{
.root_source_file = b.path("test/smoke.zig"),
.target = target,
.optimize = optimize,
});
smoke_test_module.addImport("libvine", libvine_export);
const smoke_tests = b.addTest(.{
.root_module = smoke_test_module,
});
const run_smoke_tests = b.addRunArtifact(smoke_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
test_step.dependOn(&run_vine_cli_tests.step);
test_step.dependOn(&run_smoke_tests.step);
test_step.dependOn(&vine_cli.step);
const examples_step = b.step("examples", "Build libvine examples");
const static_network_demo = b.addExecutable(.{
.name = "static_network_demo",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/static_network_demo.zig"),
.target = target,
.optimize = optimize,
}),
});
static_network_demo.root_module.addImport("libvine", libvine_export);
b.installArtifact(static_network_demo);
examples_step.dependOn(&static_network_demo.step);
const two_peer_ping = b.addExecutable(.{
.name = "two_peer_ping",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/two_peer_ping.zig"),
.target = target,
.optimize = optimize,
}),
});
two_peer_ping.root_module.addImport("libvine", libvine_export);
b.installArtifact(two_peer_ping);
examples_step.dependOn(&two_peer_ping.step);
const relay_fallback_ping = b.addExecutable(.{
.name = "relay_fallback_ping",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/relay_fallback_ping.zig"),
.target = target,
.optimize = optimize,
}),
});
relay_fallback_ping.root_module.addImport("libvine", libvine_export);
b.installArtifact(relay_fallback_ping);
examples_step.dependOn(&relay_fallback_ping.step);
const multi_node_relay_demo = b.addExecutable(.{
.name = "multi_node_relay_demo",
.root_module = b.createModule(.{
.root_source_file = b.path("examples/multi_node_relay_demo.zig"),
.target = target,
.optimize = optimize,
}),
});
multi_node_relay_demo.root_module.addImport("libvine", libvine_export);
b.installArtifact(multi_node_relay_demo);
examples_step.dependOn(&multi_node_relay_demo.step);
}