]> gitweb.ps.run Git - chirp/blob - build.zig
7a13429b26b04e000cb321bdca628429b744ac39
[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 lmdb_mod = b.createModule(.{
18         .root_source_file = .{ .cwd_relative = "../ziglmdb/src/lmdb.zig" },
19     });
20     lmdb_mod.addIncludePath(.{ .cwd_relative = "./lmdb/libraries/liblmdb" });
21     lmdb_mod.addCSourceFiles(.{ .files = &.{
22         "./lmdb/libraries/liblmdb/midl.c",
23         "./lmdb/libraries/liblmdb/mdb.c",
24     } });
25     exe.root_module.addImport("lmdb", lmdb_mod);
26
27     exe.linkLibC();
28
29     b.installArtifact(exe);
30
31     const run_cmd = b.addRunArtifact(exe);
32
33     run_cmd.step.dependOn(b.getInstallStep());
34
35     if (b.args) |args| {
36         run_cmd.addArgs(args);
37     }
38
39     const run_step = b.step("run", "Run the app");
40     run_step.dependOn(&run_cmd.step);
41 }