]> gitweb.ps.run Git - chirp/blob - build.zig
dunno
[chirp] / build.zig
1 const std = @import("std");
2
3 pub fn build(b: *std.Build) void {
4     const target = b.standardTargetOptions(.{});
5
6     const optimize = b.standardOptimizeOption(.{});
7
8     const exe = b.addExecutable(.{
9         .name = "lmdb",
10         // In this case the main source file is merely a path, however, in more
11         // complicated build scripts, this could be a generated file.
12         .root_source_file = .{ .cwd_relative = "src/main.zig" },
13         .target = target,
14         .optimize = optimize,
15     });
16
17     const epoll = b.addExecutable(.{
18         .name = "epoll",
19         // In this case the main source file is merely a path, however, in more
20         // complicated build scripts, this could be a generated file.
21         .root_source_file = .{ .cwd_relative = "src/epoll.zig" },
22         .target = target,
23         .optimize = optimize,
24     });
25
26     const lmdb_mod = b.createModule(.{
27         .root_source_file = .{ .cwd_relative = "../ziglmdb/src/lmdb.zig" },
28     });
29     lmdb_mod.addIncludePath(.{ .cwd_relative = "./lmdb/libraries/liblmdb" });
30     lmdb_mod.addCSourceFiles(.{ .files = &.{
31         "./lmdb/libraries/liblmdb/midl.c",
32         "./lmdb/libraries/liblmdb/mdb.c",
33     } });
34
35     exe.root_module.addImport("lmdb", lmdb_mod);
36     exe.linkLibC();
37
38     epoll.root_module.addImport("lmdb", lmdb_mod);
39     epoll.linkLibC();
40
41     b.installArtifact(exe);
42
43     const run_cmd = b.addRunArtifact(exe);
44
45     run_cmd.step.dependOn(b.getInstallStep());
46
47     if (b.args) |args| {
48         run_cmd.addArgs(args);
49     }
50
51     const run_step = b.step("run", "Run the app");
52     run_step.dependOn(&run_cmd.step);
53
54     const run_epoll_cmd = b.addRunArtifact(epoll);
55     const run_epoll_step = b.step("runepoll", "run epoll");
56     run_epoll_step.dependOn(&run_epoll_cmd.step);
57 }