this repo has no description
1const std = @import("std");
2
3pub fn build(b: *std.Build) void {
4 const target = b.standardTargetOptions(.{});
5 const optimize = b.standardOptimizeOption(.{});
6
7 const use_llvm = switch (optimize) {
8 .Debug => false,
9 else => true,
10 };
11
12 const exe_mod = b.createModule(.{
13 .root_source_file = b.path("src/main.zig"),
14 .target = target,
15 .optimize = optimize,
16 });
17
18 const libxev = b.dependency("libxev", .{
19 .target = target,
20 .optimize = optimize,
21 });
22 const xev_mod = libxev.module("xev");
23 exe_mod.addImport("xev", xev_mod);
24
25 const zeit = b.dependency("zeit", .{
26 .target = target,
27 .optimize = optimize,
28 });
29 const zeit_mod = zeit.module("zeit");
30 exe_mod.addImport("zeit", zeit_mod);
31
32 // We use zqlite for the actual interface with sqlite
33 const zqlite = b.dependency("zqlite", .{
34 .target = target,
35 .optimize = optimize,
36 });
37 const zqlite_mod = zqlite.module("zqlite");
38 exe_mod.addImport("sqlite", zqlite_mod);
39 exe_mod.link_libc = true;
40 exe_mod.linkSystemLibrary("sqlite3", .{});
41
42 const uuid = b.dependency("uuid", .{
43 .target = target,
44 .optimize = optimize,
45 });
46 const uuid_mod = uuid.module("uuid");
47 exe_mod.addImport("uuid", uuid_mod);
48
49 const httpz = b.dependency("httpz", .{
50 .target = target,
51 .optimize = optimize,
52 });
53 exe_mod.addImport("httpz", httpz.module("httpz"));
54
55 const exe = b.addExecutable(.{
56 .name = "apollo",
57 .root_module = exe_mod,
58 .use_llvm = use_llvm,
59 });
60
61 b.installArtifact(exe);
62
63 const run_cmd = b.addRunArtifact(exe);
64
65 run_cmd.step.dependOn(b.getInstallStep());
66
67 if (b.args) |args| {
68 run_cmd.addArgs(args);
69 }
70
71 const run_step = b.step("run", "Run the app");
72 run_step.dependOn(&run_cmd.step);
73
74 const exe_unit_tests = b.addTest(.{
75 .root_module = exe_mod,
76 .use_llvm = use_llvm,
77 });
78 exe_unit_tests.root_module.addImport("zeit", zeit_mod);
79
80 const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests);
81
82 // Similar to creating the run step earlier, this exposes a `test` step to
83 // the `zig build --help` menu, providing a way for the user to request
84 // running the unit tests.
85 const test_step = b.step("test", "Run unit tests");
86 test_step.dependOn(&run_exe_unit_tests.step);
87
88 {
89 // Add a check step for zls
90 const check_exe = b.addExecutable(.{
91 .name = "apollo",
92 .root_module = exe_mod,
93 });
94
95 const check_step = b.step("check", "Check if apollo compiles");
96 check_step.dependOn(&check_exe.step);
97 }
98}