-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
55 lines (46 loc) · 1.78 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
const std = @import("std");
const package_name = "zig-router";
const package_path = "src/router.zig";
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const getty = b.dependency("getty", .{ .target = target, .optimize = optimize });
const mod = b.addModule(package_name, .{
.root_source_file = b.path(package_path),
.imports = &.{
.{ .name = "getty", .module = getty.module("getty") },
},
});
const exe_test = b.addTest(.{
.root_source_file = b.path(package_path),
.target = target,
.optimize = optimize,
});
exe_test.root_module.addImport("getty", getty.module("getty"));
const run_test_exe = b.addRunArtifact(exe_test);
const run_test = b.step("test", "Run unit tests");
run_test.dependOn(&run_test_exe.step);
const exe_example = b.addExecutable(.{
.name = "example",
.root_source_file = b.path("example/main.zig"),
.target = target,
.optimize = optimize,
});
exe_example.root_module.addImport("zig-router", mod);
const run_example_exe = b.addRunArtifact(exe_example);
const run_example = b.step("example", "Run example");
run_example.dependOn(&run_example_exe.step);
const docs_step = b.step("docs", "Build the project documentation");
const doc_obj = b.addObject(.{
.name = "docs",
.root_source_file = b.path(package_path),
.target = target,
.optimize = optimize,
});
const install_docs = b.addInstallDirectory(.{
.source_dir = doc_obj.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = std.fmt.comptimePrint("docs/{s}", .{package_name}),
});
docs_step.dependOn(&install_docs.step);
}