Skip to content

Commit

Permalink
build.zig: update to zig 0.12.0-dev.2127+fcc0c5ddc
Browse files Browse the repository at this point in the history
closes #47
  • Loading branch information
andrewrk committed Jan 10, 2024
1 parent 4c1f00a commit 719b0db
Showing 1 changed file with 26 additions and 13 deletions.
39 changes: 26 additions & 13 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,46 @@ pub fn build(b: *std.Build) void {
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
.strip = b.option(bool, "strip", "strip the binary"),
});

exe.strip = b.option(bool, "strip", "strip the binary") orelse switch (optimize) {
.Debug, .ReleaseSafe => false,
.ReleaseFast, .ReleaseSmall => true,
};

b.installArtifact(exe);

const release = b.step("release", "make an upstream binary release");
const release_targets = &[_][]const u8{
"aarch64-linux", "x86_64-linux", "x86-linux", "riscv64-linux",
const release_targets = [_]std.Target.Query{
.{
.cpu_arch = .aarch64,
.os_tag = .linux,
},
.{
.cpu_arch = .x86_64,
.os_tag = .linux,
},
.{
.cpu_arch = .x86,
.os_tag = .linux,
},
.{
.cpu_arch = .riscv64,
.os_tag = .linux,
},
};
for (release_targets) |target_string| {
for (release_targets) |target_query| {
const resolved_target = b.resolveTargetQuery(target_query);
const t = resolved_target.result;
const rel_exe = b.addExecutable(.{
.name = "poop",
.root_source_file = .{ .path = "src/main.zig" },
.target = std.zig.CrossTarget.parse(.{
.arch_os_abi = target_string,
}) catch unreachable,
.target = resolved_target,
.optimize = .ReleaseSafe,
.strip = true,
});
rel_exe.strip = true;

const install = b.addInstallArtifact(rel_exe, .{});
install.dest_dir = .prefix;
install.dest_sub_path = b.fmt("{s}-{s}", .{ target_string, rel_exe.name });
install.dest_sub_path = b.fmt("{s}-{s}-{s}", .{
@tagName(t.cpu.arch), @tagName(t.os.tag), rel_exe.name,
});

release.dependOn(&install.step);
}
Expand Down

0 comments on commit 719b0db

Please sign in to comment.