feat: Update to Zig v0.13.0

This commit is contained in:
Rekai Nyangadzayi Musuka 2024-09-09 02:42:18 -05:00
parent 34210d1068
commit 26870542cb
7 changed files with 33 additions and 33 deletions

View File

@ -21,7 +21,7 @@ jobs:
steps:
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0-dev.2063+804cee3b9
version: 0.13.0
- run: |
git config --global core.autocrlf false
- uses: actions/checkout@v3
@ -56,5 +56,5 @@ jobs:
submodules: recursive
- uses: goto-bus-stop/setup-zig@v2
with:
version: 0.12.0-dev.2063+804cee3b9
version: 0.13.0
- run: zig fmt --check {src,lib}/**/*.zig build.zig build.zig.zon

2
.gitignore vendored
View File

@ -1,4 +1,4 @@
zig-cache/
.zig-cache/
zig-out/
bin/
doc/

View File

@ -1,5 +1,5 @@
const std = @import("std");
const Sdk = @import("lib/SDL.zig/build.zig");
const sdl = @import("lib/SDL.zig/build.zig");
// Although this function looks imperative, note that its job is to
// declaratively construct a build graph that will be executed by an external
@ -20,26 +20,26 @@ pub fn build(b: *std.Build) void {
.name = "turbo",
// In this case the main source file is merely a path, however, in more
// complicated build scripts, this could be a generated file.
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});
const sdk = Sdk.init(b, null); // https://github.com/MasterQ32/SDL.zig
const sdk = sdl.init(b, null, null);
const zgui = b.dependency("zgui", .{ .shared = false, .with_implot = true, .backend = .sdl2_opengl3 });
const imgui = zgui.artifact("imgui");
exe.root_module.addImport("arm32", b.dependency("arm32", .{}).module("arm32"));
exe.root_module.addImport("gdbstub", b.dependency("zba-gdbstub", .{}).module("gdbstub"));
exe.root_module.addImport("zig-clap", b.dependency("zig-clap", .{}).module("clap"));
exe.root_module.addImport("zgui", zgui.module("root"));
exe.root_module.addImport("sdl2", sdk.getNativeModule());
exe.root_module.addImport("arm32", b.dependency("arm32", .{}).module("arm32")); // https://git.musuka.dev/paoda/arm32
exe.root_module.addImport("gdbstub", b.dependency("zba-gdbstub", .{}).module("zba-gdbstub")); // https://git.musuka.dev/paoda/zba-gdbstub
exe.root_module.addImport("zig-clap", b.dependency("zig-clap", .{}).module("clap")); // https://github.com/Hejsil/zig-clap
exe.root_module.addImport("zgui", zgui.module("root")); // https://git.musuka.dev/paoda/zgui
exe.root_module.addImport("sdl2", sdk.getNativeModule()); // https://github.com/MasterQ32/SDL.zig
exe.root_module.addAnonymousImport("bitfield", .{ .root_source_file = .{ .path = "lib/bitfield.zig" } }); // https://github.com/FlorenceOS/
exe.root_module.addAnonymousImport("gl", .{ .root_source_file = .{ .path = "lib/gl.zig" } }); // https://github.com/MasterQ32/zig-opengl
exe.root_module.addAnonymousImport("bitfield", .{ .root_source_file = b.path("lib/bitfield.zig") }); // https://github.com/FlorenceOS/
exe.root_module.addAnonymousImport("gl", .{ .root_source_file = b.path("lib/gl.zig") }); // https://github.com/MasterQ32/zig-opengl
sdk.link(exe, .dynamic);
sdk.link(imgui, .dynamic);
sdk.link(exe, .dynamic, .SDL2);
sdk.link(imgui, .dynamic, .SDL2);
exe.linkLibrary(imgui);
// This declares intent for the executable to be installed into the
@ -73,7 +73,7 @@ pub fn build(b: *std.Build) void {
// Creates a step for unit testing. This only builds the test executable
// but does not run it.
const unit_tests = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
});

View File

