-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
58 lines (52 loc) · 2.09 KB
/
Copy pathbuild.zig
File metadata and controls
58 lines (52 loc) · 2.09 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");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const fiber_mod = b.addModule("fiber", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
// Examples: `zig build examples` builds and runs each program in examples/.
const example_step = b.step("examples", "Build and run the examples");
const examples = [_][]const u8{ "basic", "scheduler" };
for (examples) |name| {
const exe = b.addExecutable(.{
.name = name,
.root_module = b.createModule(.{
.root_source_file = b.path(b.fmt("examples/{s}.zig", .{name})),
.target = target,
.optimize = optimize,
.imports = &.{
.{ .name = "fiber", .module = fiber_mod },
},
}),
});
b.installArtifact(exe);
const run_example = b.addRunArtifact(exe);
run_example.step.dependOn(b.getInstallStep());
if (b.args) |args| run_example.addArgs(args);
example_step.dependOn(&run_example.step);
}
// Overflow probe: a standalone exe the guard-fault test spawns.
const probe = b.addExecutable(.{
.name = "overflow-probe",
.root_module = b.createModule(.{
.root_source_file = b.path("test/overflow_probe.zig"),
.target = target,
.optimize = optimize,
.imports = &.{.{ .name = "fiber", .module = fiber_mod }},
}),
});
const probe_install = b.addInstallArtifact(probe, .{});
// Tests: `zig build test`.
const tests = b.addTest(.{ .root_module = fiber_mod });
const run_tests = b.addRunArtifact(tests);
run_tests.step.dependOn(&probe_install.step);
run_tests.setEnvironmentVariable(
"FIBER_OVERFLOW_PROBE",
b.getInstallPath(.bin, b.fmt("overflow-probe{s}", .{target.result.exeFileExt()})),
);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_tests.step);
}