-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.zig
More file actions
78 lines (66 loc) · 2.69 KB
/
build.zig
File metadata and controls
78 lines (66 loc) · 2.69 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const dep_opts = .{
.target = target,
.optimize = optimize,
};
const datastar_httpz_module = b.addModule("datastar", .{
.root_source_file = b.path("src/datastar.zig"),
.target = target,
});
const httpz_module = b.dependency("httpz", dep_opts);
const tokamak_module = b.dependency("tokamak", dep_opts);
const logz_module = b.dependency("logz", dep_opts);
// datastar_httpz_module.addImport("httpz", httpz_module.module("httpz"));
const tests = b.addTest(.{
.root_module = b.createModule(.{
.root_source_file = b.path("src/datastar.zig"),
.target = target,
.optimize = optimize,
}),
.test_runner = .{ .path = b.path("test_runner.zig"), .mode = .simple },
});
const run_test = b.addRunArtifact(tests);
run_test.has_side_effects = true;
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_test.step);
const httpz_examples = [_]struct {
file: []const u8,
name: []const u8,
libc: bool = false,
}{
.{ .file = "tests/validation.zig", .name = "validation-test" },
.{ .file = "examples/01_basic.zig", .name = "example_1" },
.{ .file = "examples/02_petshop.zig", .name = "example_2" },
.{ .file = "examples/022_petshop.zig", .name = "example_22" },
.{ .file = "examples/05_garden.zig", .name = "example_5" },
.{ .file = "examples/tokamak_basic.zig", .name = "tokamak_basic" },
};
{
for (httpz_examples) |ex| {
const exe = b.addExecutable(.{
.name = ex.name,
.root_module = b.createModule(.{
.root_source_file = b.path(ex.file),
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("datastar", datastar_httpz_module);
// add some 3rd party deps to get the app working
exe.root_module.addImport("httpz", httpz_module.module("httpz"));
exe.root_module.addImport("tokamak", tokamak_module.module("tokamak"));
exe.root_module.addImport("logz", logz_module.module("logz"));
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(ex.name, ex.file);
run_step.dependOn(&run_cmd.step);
}
}
}