-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.zig
57 lines (50 loc) · 1.82 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
const std = @import("std");
const builtin = @import("builtin");
const flags = .{"-lwut"};
const devkitpro = "/opt/devkitpro";
pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const obj = b.addObject("zig-wiiu", "src/main.zig");
obj.setOutputDir("zig-out");
obj.linkLibC();
obj.setLibCFile(std.build.FileSource{ .path = "libc.txt" });
obj.addIncludeDir(devkitpro ++ "/wut/include");
obj.addIncludeDir(devkitpro ++ "/portlibs/wiiu/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",
"-Wl,-Map,zig-out/zig-wiiu.map",
"zig-out/zig-wiiu.o",
"-L" ++ devkitpro ++ "/wut/lib",
"-L" ++ devkitpro ++ "/portlibs/wiiu/lib",
"-L" ++ devkitpro ++ "/portlibs/ppc/lib",
} ++ flags ++ .{
"-o",
"zig-out/zig-wiiu.elf",
}));
const rpx = b.addSystemCommand(&.{
devkitpro ++ "/tools/bin/elf2rpl" ++ extension,
"zig-out/zig-wiiu.elf",
"zig-out/zig-wiiu.rpx",
});
const wuhb = b.addSystemCommand(&.{
devkitpro ++ "/tools/bin/wuhbtool" ++ extension,
"zig-out/zig-wiiu.rpx",
"zig-out/zig-wiiu.wuhb",
});
wuhb.stdout_action = .ignore;
b.default_step.dependOn(&wuhb.step);
wuhb.step.dependOn(&rpx.step);
rpx.step.dependOn(&elf.step);
elf.step.dependOn(&obj.step);
}