-
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathbuild.zig
59 lines (48 loc) · 1.76 KB
/
build.zig
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
const std = @import("std");
const Builder = std.build.Builder;
pub fn build(b: *Builder) void {
const mode = b.standardReleaseOptions();
// builds the library as a static library
{
const lib = b.addStaticLibrary("apple_pie", "src/server.zig");
lib.setBuildMode(mode);
lib.use_stage1 = true;
lib.install();
}
// builds and runs the tests
{
var main_tests = b.addTest("src/apple_pie.zig");
main_tests.setBuildMode(mode);
main_tests.use_stage1 = true;
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
}
// example
{
var opt = b.option([]const u8, "example", "The example to build & run") orelse "basic";
const example_file = blk: {
if (std.mem.eql(u8, opt, "router"))
break :blk "examples/router.zig";
if (std.mem.eql(u8, opt, "static"))
break :blk "examples/static.zig";
if (std.mem.eql(u8, opt, "template"))
break :blk "examples/template.zig";
if (std.mem.eql(u8, opt, "form"))
break :blk "examples/form.zig";
break :blk "examples/basic.zig";
};
// Allows for running the example
var example = b.addExecutable(opt, example_file);
example.addPackage(.{
.name = "apple_pie",
.source = .{ .path = "src/apple_pie.zig" },
});
example.setBuildMode(mode);
example.use_stage1 = true;
example.install();
const run_example = example.run();
run_example.step.dependOn(b.getInstallStep());
const example_step = b.step("example", "Run example");
example_step.dependOn(&run_example.step);
}
}