-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.zig
60 lines (53 loc) · 1.93 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
const std = @import("std");
const builtin = @import("builtin");
const emulator = "dolphin-emu";
const flags = .{"-logc"};
const devkitpro = "/opt/devkitpro";
pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const obj = b.addObject("zig-wii", "src/main.zig");
obj.setOutputDir("zig-out");
obj.linkLibC();
obj.setLibCFile(std.build.FileSource{ .path = "libc.txt" });
obj.addIncludeDir(devkitpro ++ "/libogc/include");
obj.addIncludeDir(devkitpro ++ "/portlibs/wii/include");
obj.addIncludeDir(devkitpro ++ "/portlibs/ppc/include");
obj.setTarget(.{
.cpu_arch = .powerpc,
.os_tag = .freestanding,
.abi = .eabi,
.cpu_model = .{ .explicit = &std.Target.powerpc.cpu.@"750" },
.cpu_features_add = std.Target.powerpc.featureSet(&.{.hard_float}),
});
obj.setBuildMode(mode);
const extension = if (builtin.target.os.tag == .windows) ".exe" else "";
const elf = b.addSystemCommand(&(.{
devkitpro ++ "/devkitPPC/bin/powerpc-eabi-gcc" ++ extension,
"-g",
"-DGEKKO",
"-mrvl",
"-mcpu=750",
"-meabi",
"-mhard-float",
"-Wl,-Map,zig-out/zig-wii.map",
"zig-out/zig-wii.o",
"-L" ++ devkitpro ++ "/libogc/lib/cube",
"-L" ++ devkitpro ++ "/portlibs/wii/lib",
"-L" ++ devkitpro ++ "/portlibs/ppc/lib",
} ++ flags ++ .{
"-o",
"zig-out/zig-wii.elf",
}));
const dol = b.addSystemCommand(&.{
devkitpro ++ "/tools/bin/elf2dol",
"zig-out/zig-wii.elf",
"zig-out/zig-wii.dol",
});
b.default_step.dependOn(&dol.step);
dol.step.dependOn(&elf.step);
elf.step.dependOn(&obj.step);
const run_step = b.step("run", "Run in Dolphin");
const dolphin = b.addSystemCommand(&.{ emulator, "-d", "-a", "LLE", "-e", "zig-out/zig-wii.elf" });
run_step.dependOn(&elf.step);
run_step.dependOn(&dolphin.step);
}