-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathbuild.zig
More file actions
57 lines (48 loc) · 1.76 KB
/
build.zig
File metadata and controls
57 lines (48 loc) · 1.76 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
const std = @import("std");
const Builder = std.build.Builder;
const EXAMPLES = .{
"simple-exec",
"simple",
"blog",
};
pub fn build(b: *Builder) void {
const target = b.standardTargetOptions(.{
// To deal with the error message:
//
// LLD Link... ld.lld: error: undefined symbol: fcntl64
//
// We are using musl by default; though specifying a version of glibc would also work.
//
// See https://github.com/ziglang/zig/issues/9485#issue-956197415
.default_target = .{
.abi = .musl,
},
});
const mode = b.standardReleaseOptions();
const lib = b.addStaticLibrary("sqlite3", null);
lib.setTarget(target);
lib.setBuildMode(mode);
lib.linkLibC();
lib.addCSourceFile("src/sqlite3.c", &.{});
lib.install();
const tests = b.addTest("src/sqlite3.zig");
tests.setBuildMode(mode);
tests.setTarget(target);
tests.addCSourceFile("src/sqlite3.c", &.{});
tests.linkLibC();
const test_step = b.step("test", "Run all tests");
test_step.dependOn(&tests.step);
const all_example_step = b.step("examples", "Build examples");
inline for (EXAMPLES) |example_name| {
const example = b.addExecutable(example_name, "examples" ++ std.fs.path.sep_str ++ example_name ++ ".zig");
example.addPackagePath("sqlite", "src/sqlite3.zig");
example.setBuildMode(mode);
example.setTarget(target);
example.addCSourceFile("src/sqlite3.c", &.{});
example.linkLibC();
var run = example.run();
if (b.args) |args| run.addArgs(args);
b.step("run-example-" ++ example_name, "Run the " ++ example_name ++ " example").dependOn(&run.step);
all_example_step.dependOn(&example.step);
}
}