-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.zig
More file actions
67 lines (54 loc) · 1.83 KB
/
build.zig
File metadata and controls
67 lines (54 loc) · 1.83 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
const std = @import("std");
pub const Framework = enum {
httpz,
tokamak,
all,
};
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const dep_opts = .{ .target = target, .optimize = optimize };
const framework = b.option(
Framework,
"framework",
"Decide which framework to use",
) orelse .all;
const options = b.addOptions();
options.addOption(bool, "http1", true);
options.addOption(Framework, "framework", framework);
const httpz = b.dependency("httpz", dep_opts).module("httpz");
const tokamak = b.dependency("tokamak", dep_opts).module("tokamak");
const imports: []const std.Build.Module.Import = switch (framework) {
.httpz => &.{.{ .name = "httpz", .module = httpz }},
.tokamak => &.{.{ .name = "tokamak", .module = tokamak }},
.all => &.{
.{ .name = "httpz", .module = httpz },
.{ .name = "tokamak", .module = tokamak },
},
};
const datastar = b.addModule(
"datastar",
.{
.root_source_file = b.path("src/root.zig"),
.imports = imports,
},
);
datastar.addOptions("config", options);
const tests = b.addTest(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.test_runner = .{
.path = b.path("test_runner.zig"),
.mode = .simple,
},
});
tests.root_module.addOptions("config", options);
for (imports) |import| {
tests.root_module.addImport(import.name, import.module);
}
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);
}