Skip to content

Commit

Permalink
Update clap and re-enable compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed Mar 7, 2024
1 parent b16d3b3 commit 710bc18
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 63 deletions.
71 changes: 17 additions & 54 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -74,43 +74,6 @@ pub fn build(b: *std.Build) !void {

app.compile.addIncludePath(.{ .path = root_path ++ "libs/zig-bass/src" });

// if (target.isDarwin()) {
// exe.addIncludePath(.{ .path = root_path ++ "libs/system-sdk/macos12/usr/include" });
// exe.addFrameworkPath(.{ .path = root_path ++ "libs/system-sdk/macos12/System/Library/Frameworks" });
// exe.addLibraryPath(.{ .path = root_path ++ "libs/system-sdk/macos12/usr/lib" });

// if (!builtin.target.isDarwin()) {
// b.sysroot = root_path ++ "libs/system-sdk/macos12";
// }

// exe.linkFramework("Metal");
// exe.linkFramework("QuartzCore");
// exe.linkFramework("Foundation");

// exe.linkSystemLibrary("objc");
// }

// if (target.isLinux() and !target.isNative()) {
// exe.addIncludePath(.{ .path = root_path ++ "libs/system-sdk/linux/include" });
// exe.addLibraryPath(.{ .path = b.fmt(root_path ++ "libs/system-sdk/linux/lib/{s}", .{try target.linuxTriple(b.allocator)}) });
// }

{ //zig-bass
} //zig-bass

// { //cimgui
// const cimgui_lib = try cimgui.create_cimgui(b, target, optimize);

// cimgui_lib.installLibraryHeaders(sdl_lib);
// cimgui_lib.linkLibrary(sdl_lib);
// try cimgui_lib.lib_paths.appendSlice(sdl_lib.lib_paths.items);
// try cimgui_lib.include_dirs.appendSlice(sdl_lib.include_dirs.items);

// exe.addIncludePath(.{ .path = "libs/cimgui/" });

// exe.linkLibrary(cimgui_lib);
// } //cimgui

{ //iconv
const iconv_lib = iconv.createIconv(b, target, optimize);

Expand Down Expand Up @@ -147,23 +110,23 @@ pub fn build(b: *std.Build) !void {
});
b.installArtifact(tempo);

// const clap = b.dependency("clap", .{});
// const fumen_compile = b.addExecutable(.{
// .name = "fumen_compile",
// .root_source_file = .{ .path = root_path ++ "util/fumen_compile.zig" },
// .target = target,
// .optimize = optimize,
// });
// fumen_compile.root_module.addImport("clap", clap.module("clap"));
// b.installArtifact(fumen_compile);

// const fumen_compile_cmd = b.addRunArtifact(fumen_compile);
// fumen_compile_cmd.step.dependOn(b.getInstallStep());
// if (b.args) |args| {
// fumen_compile_cmd.addArgs(args);
// }
// const fumen_compile_step = b.step("fumen_compile", "Run the fumen compiler");
// fumen_compile_step.dependOn(&fumen_compile_cmd.step);
const clap = b.dependency("clap", .{});
const fumen_compile = b.addExecutable(.{
.name = "fumen_compile",
.root_source_file = .{ .path = root_path ++ "util/fumen_compile.zig" },
.target = target,
.optimize = optimize,
});
fumen_compile.root_module.addImport("clap", clap.module("clap"));
b.installArtifact(fumen_compile);

const fumen_compile_cmd = b.addRunArtifact(fumen_compile);
fumen_compile_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
fumen_compile_cmd.addArgs(args);
}
const fumen_compile_step = b.step("fumen_compile", "Run the fumen compiler");
fumen_compile_step.dependOn(&fumen_compile_cmd.step);

const tempo_cmd = b.addRunArtifact(tempo);
tempo_cmd.step.dependOn(b.getInstallStep());
Expand Down
8 changes: 4 additions & 4 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
.url = "https://github.com/Beyley/zigimg/archive/d54b946d4b33cf1a18c31ab8ce6a1b4e4f7c2d38.tar.gz",
.hash = "1220a1ac633472925863401189e4de1cbf441736dd100c17c19a837ee0f31632d647",
},
// .clap = .{
// .url = "https://github.com/Hejsil/zig-clap/archive/f49b94700e0761b7514abdca0e4f0e7f3f938a93.tar.gz",
// .hash = "1220f48518ce22882e102255ed3bcdb7aeeb4891f50b2cdd3bd74b5b2e24d3149ba2",
// },
.clap = .{
.url = "https://github.com/Hejsil/zig-clap/archive/0f2db7700b05356ebb1ccddbbf1797048925f072.tar.gz",
.hash = "12203896de6eedec14712f4f1eaac8b646939cfed213c56accf231a0abb05f9dbb77",
},
},
.paths = .{
"game/",
Expand Down
5 changes: 3 additions & 2 deletions game/app.zig
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,6 @@ pub fn deinit(app: *App) void {
}

pub fn update(app: *App) !bool {
std.debug.print("update\n", .{});

//Get the top screen
var screen = app.screen_stack.top();

Expand Down Expand Up @@ -211,5 +209,8 @@ pub fn update(app: *App) !bool {
screen.screen_push = null;
}

if (!app.is_running)
return true;

return false;
}
7 changes: 4 additions & 3 deletions game/gfx.zig
Original file line number Diff line number Diff line change
Expand Up @@ -505,15 +505,15 @@ pub fn createBuffer(comptime contents_type: type, count: u64, buffer_type: core.

pub fn setErrorCallbacks(self: *Self) void {
_ = self; // autofix
// core.device.setUncapturedErrorCallback({}, uncapturedError);
core.device.setUncapturedErrorCallback({}, uncapturedError);

std.debug.print("setup wgpu device callbacks\n", .{});
}

fn uncapturedError(ctx: void, error_type: core.gpu.ErrorType, message: [*:0]const u8) void {
inline fn uncapturedError(ctx: void, error_type: core.gpu.ErrorType, message: [*:0]const u8) void {
_ = ctx; // autofix

std.debug.print("Got uncaptured error {d} with message {s}\n", .{ error_type, std.mem.span(message) });
std.debug.print("Got uncaptured error {s} with message {s}\n", .{ @tagName(error_type), std.mem.span(message) });
// @panic("uncaptured wgpu error");
}

Expand All @@ -540,6 +540,7 @@ pub fn updateProjectionMatrixBuffer(self: *Self) void {
1,
);

std.debug.print("thsathss {}\n", .{mat});
core.queue.writeBuffer(self.projection_matrix_buffer, 0, &[_]math.Mat4x4{mat});
}

Expand Down
1 change: 1 addition & 0 deletions util/fumen_compile.zig
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pub fn main() !void {
var diag = clap.Diagnostic{};
var res = clap.parse(clap.Help, &params, clap.parsers.default, .{
.diagnostic = &diag,
.allocator = allocator,
}) catch |err| {
// Report useful error and exit
diag.report(io.getStdErr().writer(), err) catch {};
Expand Down

0 comments on commit 710bc18

Please sign in to comment.