-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.zig
76 lines (62 loc) · 2.11 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const lib = b.addStaticLibrary(.{
.name = "fzwatch",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
if (target.result.os.tag == .macos) {
lib.linkFramework("CoreServices");
}
lib.linkLibC();
const module = b.addModule("fzwatch", .{
.root_source_file = b.path("src/main.zig"),
});
module.linkLibrary(lib);
// Basic example
const basic = b.addExecutable(.{
.name = "fzwatch-example",
.root_source_file = b.path("examples/basic.zig"),
.target = target,
.optimize = optimize,
});
basic.root_module.addImport("fzwatch", module);
const run_cmd = b.addRunArtifact(basic);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run-basic", "Run the example");
run_step.dependOn(&run_cmd.step);
// Context example
const context = b.addExecutable(.{
.name = "fzwatch-context",
.root_source_file = b.path("examples/context.zig"),
.target = target,
.optimize = optimize,
});
context.root_module.addImport("fzwatch", module);
const run_cmd_context = b.addRunArtifact(context);
run_cmd_context.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd_context.addArgs(args);
}
const run_step_context = b.step("run-context", "Run the example");
run_step_context.dependOn(&run_cmd_context.step);
const test_step = b.addTest(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
if (target.result.os.tag == .macos) {
test_step.linkFramework("CoreServices");
}
test_step.linkLibC();
const test_run = b.addRunArtifact(test_step);
const test_step_cmd = b.step("test", "Run library tests");
test_step_cmd.dependOn(&test_run.step);
b.installArtifact(lib);
}