-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathbuild.zig
55 lines (49 loc) · 1.54 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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const std = @import("std");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
const exe = b.addExecutable(.{
.name = "poop",
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
.strip = b.option(bool, "strip", "strip the binary"),
});
b.installArtifact(exe);
const release = b.step("release", "make an upstream binary release");
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_query| {
const resolved_target = b.resolveTargetQuery(target_query);
const t = resolved_target.result;
const rel_exe = b.addExecutable(.{
.name = "poop",
.root_source_file = b.path("src/main.zig"),
.target = resolved_target,
.optimize = .ReleaseSafe,
.strip = true,
});
const install = b.addInstallArtifact(rel_exe, .{});
install.dest_dir = .prefix;
install.dest_sub_path = b.fmt("{s}-{s}-{s}", .{
@tagName(t.cpu.arch), @tagName(t.os.tag), rel_exe.name,
});
release.dependOn(&install.step);
}
}