Skip to content

Commit 4b7e95a

Browse files
author
Jay
committed
Add SDL3_mixer dependency
1 parent 1c1645b commit 4b7e95a

File tree

3 files changed

+3173
-62
lines changed

3 files changed

+3173
-62
lines changed

build.zig

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub fn build(b: *std.Build) void {
1515
add_libs(b, &target, zigimg_module);
1616

1717
const sdl_module = define_sdl_module(b, &target, &optimize);
18+
const mixer_module = define_mixer_module(b, &target, &optimize);
1819

1920
const lib_mod = b.addModule("engine", .{
2021
.root_source_file = b.path("src/engine.zig"),
@@ -25,6 +26,7 @@ pub fn build(b: *std.Build) void {
2526
lib_mod.addImport("resources", resources_module);
2627
lib_mod.addImport("zigimg", zigimg_module);
2728
lib_mod.addImport("sdl", sdl_module);
29+
lib_mod.addImport("mixer", mixer_module);
2830

2931
link_sdl_framework(b, &target, lib_mod);
3032

@@ -45,6 +47,26 @@ pub fn build(b: *std.Build) void {
4547
test_step.dependOn(&run_lib_unit_tests.step);
4648
}
4749

50+
fn define_mixer_module(
51+
b: *std.Build,
52+
target: *const std.Build.ResolvedTarget,
53+
optimize: *const std.builtin.OptimizeMode,
54+
) *std.Build.Module {
55+
const sdl_dep = b.dependency("sdl", .{});
56+
const headers2 = b.addTranslateC(.{
57+
//.root_source_file = ttf_dep.path("libs/SDL3_mixer/SDL_mixer.h"),
58+
.root_source_file = b.path("libs/SDL3_mixer/SDL_mixer.h"),
59+
.target = target.*,
60+
.optimize = optimize.*,
61+
});
62+
headers2.addIncludePath(sdl_dep.path("include"));
63+
const sdl_mix_mod = headers2.addModule("mixer");
64+
add_libs(b, target, sdl_mix_mod);
65+
add_translatec_headers(b, target, headers2);
66+
67+
return sdl_mix_mod;
68+
}
69+
4870
/// Build an SDL module from the SDL3 and SDL3_ttf header files that we
4971
/// import as dependencies from zig packages that contain these headers.
5072
fn define_sdl_module(

0 commit comments

Comments
 (0)