-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
40 lines (32 loc) · 1.37 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
const std = @import("std");
const string = []const u8;
const builtin = @import("builtin");
const deps = @import("./deps.zig");
pub fn build(b: *std.build.Builder) void {
const target = b.standardTargetOptions(.{
.default_target = std.zig.CrossTarget{ .abi = .musl },
});
std.debug.assert(target.getOsTag() == .linux);
b.prominent_compile_errors = true;
b.setPreferredReleaseMode(.ReleaseSafe);
const mode = b.standardReleaseOptions();
const use_full_name = b.option(bool, "use-full-name", "") orelse false;
const with_os_arch = b.fmt("-{s}-{s}", .{ @tagName(target.os_tag orelse builtin.os.tag), @tagName(target.cpu_arch orelse builtin.cpu.arch) });
const exe_name = b.fmt("{s}{s}", .{ "aquila", if (use_full_name) with_os_arch else "" });
const exe = b.addExecutable(exe_name, "src/main.zig");
exe.setTarget(target);
exe.setBuildMode(mode);
if (mode != .Debug) exe.strip = true;
const exe_options = b.addOptions();
exe.addOptions("build_options", exe_options);
exe_options.addOption(string, "version", b.option(string, "version", "") orelse "dev");
deps.addAllTo(exe);
exe.install();
const run_cmd = exe.run();
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
}