-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
142 lines (125 loc) · 3.75 KB
/
Copy pathbuild.zig
File metadata and controls
142 lines (125 loc) · 3.75 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
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 skip_tests = b.option(
bool,
"skip-tests",
"Skip testing and just build",
) orelse false;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const dep_opts = .{
.target = target,
.optimize = optimize,
};
_ = dep_opts;
const archive_c = b.addTranslateC(.{
.root_source_file = b.path("lib/archive.h"),
.target = target,
.optimize = optimize,
});
archive_c.linkSystemLibrary("archive", .{});
const git2_c = b.addTranslateC(.{
.root_source_file = b.path("lib/git.h"),
.target = target,
.optimize = optimize,
});
git2_c.linkSystemLibrary("git2", .{});
const module = b.addModule("libnest", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{
.{
.name = "archive_c",
.module = archive_c.createModule(),
},
.{
.name = "git2_c",
.module = git2_c.createModule(),
},
},
});
const curl = b.dependency("curl", .{
.target = target,
.optimize = optimize,
.link_vendor = false,
});
module.addImport("curl", curl.module("curl"));
const zqlite = b.dependency("zqlite", .{
.target = target,
.optimize = optimize,
});
module.linkSystemLibrary("sqlite3", .{});
module.addImport("zqlite", zqlite.module("zqlite"));
const ini = b.dependency("ini", .{
.target = target,
.optimize = optimize,
});
module.addImport("ini", ini.module("ini"));
if (!skip_tests) {
const tests = b.addTest(.{
.root_module = b.addModule("tests", .{
.root_source_file = b.path("src/tests.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{
.{
.name = "archive_c",
.module = archive_c.createModule(),
},
.{
.name = "git2_c",
.module = git2_c.createModule(),
},
},
}),
.use_llvm = true,
.filters = test_filters,
});
tests.root_module.linkSystemLibrary("curl", .{});
tests.root_module.addImport("curl", curl.module("curl"));
tests.root_module.addImport("zqlite", zqlite.module("zqlite"));
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);
}
}