-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.zig
61 lines (48 loc) · 1.9 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
56
57
58
59
60
61
const std = @import("std");
const builtin = @import("builtin");
pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const target = b.standardTargetOptions(.{});
const main_tests = b.addTest("src/main.zig");
main_tests.setBuildMode(mode);
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&main_tests.step);
const wasm = b.addSharedLibrary("fundude", "src/exports.zig", .unversioned);
wasm.addPackagePath("zee_alloc", "submodules/zee_alloc/src/main.zig");
wasm.setOutputDir("zig-out/lib");
wasm.setBuildMode(mode);
wasm.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
wasm.install();
const wasm_step = b.step("wasm", "Build wasm version");
wasm_step.dependOn(&wasm.step);
const native = b.addExecutable("fundude_native", "src/native.zig");
native.linkSystemLibrary("sdl2");
native.setTarget(target);
native.setBuildMode(mode);
native.install();
const native_step = b.step("native", "Build native SDL version");
native_step.dependOn(&native.step);
const run_cmd = native.run();
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);
addScript(b, "opcodes");
addScript(b, "testrom");
addScript(b, "turbo");
}
fn addScript(b: *std.build.Builder, name: []const u8) void {
const filename = std.fmt.allocPrint(b.allocator, "scripts/{s}.zig", .{name}) catch unreachable;
const mode = b.standardReleaseOptions();
const exe = b.addExecutable(name, filename);
exe.setBuildMode(mode);
exe.addPackagePath("fundude", "src/main.zig");
const run_cmd = exe.run();
if (b.args) |args| {
run_cmd.addArgs(args);
}
const run_step = b.step(name, filename);
run_step.dependOn(&run_cmd.step);
}