-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
93 lines (80 loc) · 3.25 KB
/
Copy pathbuild.zig
File metadata and controls
93 lines (80 loc) · 3.25 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const zero = b.dependency("zero", .{});
const bearssl = b.dependency("zig_bearssl", .{});
const mod = b.addModule("eva", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
});
mod.addImport("zero", zero.module("zero"));
mod.addImport("bearssl", bearssl.module("bearssl"));
const exe = b.addExecutable(.{
.name = "eva",
.use_llvm = true,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "eva", .module = mod },
.{ .name = "zero", .module = zero.module("zero") },
.{ .name = "bearssl", .module = bearssl.module("bearssl") },
},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Run the app");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
// Tests: a SEPARATE module rooted at src/root.zig (which contains a
// `comptime { _ = ... }` block that forces test discovery). The test
// module imports the same dependencies as the main module. This
// mirrors the pattern in zero/src/tests.zig and zero/build.zig.
const test_module = b.createModule(.{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
test_module.addImport("zero", zero.module("zero"));
test_module.addImport("bearssl", bearssl.module("bearssl"));
const mod_tests = b.addTest(.{ .root_module = test_module, .use_llvm = true });
const run_mod_tests = b.addRunArtifact(mod_tests);
const test_step = b.step("test", "Run tests");
// `-Dcoverage` mirrors zero's build.zig: wraps the test run with kcov
// and writes `zig-out/kcov/test/coverage.json` for the CI badge step.
const coverage = b.option(bool, "coverage", "enable code coverage using kcov") orelse false;
if (coverage) {
const mkdir_kcov = b.addSystemCommand(&.{ "mkdir", "-p", "zig-out/kcov" });
const run_kcov = b.addSystemCommand(&.{
"kcov",
"--clean",
"--include-path=src/",
"zig-out/kcov",
});
run_kcov.addArtifactArg(mod_tests);
run_kcov.step.dependOn(&mkdir_kcov.step);
test_step.dependOn(&run_mod_tests.step);
test_step.dependOn(&run_kcov.step);
} else {
test_step.dependOn(&run_mod_tests.step);
}
const test_https = b.addExecutable(.{
.name = "test_https",
.root_module = b.createModule(.{
.root_source_file = b.path("test_https.zig"),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "bearssl", .module = bearssl.module("bearssl") },
},
}),
});
const run_test_https = b.addRunArtifact(test_https);
b.step("test-https", "Test HTTPS Telegram message").dependOn(&run_test_https.step);
}