update zig: fix never mutated vars, use new build system API

This commit is contained in:
Stephen Gutekanst 2024-01-12 14:18:38 -07:00 committed by Stephen Gutekanst
parent 689bd4902c
commit e8d3deacdc
4 changed files with 15 additions and 11 deletions

View file

@ -6,9 +6,10 @@ pub fn build(b: *Build) !void {
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
_ = b.addModule("mach-glfw", .{ const module = b.addModule("mach-glfw", .{
.source_file = .{ .path = "src/main.zig" }, .root_source_file = .{ .path = "src/main.zig" },
}); });
module.addIncludePath(b.dependency("glfw", .{}).path("include"));
const lib = b.addStaticLibrary(.{ const lib = b.addStaticLibrary(.{
.name = "mach-glfw", .name = "mach-glfw",
@ -34,10 +35,13 @@ pub fn build(b: *Build) !void {
test_step.dependOn(&b.addRunArtifact(main_tests).step); test_step.dependOn(&b.addRunArtifact(main_tests).step);
} }
pub fn link(b: *std.Build, step: *std.build.CompileStep) void { pub fn link(b: *std.Build, step: *std.Build.Step.Compile) void {
const target_triple: []const u8 = step.rootModuleTarget().zigTriple(b.allocator) catch @panic("OOM");
const cpu_opts: []const u8 = step.root_module.resolved_target.?.query.serializeCpuAlloc(b.allocator) catch @panic("OOM");
const glfw_dep = b.dependency("glfw", .{ const glfw_dep = b.dependency("glfw", .{
.target = step.target, .target = target_triple,
.optimize = step.optimize, .cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
}); });
@import("glfw").link(glfw_dep.builder, step); @import("glfw").link(glfw_dep.builder, step);
step.linkLibrary(glfw_dep.artifact("glfw")); step.linkLibrary(glfw_dep.artifact("glfw"));

View file

@ -12,8 +12,8 @@
}, },
.dependencies = .{ .dependencies = .{
.glfw = .{ .glfw = .{
.url = "https://pkg.machengine.org/glfw/49d153ebfc4f45eacc757ec2b063decbf5bb1779.tar.gz", .url = "https://github.com/der-teufel-programming/glfw/archive/523dc59dc16ceabd7665b38aabf969e330decaf6.tar.gz",
.hash = "122020d1ba277ff9e4b5ffff3e3bf4a3c98eeaec821e2a497d031070b05f7814b91f", .hash = "1220dbfb5484019e82fb064090afbe09c83b2d6ab80aac11ceb43a37af78a792cf52",
}, },
}, },
} }

View file

@ -2222,7 +2222,7 @@ test "hint int" {
} }
defer glfw.terminate(); defer glfw.terminate();
var focused: i32 = 1; const focused: i32 = 1;
hint(.focused, focused); hint(.focused, focused);
defaultHints(); defaultHints();
@ -2363,8 +2363,8 @@ test "setIcon" {
defer window.destroy(); defer window.destroy();
// Create an all-red icon image. // Create an all-red icon image.
var width: u32 = 48; const width: u32 = 48;
var height: u32 = 48; const height: u32 = 48;
const icon = try Image.init(allocator, width, height, width * height * 4); const icon = try Image.init(allocator, width, height, width * height * 4);
var x: u32 = 0; var x: u32 = 0;
var y: u32 = 0; var y: u32 = 0;

View file

@ -520,7 +520,7 @@ pub fn basicTest() !void {
}; };
defer window.destroy(); defer window.destroy();
var start = std.time.milliTimestamp(); const start = std.time.milliTimestamp();
while (std.time.milliTimestamp() < start + 1000 and !window.shouldClose()) { while (std.time.milliTimestamp() < start + 1000 and !window.shouldClose()) {
c.glfwPollEvents(); c.glfwPollEvents();
} }