-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
82 lines (71 loc) · 2.36 KB
/
build.zig
File metadata and controls
82 lines (71 loc) · 2.36 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Module
const mod = b.addModule("uuidz", .{
.root_source_file = b.path("src/uuidz.zig"),
.target = target,
.optimize = optimize,
});
// Library
const lib = b.addLibrary(.{
.linkage = .static,
.name = "uuidz",
.root_module = mod,
});
// Example
const example = b.addExecutable(.{
.name = "example",
.root_module = b.createModule(.{
.root_source_file = b.path("example.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "uuidz", .module = mod },
},
}),
// https://github.com/ziglang/zig/issues/24181
.use_llvm = true,
});
const run_example = b.addRunArtifact(example);
const example_step = b.step("example", "Run usage example");
example_step.dependOn(&run_example.step);
// Benchmark
const benchmark = b.addExecutable(.{
.name = "benchmark",
.root_module = b.createModule(.{
.root_source_file = b.path("benchmark.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "uuidz", .module = mod },
},
}),
// https://github.com/ziglang/zig/issues/24181
.use_llvm = true,
});
if (b.lazyDependency("uuid_zig", .{})) |uuid_zig| {
benchmark.root_module.addImport("uuid_zig", uuid_zig.module("uuid"));
}
const run_benchmark = b.addRunArtifact(benchmark);
const bench_step = b.step("bench", "Run ClockSequence performance benchmark");
bench_step.dependOn(&run_benchmark.step);
// Test
const tests = b.addTest(.{
.root_module = mod,
// https://github.com/ziglang/zig/issues/24181
.use_llvm = true,
});
b.installArtifact(tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&tests.step);
// Docs
const docs = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
const docs_step = b.step("docs", "Install docs into zig-out/docs");
docs_step.dependOn(&docs.step);
}