-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
58 lines (47 loc) · 2.01 KB
/
build.zig
File metadata and controls
58 lines (47 loc) · 2.01 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
58
const std = @import("std");
const manifest = @import("build.zig.zon");
fn linkLibs(b: *std.Build, compile: *std.Build.Step.Compile) void {
compile.linkLibC();
compile.linkSystemLibrary("tree-sitter");
compile.linkSystemLibrary("pcre2-8");
const lsp_kit = b.dependency("lsp_kit", .{});
compile.root_module.addImport("lsp", lsp_kit.module("lsp"));
const zon = b.createModule(.{ .root_source_file = b.path("build.zig.zon") });
compile.root_module.addImport("zon", zon);
}
pub fn build(b: *std.Build) !void {
b.reference_trace = 10;
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const exe = b.addExecutable(.{ .name = "hat", .root_module = root_module });
linkLibs(b, exe);
b.installArtifact(exe);
const run = b.addRunArtifact(exe);
run.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run.addArgs(args);
}
const run_step = b.step("run", "");
run_step.dependOn(&run.step);
const test_runner: std.Build.Step.Compile.TestRunner = .{ .path = b.path("src/test_runner.zig"), .mode = .simple };
const tests = b.addTest(.{ .root_module = root_module, .test_runner = test_runner });
linkLibs(b, tests);
const run_tests = b.addRunArtifact(tests);
const test_step = b.step("test", "");
test_step.dependOn(&run_tests.step);
const check_step = b.step("check", "");
check_step.dependOn(&exe.step);
check_step.dependOn(&tests.step);
const cov_tests = b.addTest(.{ .root_module = root_module, .test_runner = test_runner });
linkLibs(b, cov_tests);
cov_tests.use_llvm = true;
cov_tests.setExecCmd(&.{ "kcov", "--include-path=src/", b.pathJoin(&.{ b.install_path, "kcov" }), null });
const run_cov = b.addRunArtifact(cov_tests);
const cov_step = b.step("coverage", "");
cov_step.dependOn(&run_cov.step);
}