Skip to content

Commit

Permalink
update to Zig 2024.1.0-mach
Browse files Browse the repository at this point in the history
helps hexops/mach#1135

Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
  • Loading branch information
slimsag committed Jan 13, 2024
1 parent e8d3dea commit 0fdefbd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
41 changes: 17 additions & 24 deletions build.zig
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
const builtin = @import("builtin");
const std = @import("std");
const Build = std.Build;

pub fn build(b: *Build) !void {
pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

const module = b.addModule("mach-glfw", .{
.root_source_file = .{ .path = "src/main.zig" },
});
module.addIncludePath(b.dependency("glfw", .{}).path("include"));

const lib = b.addStaticLibrary(.{
.name = "mach-glfw",
.root_source_file = b.addWriteFiles().add("empty.c", ""),
const glfw_dep = b.dependency("glfw", .{
.target = target,
.optimize = optimize,
});
link(b, lib);
b.installArtifact(lib);

const module = b.addModule("mach-glfw", .{
.root_source_file = .{ .path = "src/main.zig" },
});
module.linkLibrary(glfw_dep.artifact("glfw"));

const test_step = b.step("test", "Run library tests");
const main_tests = b.addTest(.{
Expand All @@ -27,22 +22,20 @@ pub fn build(b: *Build) !void {
.target = target,
.optimize = optimize,
});

main_tests.linkLibrary(lib);
link(b, main_tests);
main_tests.linkLibrary(glfw_dep.artifact("glfw"));
addPaths(main_tests);
b.installArtifact(main_tests);

test_step.dependOn(&b.addRunArtifact(main_tests).step);
}

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", .{
.target = target_triple,
.cpu = cpu_opts,
.optimize = step.root_module.optimize.?,
});
@import("glfw").link(glfw_dep.builder, step);
step.linkLibrary(glfw_dep.artifact("glfw"));
_ = b;
_ = step;

@panic(".link(b, step) has been replaced by .addPaths(step)");
}

pub fn addPaths(step: *std.Build.Step.Compile) void {
@import("glfw").addPaths(step);
}
4 changes: 2 additions & 2 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
},
.dependencies = .{
.glfw = .{
.url = "https://github.com/der-teufel-programming/glfw/archive/523dc59dc16ceabd7665b38aabf969e330decaf6.tar.gz",
.hash = "1220dbfb5484019e82fb064090afbe09c83b2d6ab80aac11ceb43a37af78a792cf52",
.url = "https://pkg.machengine.org/glfw/4a39c70a6347419ae95f0718684b6b10e65e015a.tar.gz",
.hash = "12209e5e9c8850f4beebf1e620c73ba9daa5cf587ffa5dbd5376b8a4f18bb0e1c819",
},
},
}

0 comments on commit 0fdefbd

Please sign in to comment.