-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
48 lines (42 loc) · 1.52 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
const std = @import("std");
const gpu = @import("mach_gpu");
pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{});
// Build wchip
const exe = b.addExecutable(.{
.name = "wchip",
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
.optimize = optimize,
});
b.installArtifact(exe);
try gpu.link(b, exe, &exe.root_module, .{});
const glfw_dep = b.lazyDependency("mach_glfw", .{
.target = target,
.optimize = optimize,
}) orelse @panic("Could not resolve glfw dep");
exe.root_module.addImport("glfw", glfw_dep.module("mach-glfw"));
exe.root_module.addImport("gpu", b.dependency("mach_gpu", .{
.target = target,
.optimize = optimize,
}).module("mach-gpu"));
// zig build run implementation
const run_cmd = b.addRunArtifact(exe);
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step("run", "Run the app");
run_step.dependOn(&run_cmd.step);
// zig build test implementation
const test_lib_chip = b.addTest(.{
.root_source_file = .{ .path = "src/chip8.zig" },
.target = target,
.optimize = optimize,
});
const test_step = b.step("test", "Run unit tests");
const run_test = b.addRunArtifact(test_lib_chip);
run_test.setCwd(b.dependency("chip8_test_suite", .{}).path("/bin"));
test_step.dependOn(&run_test.step);
}