-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.zig
More file actions
56 lines (49 loc) · 1.79 KB
/
build.zig
File metadata and controls
56 lines (49 loc) · 1.79 KB
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
const std = @import("std");
const builtin = @import("builtin");
const emulator = "Ryujinx";
const flags = .{"-lnx"};
const devkitpro = "/opt/devkitpro";
pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
const obj = b.addObject("zig-switch", "src/main.zig");
obj.setOutputDir("zig-out");
obj.linkLibC();
obj.setLibCFile(std.build.FileSource{ .path = "libc.txt" });
obj.addIncludeDir(devkitpro ++ "/libnx/include");
obj.addIncludeDir(devkitpro ++ "/portlibs/switch/include");
obj.setTarget(.{
.cpu_arch = .aarch64,
.os_tag = .freestanding,
.cpu_model = .{ .explicit = &std.Target.aarch64.cpu.cortex_a57 },
});
obj.setBuildMode(mode);
const extension = if (builtin.target.os.tag == .windows) ".exe" else "";
const elf = b.addSystemCommand(&(.{
devkitpro ++ "/devkitA64/bin/aarch64-none-elf-gcc" ++ extension,
"-g",
"-march=armv8-a+crc+crypto",
"-mtune=cortex-a57",
"-mtp=soft",
"-fPIE",
"-Wl,-Map,zig-out/zig-switch.map",
"-specs=" ++ devkitpro ++ "/libnx/switch.specs",
"zig-out/zig-switch.o",
"-L" ++ devkitpro ++ "/libnx/lib",
"-L" ++ devkitpro ++ "/portlibs/switch/lib",
} ++ flags ++ .{
"-o",
"zig-out/zig-switch.elf",
}));
const nro = b.addSystemCommand(&.{
devkitpro ++ "/tools/bin/elf2nro" ++ extension,
"zig-out/zig-switch.elf",
"zig-out/zig-switch.nro",
});
b.default_step.dependOn(&nro.step);
nro.step.dependOn(&elf.step);
elf.step.dependOn(&obj.step);
const run_step = b.step("run", "Run in Yuzu");
const yuzu = b.addSystemCommand(&.{ emulator, "zig-out/zig-switch.nro" });
run_step.dependOn(&nro.step);
run_step.dependOn(&yuzu.step);
}