-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
47 lines (38 loc) · 1.4 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
const pkgs = @import("deps.zig").pkgs;
const std = @import("std");
pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const lib = b.addStaticLibrary("nats", "src/main.zig");
lib.setBuildMode(mode);
lib.install();
pkgs.addAllTo(lib);
var main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode);
pkgs.addAllTo(main_tests);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
const example = b.addExecutable("example", "example/main.zig");
example.setBuildMode(mode);
example.setTarget(target);
pkgs.addAllTo(example);
example.addPackage(.{
.name = b.dupe("nats"),
.path = .{ .path = b.dupe("src/main.zig") },
.dependencies = &[_]std.build.Pkg{
pkgs.nkeys,
pkgs.uri,
pkgs.iguanaTLS,
},
});
const example_install = b.addInstallArtifact(example);
const example_step = b.step("example", "Build example");
example_step.dependOn(&example_install.step);
const example_run_cmd = example.run();
example_run_cmd.step.dependOn(&example_install.step);
if (b.args) |args| {
example_run_cmd.addArgs(args);
}
const example_run_step = b.step("run-example", "Run example");
example_run_step.dependOn(&example_run_cmd.step);
}