@ -10,20 +10,20 @@
},
.dependencies = .{
.@"zig-clap" = .{
.url = "https://github.com/Hejsil/zig-clap/archive/4267b0b60ef6f87cccf3ee6ed481e6d0759180c6.tar.gz",
.hash = "12202fa30d679d821292bcd953458b9e76097a5d16999489125a206db63a53392833",
.url = "git+https://github.com/Hejsil/zig-clap#c0193e9247335a6c1688b946325060289405de2a",
.hash = "12207ee987ce045596cb992cfb15b0d6d9456e50d4721c3061c69dabc2962053644d",
},
.@"zba-gdbstub" = .{
.url = "https://git.musuka.dev/paoda/zba-gdbstub/archive/7ae72ed5a892d2fc6cc3f5511e2b96134d928b59.tar.gz",
.hash = "1220823e961f369e22b62edc1b4da3742af0a7cb420ae9a52ec33216ff5a8ef270c8",
.url = "git+https://git.musuka.dev/paoda/zba-gdbstub#9a50607d5f48293f950a4e823344f2bc24582a5a",
.hash = "1220ac267744ed2a735f03c4620d7c6210fbd36d7bfb2b376ddc3436faebadee0f61",
},
.arm32 = .{
.url = "https://git.musuka.dev/paoda/arm32/archive/0010029783a907b2c73dc7741d9d81471ff98592.tar.gz",
.hash = "1220a0c28bb7bbb6df57bbaf91741d3e032f8fbf9e273f41d19384f6bcd1d3adf7d3",
.url = "git+https://git.musuka.dev/paoda/arm32#814d081ea0983bc48841a6baad7158c157b17ad6",
.hash = "12203c3dacf3a7aa7aee5fc5763dd7b40399bd1c34d1483330b6bd5a76bffef22d82",
},
.zgui = .{
.url = "https://git.musuka.dev/paoda/zgui/archive/28e926748b8f302dd4e2902835e392c9b87ea3c6.tar.gz",
.hash = "1220dbf1d809d07d1910b9853f162458ed1ebc66be81b21ccfc40a2552bc1019f9c2",
.url = "git+https://git.musuka.dev/paoda/zgui#7f8d05101e96c64314d7926c80ee157dcb89da4e",
.hash = "1220bd81a1c7734892b1d4233ed047710487787873c85dd5fc76d1764a331ed2ff43",
},
},
}

@ -1 +1 @@
Subproject commit 0f74e59f4b258868959104b24fdf6c43071e11ad
Subproject commit fac81ec499cfd64da7b846de27f6db4a0d4943bf

View File

@ -429,7 +429,7 @@ const Input = struct {
inner: u32 = 0x007F_03FF,
pub inline fn keyinput(self: *const Input) KeyInput {
const value = @atomicLoad(u32, &self.inner, .Monotonic);
const value = @atomicLoad(u32, &self.inner, .monotonic);
return .{ .raw = @truncate(value) };
}
@ -440,11 +440,11 @@ const Input = struct {
else => @compileError("not supported"),
};
_ = @atomicRmw(u32, &self.inner, op, msked, .Monotonic);
_ = @atomicRmw(u32, &self.inner, op, msked, .monotonic);
}
pub inline fn extkeyin(self: *const Input) ExtKeyIn {
const value = @atomicLoad(u32, &self.inner, .Monotonic);
const value = @atomicLoad(u32, &self.inner, .monotonic);
const shifted: u16 = @truncate(value >> 16);
return .{ .raw = shifted | 0b00110100 }; // bits 2, 4, 5 are always set
@ -457,10 +457,10 @@ const Input = struct {
else => @compileError("not supported"),
};
_ = @atomicRmw(u32, &self.inner, op, msked, .Monotonic);
_ = @atomicRmw(u32, &self.inner, op, msked, .monotonic);
}
pub inline fn set(self: *Input, comptime op: AtomicRmwOp, value: u32) void {
_ = @atomicRmw(u32, &self.inner, op, value, .Monotonic);
_ = @atomicRmw(u32, &self.inner, op, value, .monotonic);
}
};

View File

@ -98,7 +98,7 @@ pub const Ui = struct {
var event: SDL.SDL_Event = undefined;
while (!sync.should_quit.load(.Monotonic)) {
while (!sync.should_quit.load(.monotonic)) {
emu.runFrame(scheduler, system); // TODO: run emu in separate thread
while (SDL.SDL_PollEvent(&event) != 0) {
@ -141,7 +141,7 @@ pub const Ui = struct {
var event: SDL.SDL_Event = undefined;
while (!sync.should_quit.load(.Monotonic)) {
while (!sync.should_quit.load(.monotonic)) {
while (SDL.SDL_PollEvent(&event) != 0) {
_ = zgui.backend.processEvent(&event);
handleInput(&event, system, &self.state, sync);
@ -178,7 +178,7 @@ pub const Ui = struct {
fn handleInput(event: *SDL.SDL_Event, system: System, state: *imgui.State, sync: *Sync) void {
switch (event.type) {
SDL.SDL_QUIT => sync.should_quit.store(true, .Monotonic),
SDL.SDL_QUIT => sync.should_quit.store(true, .monotonic),
SDL.SDL_WINDOWEVENT => {
if (event.window.event == SDL.SDL_WINDOWEVENT_RESIZED) {
std.log.debug("window resized to: {}x{}", .{ event.window.data1, event.window.data2 });