diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2438ee74..75d58e76 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 97524805..e1763681 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,17 @@ 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); + try b.modules.putNoClobber(b.graph.arena, "sdl3", translator.mod); // Add the example const example = b.addExecutable(.{ @@ -136,7 +138,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 6686e866..0079b88e 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",