-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
43 lines (35 loc) · 1.29 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
const std = @import("std");
const Build = std.Build;
const Executable = struct {
name: []const u8,
source: []const u8,
run_args: ?[]const []const u8 = null,
};
const executables = [_]Executable{
.{ .name = "memory", .source = "src/memory.zig" },
.{ .name = "gpu", .source = "src/gpu.zig" },
.{ .name = "ping", .source = "src/ping.zig" },
.{ .name = "updates", .source = "src/updates.zig" },
};
pub fn build(b: *Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{
.preferred_optimize_mode = .ReleaseFast,
});
for (executables) |exe| {
const exe_obj = b.addExecutable(.{
.name = exe.name,
.root_source_file = b.path(exe.source),
.target = target,
.optimize = optimize,
});
exe_obj.want_lto = true;
const install_exe = b.addInstallArtifact(exe_obj, .{});
b.getInstallStep().dependOn(&install_exe.step);
const run_cmd = b.addRunArtifact(exe_obj);
if (b.args) |args| run_cmd.addArgs(args);
if (exe.run_args) |args| run_cmd.addArgs(args);
const run_step = b.step(b.fmt("run-{s}", .{exe.name}), b.fmt("Run the {s} executable", .{exe.name}));
run_step.dependOn(&run_cmd.step);
}
}