i think we cracked the code on getting some linux builds working

This commit is contained in:
peterino2 2025-06-07 15:20:52 -07:00
parent ea14d8941d
commit a7505acf8b
2 changed files with 21 additions and 3 deletions

View File

@ -11,7 +11,7 @@ pub const revision = formatted_version ++ " (" ++ vendor_info ++ ")";
pub fn build(b: *std.Build) void { pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
var preferred_linkage: std.builtin.LinkMode = b.option( const preferred_linkage: std.builtin.LinkMode = b.option(
std.builtin.LinkMode, std.builtin.LinkMode,
"preferred_linkage", "preferred_linkage",
"Prefer building statically or dynamically linked libraries (default: static)", "Prefer building statically or dynamically linked libraries (default: static)",
@ -21,7 +21,6 @@ pub fn build(b: *std.Build) void {
"Deprecated; use 'preferred_linkage' instead", "Deprecated; use 'preferred_linkage' instead",
) orelse .static; ) orelse .static;
preferred_linkage = .dynamic;
const strip = b.option( const strip = b.option(
bool, bool,
"strip", "strip",
@ -546,7 +545,7 @@ pub fn build(b: *std.Build) void {
.pic = pic, .pic = pic,
}); });
const sdl_lib = b.addLibrary(.{ const sdl_lib = b.addLibrary(.{
.linkage = .dynamic, //if (emscripten) .static else preferred_linkage, .linkage = if (emscripten) .static else preferred_linkage,
.name = "SDL3", .name = "SDL3",
.root_module = sdl_mod, .root_module = sdl_mod,
.version = .{ .version = .{

19
lib/sdl3/build.zig vendored
View File

@ -42,9 +42,28 @@ pub fn build(b: *std.Build) void {
const target = b.standardTargetOptions(.{}); const target = b.standardTargetOptions(.{});
const optimize = b.standardOptimizeOption(.{}); const optimize = b.standardOptimizeOption(.{});
var linux = false;
var windows = false;
var macos = false;
switch (target.result.os.tag) {
.windows => {
windows = true;
},
.linux => {
linux = true;
},
.macos => {
macos = true;
},
else => {},
}
const preferred_linkage: std.builtin.LinkMode = if (linux) .static else .dynamic;
const sdl_dep = b.dependency("sdl", .{ const sdl_dep = b.dependency("sdl", .{
.target = target, .target = target,
.optimize = optimize, .optimize = optimize,
.preferred_linkage = preferred_linkage,
}); });
const sdl3_lib = sdl_dep.artifact("SDL3"); const sdl3_lib = sdl_dep.artifact("SDL3");