Files
zag/build.zig
T

46 lines
1.6 KiB
Zig

const std = @import("std");
const builtin = @import("builtin");
const zon = @import("build.zig.zon");
pub fn build(b: *std.Build) void {
// Linux builds default to musl: static binaries with no dependency on the host's libc.
const target = b.standardTargetOptions(.{
.default_target = if (builtin.os.tag == .linux) .{ .abi = .musl } else .{},
});
const optimize = b.standardOptimizeOption(.{});
const options = b.addOptions();
options.addOption([]const u8, "version", zon.version);
// libc is linked for `localtime_r` (human-readable local timestamps).
const mod = b.addModule("zag", .{
.root_source_file = b.path("src/root.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
});
mod.addOptions("build_options", options);
const exe = b.addExecutable(.{
.name = "zag",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.link_libc = true,
.imports = &.{.{ .name = "zag", .module = mod }},
}),
});
b.installArtifact(exe);
const run_step = b.step("run", "Run zag");
const run_cmd = b.addRunArtifact(exe);
run_step.dependOn(&run_cmd.step);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| run_cmd.addArgs(args);
const test_step = b.step("test", "Run tests");
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = mod })).step);
test_step.dependOn(&b.addRunArtifact(b.addTest(.{ .root_module = exe.root_module })).step);
}