Skip to content

Commit 6c5861b

Browse files
committed
Install prebuilt libs if deps exist
1 parent 33e4e41 commit 6c5861b

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

build.zig

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ pub fn build(b: *std.Build) void {
6464
const zsdl3_tests = addTests(test_step, target, optimize, "zsdl3-tests", "src/sdl3.zig");
6565
link_SDL3(zsdl3_tests);
6666
}
67+
68+
if (prebuilt.install_SDL2(b, target.result, .bin)) |install_sdl2_step| {
69+
b.getInstallStep().dependOn(install_sdl2_step);
70+
}
71+
if (prebuilt.install_SDL2_ttf(b, target.result, .bin)) |install_sdl2_ttf_step| {
72+
b.getInstallStep().dependOn(install_sdl2_ttf_step);
73+
}
74+
if (prebuilt.install_SDL2_image(b, target.result, .bin)) |install_sdl2_image_step| {
75+
b.getInstallStep().dependOn(install_sdl2_image_step);
76+
}
77+
if (prebuilt.install_SDL3(b, target.result, .bin)) |install_sdl3_step| {
78+
b.getInstallStep().dependOn(install_sdl3_step);
79+
}
6780
}
6881

6982
pub fn link_SDL2(compile_step: *std.Build.Step.Compile) void {
@@ -326,6 +339,48 @@ pub const prebuilt = struct {
326339
}
327340
return null;
328341
}
342+
343+
pub fn install_SDL3(
344+
b: *std.Build,
345+
target: std.Target,
346+
install_dir: std.Build.InstallDir,
347+
) ?*std.Build.Step {
348+
switch (target.os.tag) {
349+
.windows => {
350+
if (target.cpu.arch.isX86()) {
351+
if (b.lazyDependency("sdl3-prebuilt-x86_64-windows-gnu", .{})) |sdl3_prebuilt| {
352+
return &b.addInstallFileWithDir(
353+
sdl3_prebuilt.path("bin/SDL3.dll"),
354+
install_dir,
355+
"SDL2.dll",
356+
).step;
357+
}
358+
}
359+
},
360+
.linux => {
361+
if (target.cpu.arch.isX86()) {
362+
if (b.lazyDependency("sdl3-prebuilt-x86_64-linux-gnu", .{})) |sdl3_prebuilt| {
363+
return &b.addInstallFileWithDir(
364+
sdl3_prebuilt.path("lib/libSDL3.so"),
365+
install_dir,
366+
"libSDL2.so",
367+
).step;
368+
}
369+
}
370+
},
371+
.macos => {
372+
if (b.lazyDependency("sdl3-prebuilt-macos", .{})) |sdl3_prebuilt| {
373+
return &b.addInstallDirectory(.{
374+
.source_dir = sdl3_prebuilt.path("Frameworks/SDL3.framework"),
375+
.install_dir = install_dir,
376+
.install_subdir = "SDL3.framework",
377+
}).step;
378+
}
379+
},
380+
else => {},
381+
}
382+
return null;
383+
}
329384
};
330385

331386
fn addTests(

0 commit comments

Comments
 (0)