-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
96 lines (83 loc) · 2.45 KB
/
build.zig
File metadata and controls
96 lines (83 loc) · 2.45 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
84
85
86
87
88
89
90
91
92
93
94
95
96
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.Build) void {
const emit_static = b.option(
bool,
"emit-static",
"Emit a static library",
) orelse false;
const emit_dynamic = b.option(
bool,
"emit-dynamic",
"Emit a dynamic library",
) orelse false;
const test_filters = b.option(
[][]const u8,
"test",
"Test to run",
) orelse &.{};
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const dep_opts = .{
.target = target,
.optimize = optimize,
};
_ = dep_opts;
const module = b.addModule("libnest", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
module.linkSystemLibrary("archive", .{});
module.linkSystemLibrary("git2", .{});
const curl = b.dependency("curl", .{
.target = target,
.optimize = optimize,
});
module.addImport("curl", curl.module("curl"));
const sqlite = b.dependency("sqlite", .{
.target = target,
.optimize = optimize,
});
module.addImport("sqlite", sqlite.module("sqlite"));
const tests = b.addTest(.{
.root_module = b.addModule("tests", .{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
}),
.use_llvm = true,
.filters = test_filters,
});
tests.linkSystemLibrary("curl");
tests.linkSystemLibrary("archive");
tests.linkSystemLibrary("git2");
tests.linkLibC();
tests.root_module.addImport("curl", curl.module("curl"));
tests.root_module.addImport("sqlite", sqlite.module("sqlite"));
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run libnest tests");
test_step.dependOn(&run_tests.step);
if (emit_dynamic) {
const lib = b.addLibrary(.{
.name = "nest",
.root_module = module,
.linkage = .dynamic,
.version = .{
.major = 0,
.minor = 1,
.patch = 0,
},
});
b.installArtifact(lib);
}
if (emit_static) {
const lib = b.addLibrary(.{
.name = "nest",
.root_module = module,
.linkage = .static,
});
b.installArtifact(lib);
}
}