From e35213d38beb07b0981bcb823b00955e20cad561 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Thu, 4 Jun 2026 20:25:07 -0700 Subject: [PATCH 1/8] Switches to external translate C package to get latest fixes resolves #22 --- .github/workflows/ci.yaml | 2 +- build.zig | 17 +++++++++-------- build.zig.zon | 6 +++++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2438ee74b..75d58e76b 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - zig-version: [0.16.0] + zig-version: [0.17.0-dev.690+c5a61e899] os: [ubuntu-latest, windows-latest, macos-latest] runs-on: ${{ matrix.os }} steps: diff --git a/build.zig b/build.zig index 975248058..a58296df8 100644 --- a/build.zig +++ b/build.zig @@ -3,6 +3,7 @@ const linux = @import("src/linux.zig"); const windows = @import("src/windows.zig"); const macos = @import("src/macos.zig"); const build_zon = @import("build.zig.zon"); +const Translator = @import("translate_c").Translator; const assert = std.debug.assert; @@ -116,16 +117,16 @@ pub fn build(b: *std.Build) !void { linux.addWaylandScannerStep(b); // Translate the SDL headers and export them as a Zig module - const translate_c = b.addTranslateC(.{ - .root_source_file = b.path("src/sdl.h"), + const translate_c = b.dependency("translate_c", .{}); + const translator: Translator = .init(translate_c, .{ + .c_source_file = b.path("src/sdl.h"), .target = target, .optimize = optimize, }); - translate_c.defineCMacro("USING_GENERATED_CONFIG_H", "1"); - translate_c.addIncludePath(upstream.path("include")); - translate_c.addIncludePath(upstream.path("src/video/khronos")); - const module = translate_c.addModule("sdl3"); - module.linkLibrary(lib); + translator.defineCMacro("USING_GENERATED_CONFIG_H", "1"); + translator.addIncludePath(upstream.path("include")); + translator.addIncludePath(upstream.path("src/video/khronos")); + translator.mod.linkLibrary(lib); // Add the example const example = b.addExecutable(.{ @@ -136,7 +137,7 @@ pub fn build(b: *std.Build) !void { .optimize = optimize, }), }); - example.root_module.addImport("sdl3", module); + example.root_module.addImport("sdl3", translator.mod); const build_example_step = b.step("example", "Build the example app"); build_example_step.dependOn(&example.step); diff --git a/build.zig.zon b/build.zig.zon index 6686e866c..0079b88ed 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -2,13 +2,17 @@ .name = .sdl, .fingerprint = 0xec638ccbd103848b, .version = "1.0.1+3.4.4", - .minimum_zig_version = "0.16.0", + .minimum_zig_version = "0.17.0", .dependencies = .{ .sdl = .{ .url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.4.4.tar.gz", .hash = "N-V-__8AAL9L9AJxY67Fhxp52_VHlLps195MF3irmi4z8Qge", .version = "3.4.4", }, + .translate_c = .{ + .url = "git+https://codeberg.org/ziglang/translate-c#c26bb176f3d63c8f3f57ac4e82d78f9124506b0d", + .hash = "translate_c-0.0.0-Q_BUWuEVBwCbZUsNorTQ6-d3nYx8KDgHHWtVWBzgzyB5", + }, .dbus = .{ .version = "1.16.0", .url = "https://gitlab.freedesktop.org/dbus/dbus/-/archive/dbus-1.16.0/dbus-dbus-1.16.0.tar.gz", From 480e7b658a45edddfc4d64cb5d616a27717ac3f1 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Thu, 4 Jun 2026 20:51:51 -0700 Subject: [PATCH 2/8] Actually export the `sdl3` module --- build.zig | 1 + 1 file changed, 1 insertion(+) diff --git a/build.zig b/build.zig index a58296df8..e1763681b 100644 --- a/build.zig +++ b/build.zig @@ -127,6 +127,7 @@ pub fn build(b: *std.Build) !void { translator.addIncludePath(upstream.path("include")); translator.addIncludePath(upstream.path("src/video/khronos")); translator.mod.linkLibrary(lib); + try b.modules.putNoClobber(b.graph.arena, "sdl3", translator.mod); // Add the example const example = b.addExecutable(.{ From 71c1ce0d1cde1b765a35de24c02292d3d36908b9 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Mon, 22 Jun 2026 16:50:35 -0700 Subject: [PATCH 3/8] Updates Translate C --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 0079b88ed..2744e61e8 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -10,8 +10,8 @@ .version = "3.4.4", }, .translate_c = .{ - .url = "git+https://codeberg.org/ziglang/translate-c#c26bb176f3d63c8f3f57ac4e82d78f9124506b0d", - .hash = "translate_c-0.0.0-Q_BUWuEVBwCbZUsNorTQ6-d3nYx8KDgHHWtVWBzgzyB5", + .url = "git+https://codeberg.org/ziglang/translate-c#1b33d1d273f7035a16c45457efdf2afda7cf0925", + .hash = "translate_c-0.0.0-Q_BUWrI7BwCBn0jcYDTs1UP047kxSYoFpV6vD6Vuy9Vo", }, .dbus = .{ .version = "1.16.0", From 309e3a0a411a5e715cd23dedcfc1d6af6d59cb5f Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Tue, 30 Jun 2026 00:55:58 -0700 Subject: [PATCH 4/8] Patches bug in Wayland animated cursor handling --- build.zig.zon | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 2744e61e8..be6774a27 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,9 +5,10 @@ .minimum_zig_version = "0.17.0", .dependencies = .{ .sdl = .{ - .url = "https://github.com/libsdl-org/SDL/archive/refs/tags/release-3.4.4.tar.gz", - .hash = "N-V-__8AAL9L9AJxY67Fhxp52_VHlLps195MF3irmi4z8Qge", - .version = "3.4.4", + // See https://github.com/libsdl-org/SDL/pull/15904 + .url = "git+https://github.com/MasonRemaley/SDL#release-3.4.4-fix-surface-sort-callback", + .hash = "N-V-__8AAMJL9AK6KoamlTcuU5MiPD_-JW3Mz0jPAMzXE0w7", + .version = "3.4.4-fix-surface-sort-callback", }, .translate_c = .{ .url = "git+https://codeberg.org/ziglang/translate-c#1b33d1d273f7035a16c45457efdf2afda7cf0925", From 99df4f139900566bb8ebcb66194e882afc8e96ed Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Tue, 30 Jun 2026 15:03:50 -0700 Subject: [PATCH 5/8] Updates to latest SDL on release branch to get Wayland surface pointer fix --- build.zig | 9 ++------- build.zig.zon | 14 +++++++++----- src/sdl.zon | 1 + 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/build.zig b/build.zig index e1763681b..2e22e5af0 100644 --- a/build.zig +++ b/build.zig @@ -36,12 +36,6 @@ pub fn build(b: *std.Build) !void { , ) orelse .static; - // Get the SO version. This is the same as the SDL version, but the major version is elided - // since it's baked into the name. This mirrors the official build process. - var sdl_so_version = comptime std.SemanticVersion.parse(build_zon.dependencies.sdl.version) catch unreachable; - assert(sdl_so_version.major == 3); - sdl_so_version.major = 0; - // Create the library const lib = b.addLibrary(.{ .name = "SDL3", @@ -51,7 +45,8 @@ pub fn build(b: *std.Build) !void { .link_libc = true, }), .linkage = linkage, - .version = sdl_so_version, + .version = comptime std.SemanticVersion.parse(build_zon.dependencies.sdl.so_version) + catch unreachable, }); switch (linkage) { .dynamic => { diff --git a/build.zig.zon b/build.zig.zon index be6774a27..5ea34551c 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,14 +1,18 @@ .{ .name = .sdl, .fingerprint = 0xec638ccbd103848b, - .version = "1.0.1+3.4.4", + .version = "1.0.1+3.4.x", .minimum_zig_version = "0.17.0", .dependencies = .{ .sdl = .{ - // See https://github.com/libsdl-org/SDL/pull/15904 - .url = "git+https://github.com/MasonRemaley/SDL#release-3.4.4-fix-surface-sort-callback", - .hash = "N-V-__8AAMJL9AK6KoamlTcuU5MiPD_-JW3Mz0jPAMzXE0w7", - .version = "3.4.4-fix-surface-sort-callback", + .url = "git+https://github.com/libsdl-org/SDL?ref=release-3.4.x#2d8ddf333ad55764d10138827434ef7fb6a02ad1", + .hash = "N-V-__8AAP499wJaqsUJUuTeTisB3PxJKFBIJRb90cpSQBVO", + .version = "3.4.x", + // This is the same as the SDL version, but the major version is elided since it's baked + // into the name. This mirrors the official build process. Additionally, it must be an + // actual semantic version, it cannot for example include "x" which is used for release + // candidates. + .so_version = "0.4.10", }, .translate_c = .{ .url = "git+https://codeberg.org/ziglang/translate-c#1b33d1d273f7035a16c45457efdf2afda7cf0925", diff --git a/src/sdl.zon b/src/sdl.zon index 2bcb9a1f0..390507fd3 100644 --- a/src/sdl.zon +++ b/src/sdl.zon @@ -376,6 +376,7 @@ "video/vivante/SDL_vivantevideo.c", "video/vivante/SDL_vivantevulkan.c", "video/wayland/SDL_waylandclipboard.c", + "video/wayland/SDL_waylandutil.c", "video/wayland/SDL_waylandcolor.c", "video/wayland/SDL_waylanddatamanager.c", "video/wayland/SDL_waylanddyn.c", From 4bfab7d7598322a6cabfaf0f62ca5ac8fbb08de0 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Tue, 30 Jun 2026 15:09:07 -0700 Subject: [PATCH 6/8] Mitigation for translate-c#327 I'll look into the issue upstream when I have time, but need to get this working in the mean time to test another project. --- build.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/build.zig b/build.zig index 2e22e5af0..7c4c5541f 100644 --- a/build.zig +++ b/build.zig @@ -116,7 +116,14 @@ pub fn build(b: *std.Build) !void { const translator: Translator = .init(translate_c, .{ .c_source_file = b.path("src/sdl.h"), .target = target, - .optimize = optimize, + // https://codeberg.org/ziglang/translate-c/issues/327 + .optimize = switch (target.result.os.tag) { + .windows => switch (optimize) { + .ReleaseSafe => .ReleaseFast, + else => optimize, + }, + else => optimize, + }, }); translator.defineCMacro("USING_GENERATED_CONFIG_H", "1"); translator.addIncludePath(upstream.path("include")); From fef02c9db24eebfca019e99c28e6318fd43b9f65 Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Tue, 30 Jun 2026 16:32:17 -0700 Subject: [PATCH 7/8] Updates Translate C --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 5ea34551c..387662473 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -15,8 +15,8 @@ .so_version = "0.4.10", }, .translate_c = .{ - .url = "git+https://codeberg.org/ziglang/translate-c#1b33d1d273f7035a16c45457efdf2afda7cf0925", - .hash = "translate_c-0.0.0-Q_BUWrI7BwCBn0jcYDTs1UP047kxSYoFpV6vD6Vuy9Vo", + .url = "git+https://codeberg.org/ziglang/translate-c#ee20d6a7366abfcb9290184cbdbb0372a08bd9cf", + .hash = "translate_c-0.0.0-Q_BUWrw7BwCthYKOQHra8x2h-TxIHPLQnRnP2WbHL9HX", }, .dbus = .{ .version = "1.16.0", From a3981af8898a6a84de9bbcc2aa7d0210f29bcb2f Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Wed, 1 Jul 2026 15:24:20 -0700 Subject: [PATCH 8/8] Updates to SDL 3.4.12 --- README.md | 2 +- build.zig.zon | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1c9f64f6c..82b1755f6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![CI](https://github.com/Games-By-Mason/sdl_zig/actions/workflows/ci.yaml/badge.svg)](https://github.com/Games-By-Mason/sdl_zig/actions) -# SDL3 Zig +# SDL Zig SDL3 ported to the Zig build system. diff --git a/build.zig.zon b/build.zig.zon index 387662473..5b19e3818 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,14 +5,14 @@ .minimum_zig_version = "0.17.0", .dependencies = .{ .sdl = .{ - .url = "git+https://github.com/libsdl-org/SDL?ref=release-3.4.x#2d8ddf333ad55764d10138827434ef7fb6a02ad1", - .hash = "N-V-__8AAP499wJaqsUJUuTeTisB3PxJKFBIJRb90cpSQBVO", - .version = "3.4.x", + .url = "git+https://github.com/libsdl-org/SDL#release-3.4.12", + .hash = "N-V-__8AAD0-9wIMzG8dsliLwybOaKczJZMCLORvnK3Bnqq4", + .version = "3.4.12", // This is the same as the SDL version, but the major version is elided since it's baked // into the name. This mirrors the official build process. Additionally, it must be an // actual semantic version, it cannot for example include "x" which is used for release // candidates. - .so_version = "0.4.10", + .so_version = "0.4.12", }, .translate_c = .{ .url = "git+https://codeberg.org/ziglang/translate-c#ee20d6a7366abfcb9290184cbdbb0372a08bd9cf",