-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
83 lines (70 loc) · 2.33 KB
/
build.zig
File metadata and controls
83 lines (70 loc) · 2.33 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
const std = @import("std");
const manifest = @import("build.zig.zon");
pub fn build(b: *std.Build) !void {
const install_step = b.getInstallStep();
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const root_source_file = b.path("src/root.zig");
const version: std.SemanticVersion = try .parse(manifest.version);
// Public root module
const root_mod = b.addModule("quickphf", .{
.target = target,
.optimize = optimize,
.root_source_file = root_source_file,
.strip = b.option(bool, "strip", "Strip binary"),
});
// Library
const lib = b.addLibrary(.{
.name = "quickphf",
.version = version,
.root_module = root_mod,
});
b.installArtifact(lib);
// Documentation
const docs_step = b.step("doc", "Emit documentation");
const docs_install = b.addInstallDirectory(.{
.install_dir = .prefix,
.install_subdir = "docs",
.source_dir = lib.getEmittedDocs(),
});
docs_step.dependOn(&docs_install.step);
// Example
const example_step = b.step("run", "Run example");
const example_exe = b.addExecutable(.{
.name = "example",
.version = version,
.root_module = b.createModule(.{
.target = target,
.optimize = optimize,
.root_source_file = b.path(EXAMPLE_DIR ++ "main.zig"),
.imports = &.{
.{ .name = "quickphf", .module = root_mod },
},
}),
});
const example_exe_run = b.addRunArtifact(example_exe);
example_step.dependOn(&example_exe_run.step);
// Formatting check
const fmt_step = b.step("fmt", "Check formatting");
const fmt = b.addFmt(.{
.paths = &.{
"src/",
"build.zig",
"build.zig.zon",
EXAMPLE_DIR,
},
.check = true,
});
fmt_step.dependOn(&fmt.step);
install_step.dependOn(fmt_step);
// Compilation check for ZLS Build-On-Save
// See: https://zigtools.org/zls/guides/build-on-save/
const check_step = b.step("check", "Check compilation");
const check_exe = b.addExecutable(.{
.name = "quickphf",
.version = version,
.root_module = root_mod,
});
check_step.dependOn(&check_exe.step);
}
const EXAMPLE_DIR = "example/";