-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathbuild.zig
More file actions
116 lines (100 loc) · 2.96 KB
/
Copy pathbuild.zig
File metadata and controls
116 lines (100 loc) · 2.96 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
pub fn build(b: *Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const tardy = b.dependency("tardy", .{
.target = target,
.optimize = optimize,
}).module("tardy");
const secsock = b.dependency("secsock", .{
.target = target,
.optimize = optimize,
}).module("secsock");
const zzz = b.addModule("zzz", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "tardy", .module = tardy },
.{ .name = "secsock", .module = secsock },
},
});
const all = b.step("all", "Build all Zzz examples");
for ([_][]const u8{
"basic",
"cookies",
"form",
"fs",
"middleware",
"sse",
"tls",
}) |name| add_example(b, .{
.name = name,
.target = target,
.optimize = optimize,
.zzz_module = zzz,
.all = all,
});
if (target.result.os.tag != .windows) add_example(b, .{
.name = "unix",
.target = target,
.optimize = optimize,
.zzz_module = zzz,
.all = all,
});
const tests = b.addTest(.{
.name = "tests",
.root_module = b.addModule("tests", .{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
}),
});
const run_test = b.addRunArtifact(tests);
run_test.step.dependOn(&tests.step);
const test_step = b.step("test", "Run general unit tests");
test_step.dependOn(&run_test.step);
}
fn add_example(
b: *Build,
options: struct {
name: []const u8,
target: Build.ResolvedTarget,
optimize: std.lang.Optimize,
zzz_module: *Build.Module,
all: *Build.Step,
},
) void {
const mod = b.createModule(.{
.root_source_file = b.path(
b.fmt("examples/{s}/main.zig", .{options.name}),
),
.optimize = options.optimize,
.target = options.target,
.strip = false,
});
mod.addImport("zzz", options.zzz_module);
const example = b.addExecutable(.{
.name = options.name,
.root_module = mod,
});
const install_artifact = b.addInstallArtifact(
example,
.{},
);
options.all.dependOn(&install_artifact.step);
const build_step = b.step(
b.fmt("{s}", .{options.name}),
b.fmt("Build zzz example ({s})", .{options.name}),
);
build_step.dependOn(&install_artifact.step);
const run_artifact = b.addRunArtifact(example);
run_artifact.step.dependOn(&install_artifact.step);
const run_step = b.step(
b.fmt("run_{s}", .{options.name}),
b.fmt("Run zzz example ({s})", .{options.name}),
);
run_step.dependOn(&install_artifact.step);
run_step.dependOn(&run_artifact.step);
}
const std = @import("std");
const Build = std.Build;