I was following this here https://zigtools.org/zls/guides/build-on-save/ and the zig build code included defining two different executable objects, one for the installed executable and one for a check executable. I thought that was a bit verbose, so I tried to create a version of the code which just uses the one executable, however it for some reason still installs the executable when running the check step. The code is as follows:
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "PLACEHOLDER",
.root_source_file = b.path("src/main.zig"),
.optimize = optimize,
.target = target,
});
const checkStep = b.step("check", "Check if the executable compiles");
checkStep.dependOn(&exe.step);
const installExe = b.addInstallArtifact(exe, .{});
b.getInstallStep().dependOn(&installExe.step);
const runExe = b.addRunArtifact(exe);
const runStep = b.step("run", "Run the executable");
runStep.dependOn(&runExe.step);
}
Can someone explain to me what exactly the build script is doing and if there's a way to do it without defining two executables?
zigtools: We make free and open-source tools for the @ziglang community.