-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.zig
66 lines (54 loc) · 2.1 KB
/
build.zig
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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{
.preferred_optimize_mode = .ReleaseFast,
});
const trace = b.option(bool, "trace", "Enable tracing") orelse false;
const gas = b.option(bool, "gas", "Enable gas output (only if tracing is enabled)") orelse false;
const debug = b.option(bool, "debug", "Debug opcodes") orelse false;
const bench = b.option(bool, "bench", "Benchmark mode (print time)") orelse false;
const options = b.addOptions();
options.addOption(bool, "trace", trace);
options.addOption(bool, "gas", gas);
options.addOption(bool, "debug", debug);
options.addOption(bool, "bench", bench);
const lib = b.addStaticLibrary(.{
.name = "zee",
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
});
b.installArtifact(lib);
var testOptions: std.Build.TestOptions = .{
.root_source_file = b.path("src/test.zig"),
.target = target,
.optimize = optimize,
};
if (b.args) |args| {
testOptions.filters = args;
}
const lib_unit_tests = b.addTest(testOptions);
lib_unit_tests.root_module.addOptions("config", options);
const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
const test_step = b.step("test", "Run unit tests");
test_step.dependOn(&run_lib_unit_tests.step);
// Examples
const examples_step = b.step("example", "Run example");
const example_exe = b.addExecutable(.{
.name = "run example",
.root_source_file = b.path("examples/example.zig"),
.target = target,
.optimize = optimize,
});
const zee_module = b.addModule("zee", .{
.root_source_file = b.path("src/root.zig"),
});
zee_module.addOptions("config", options);
example_exe.root_module.addImport("zee", zee_module);
const example_run = b.addRunArtifact(example_exe);
if (b.args) |args| {
example_run.addArgs(args);
}
examples_step.dependOn(&example_run.step);
}