-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.zig
75 lines (60 loc) · 2.36 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
const std = @import("std");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
// runner.
pub fn build(b: *std.Build) void {
// these are boiler plate code until you know what you are doing
// and you need to add additional options
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{ .preferred_optimize_mode = .ReleaseFast });
const websocket = b.dependency("websocket", .{
.target = target,
.optimize = optimize,
});
const zlib = b.dependency("zlib", .{});
const deque = b.dependency("zig-deque", .{
.target = target,
.optimize = optimize,
});
const dzig = b.addModule("discord.zig", .{
.root_source_file = b.path("src/discord.zig"),
.link_libc = true,
});
dzig.addImport("ws", websocket.module("websocket"));
dzig.addImport("zlib", zlib.module("zlib"));
dzig.addImport("deque", deque.module("zig-deque"));
const marin = b.addExecutable(.{
.name = "marin",
.root_source_file = b.path("test/test.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
marin.root_module.addImport("discord", dzig);
marin.root_module.addImport("ws", websocket.module("websocket"));
marin.root_module.addImport("zlib", zlib.module("zlib"));
marin.root_module.addImport("deque", deque.module("zig-deque"));
//b.installArtifact(marin);
// test
const run_cmd = b.addRunArtifact(marin);
run_cmd.step.dependOn(b.getInstallStep());
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
const lib = b.addStaticLibrary(.{
.name = "discord.zig",
.root_source_file = b.path("src/discord.zig"),
.target = target,
.optimize = optimize,
});
lib.root_module.addImport("ws", websocket.module("websocket"));
lib.root_module.addImport("zlib", zlib.module("zlib"));
lib.root_module.addImport("deque", deque.module("zig-deque"));
// docs
const docs_step = b.step("docs", "Generate documentation");
const docs_install = b.addInstallDirectory(.{
.source_dir = lib.getEmittedDocs(),
.install_dir = .prefix,
.install_subdir = "docs",
});
docs_step.dependOn(&docs_install.step);
}