-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.zig
More file actions
77 lines (64 loc) · 2.76 KB
/
build.zig
File metadata and controls
77 lines (64 loc) · 2.76 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
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const name = b.option([]const u8, "name", "Name of the executable") orelse "usrl";
const profiling = b.option(bool, "profiling", "Enable profiling with tracy") orelse false;
const keep_temp = b.option(bool, "keep-temp", "Keep transaction and temp files.") orelse false;
const max_script_size = b.option(usize, "max-script-size", "The maximum amount of bytes a script can take") orelse 1 << 16;
const scan_thread_count = b.option(usize, "scan-thread-count", "The number of threads that will be used when scanning") orelse 4;
const install_step = b.getInstallStep();
const run_step = b.step("run", "Run the CLI");
const test_step = b.step("test", "Run unit tests");
const libyaml = b.dependency("libyaml", .{
.target = target,
.optimize = optimize,
}).module("libyaml");
const ztracy = b.dependency("ztracy", .{
.target = target,
.optimize = optimize,
.enable_ztracy = profiling,
});
const options = b.addOptions();
options.addOption(bool, "profiling", profiling);
options.addOption(bool, "keep_temp", keep_temp);
options.addOption(usize, "max_script_size", max_script_size);
options.addOption(usize, "scan_thread_count", scan_thread_count);
options.addOption([]const u8, "version", @import("build.zig.zon").version);
const config = options.createModule();
const mod = b.addModule("usrl", .{
.root_source_file = b.path("lib/root.zig"),
.target = target,
.optimize = optimize,
});
mod.addImport("core", mod);
mod.addImport("config", config);
mod.addImport("libyaml", libyaml);
mod.addImport("tracy", ztracy.module("root"));
mod.linkLibrary(ztracy.artifact("tracy"));
// main executable
const exe = b.addExecutable(.{
.name = name,
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("usrl", mod);
exe.root_module.addImport("config", config);
exe.root_module.addImport("tracy", ztracy.module("root"));
exe.root_module.linkLibrary(ztracy.artifact("tracy"));
const install_urt = b.addInstallArtifact(exe, .{});
install_step.dependOn(&install_urt.step);
const run_urt = b.addRunArtifact(exe);
run_urt.step.dependOn(install_step);
run_step.dependOn(&run_urt.step);
if (b.args) |args| {
run_urt.addArgs(args);
}
// Tests
const tests = b.addTest(.{ .root_module = mod });
const run_tests = b.addRunArtifact(tests);
test_step.dependOn(&run_tests.step);
}