authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-01-18 00:03:02 -08:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2022-01-18 00:03:02 -08:00
log1649bf2e63ba4c27961582f78f138da0abb5c42d
tree321a0aaeae928c20341583bb203a0c219b3db79b
parent347e98e9352f7983272150eb3de445113bc6dd7b

build.zig- make constructing the output exe a separate function


1 files changed, 14 insertions(+), 10 deletions(-)

build.zig+14-10
......@@ -9,14 +9,26 @@ pub fn build(b: *std.build.Builder) void {
99 b.setPreferredReleaseMode(.ReleaseSafe);
1010 const mode = b.standardReleaseOptions();
1111
12 const bootstrap = b.option(bool, "bootstrap", "bootstrapping with just the zig compiler");
1213 const use_full_name = b.option(bool, "use-full-name", "") orelse false;
1314 const with_arch_os = b.fmt("-{s}-{s}", .{ @tagName(target.cpu_arch orelse builtin.cpu.arch), @tagName(target.os_tag orelse builtin.os.tag) });
1415 const exe_name = b.fmt("{s}{s}", .{ "zigmod", if (use_full_name) with_arch_os else "" });
16 const exe = makeExe(b, exe_name, target, mode, bootstrap);
17
18 const run_cmd = exe.run();
19 run_cmd.step.dependOn(b.getInstallStep());
20 if (b.args) |args| {
21 run_cmd.addArgs(args);
22 }
23
24 const run_step = b.step("run", "Run the app");
25 run_step.dependOn(&run_cmd.step);
26}
1527
28fn makeExe(b: *std.build.Builder, exe_name: string, target: std.zig.CrossTarget, mode: std.builtin.Mode, bootstrap: ?bool) *std.build.LibExeObjStep {
1629 const exe = b.addExecutable(exe_name, "src/main.zig");
1730 exe.setTarget(target);
1831 exe.setBuildMode(mode);
19 const bootstrap = b.option(bool, "bootstrap", "bootstrapping with just the zig compiler");
2032
2133 const exe_options = b.addOptions();
2234 exe.addOptions("build_options", exe_options);
......@@ -55,13 +67,5 @@ pub fn build(b: *std.build.Builder) void {
5567 }
5668
5769 exe.install();
58
59 const run_cmd = exe.run();
60 run_cmd.step.dependOn(b.getInstallStep());
61 if (b.args) |args| {
62 run_cmd.addArgs(args);
63 }
64
65 const run_step = b.step("run", "Run the app");
66 run_step.dependOn(&run_cmd.step);
70 return exe;
6771}