-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
126 lines (110 loc) · 3.46 KB
/
Copy pathbuild.zig
File metadata and controls
126 lines (110 loc) · 3.46 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
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.Build) void {
const emit_library = b.option(
bool,
"emit-lib",
"Whether to build dynamic and static library files",
) 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 config_path = b.option(
[]const u8,
"config",
"Path to the libnest .zon config file",
) orelse "libnest.zon";
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const config_cwd: std.Build.LazyPath = .{ .cwd_relative = config_path };
const config_mod = b.createModule(.{ .root_source_file = config_cwd });
const archive_c = b.addTranslateC(.{
.root_source_file = b.path("lib/archive.h"),
.target = target,
.optimize = optimize,
});
archive_c.linkSystemLibrary("archive", .{});
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 = "config",
.module = config_mod,
},
},
});
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(),
},
},
}),
.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_library) {
var lib = b.addLibrary(.{
.name = "nest",
.root_module = module,
.linkage = .static,
});
b.installArtifact(lib);
lib = b.addLibrary(.{
.name = "nest",
.root_module = module,
.linkage = .dynamic,
.version = .{
.major = 0,
.minor = 1,
.patch = 0,
},
});
b.installArtifact(lib);
}
}