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 5720c9b commit 5a68105
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
24 changes: 9 additions & 15 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ pub fn build(b: *Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});

_ = b.addModule("mach-basisu", .{
.source_file = .{ .path = "src/main.zig" },
});

// TODO: add this as a module dependency
const lib = b.addStaticLibrary(.{
.name = "mach-basisu",
.target = target,
.optimize = optimize,
});
lib.linkLibCpp();
link(b, lib);

lib.addCSourceFiles(.{ .files = &.{
"src/encoder/wrapper.cpp",
"src/transcoder/wrapper.cpp",
}, .flags = &.{} });

lib.linkLibrary(b.dependency("basisu", .{
.target = target,
.optimize = optimize,
}).artifact("basisu"));
b.installArtifact(lib);

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

const test_exe = b.addTest(.{
.root_source_file = .{ .path = "src/main.zig" },
.target = target,
Expand All @@ -36,10 +37,3 @@ pub fn build(b: *Build) void {
const test_step = b.step("test", "Run library tests");
test_step.dependOn(&b.addRunArtifact(test_exe).step);
}

pub fn link(b: *std.Build, step: *std.build.CompileStep) void {
step.linkLibrary(b.dependency("basisu", .{
.target = step.target,
.optimize = step.optimize,
}).artifact("basisu"));
}
2 changes: 1 addition & 1 deletion src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ test "encode/transcode" {
const trans = try Transcoder.init(comp.output());
defer trans.deinit();

var out_buf = try testing.allocator.alloc(u8, try trans.calcTranscodedSize(0, 0, .astc_4x4_rgba));
const out_buf = try testing.allocator.alloc(u8, try trans.calcTranscodedSize(0, 0, .astc_4x4_rgba));
defer testing.allocator.free(out_buf);
try trans.transcode(out_buf, 0, 0, .astc_4x4_rgba, .{});
}

0 comments on commit 5a68105

Please sign in to comment.