-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.zig
35 lines (31 loc) · 1.18 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
const std = @import("std");
pub fn build(b: *std.Build) !void {
const bundle = b.option(bool, "bundle", "Bundle SQLite") orelse false;
const lib = b.addModule("fridge", .{
.root_source_file = b.path("src/main.zig"),
});
lib.link_libc = true;
if (bundle) {
const src = b.dependency("sqlite_source", .{});
lib.addIncludePath(src.path("."));
lib.addCSourceFile(.{ .file = src.path("sqlite3.c"), .flags = &.{"-std=c99"} });
} else {
// lib.linkSystemLibrary("sqlite3", .{});
try lib.link_objects.append(b.allocator, .{
.system_lib = .{
.name = b.dupe("sqlite3"),
.needed = false,
.weak = false,
.use_pkg_config = .yes,
.preferred_link_mode = .dynamic,
.search_strategy = .paths_first,
},
});
}
const tests = b.addTest(.{ .root_source_file = b.path("src/main.zig") });
tests.root_module.link_libc = true;
tests.root_module.link_objects = lib.link_objects;
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&run_tests.step);
}