-
-
Notifications
You must be signed in to change notification settings - Fork 35
/
build.zig
37 lines (32 loc) · 1.35 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
const std = @import("std");
const string = []const u8;
const builtin = @import("builtin");
const deps = @import("./deps.zig");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const mode = b.option(std.builtin.Mode, "mode", "") orelse .Debug;
const use_full_name = b.option(bool, "use-full-name", "") orelse false;
const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.result.cpu.arch), @tagName(target.result.os.tag) });
const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
const exe = b.addExecutable(.{
.name = exe_name,
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = mode,
});
const tag = b.option(string, "tag", "") orelse "dev";
const strip = b.option(bool, "strip", "Build without debug info.") orelse false;
const exe_options = b.addOptions();
exe.root_module.addImport("build_options", exe_options.createModule());
exe_options.addOption(string, "version", tag);
deps.addAllTo(exe);
exe.root_module.strip = strip;
b.installArtifact(exe);
const run_cmd = b.addRunArtifact(exe);
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);
}