diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e87ed71e27f90..34d0949bda725 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - zig-version: [0.13.0] + zig-version: [0.14.0] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: diff --git a/build.zig b/build.zig index d54bb428e7aa6..11590a47dee71 100644 --- a/build.zig +++ b/build.zig @@ -5,18 +5,15 @@ pub fn build(b: *std.Build) void { const optimize = b.standardOptimizeOption(.{}); const t = target.result; - const is_android = if (@hasDecl(@TypeOf(t), "isAndroid")) t.isAndroid() else t.abi.isAndroid(); - const is_shared_library = is_android; - const lib = if (!is_shared_library) b.addStaticLibrary(.{ + const lib = b.addLibrary(.{ .name = "SDL2", - .target = target, - .optimize = optimize, - .link_libc = true, - }) else b.addSharedLibrary(.{ - .name = "SDL2", - .target = target, - .optimize = optimize, - .link_libc = true, + .version = .{ .major = 2, .minor = 32, .patch = 2 }, + .linkage = if (t.abi.isAndroid()) .dynamic else .static, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + .link_libc = true, + }), }); const sdl_include_path = b.path("include"); @@ -24,7 +21,7 @@ pub fn build(b: *std.Build) void { lib.root_module.addCMacro("SDL_USE_BUILTIN_OPENGL_DEFINITIONS", "1"); lib.root_module.addCMacro("HAVE_GCC_ATOMICS", "1"); lib.root_module.addCMacro("HAVE_GCC_SYNC_LOCK_TEST_AND_SET", "1"); - lib.linkLibC(); + switch (t.os.tag) { .windows => { lib.root_module.addCMacro("SDL_STATIC_LIB", ""); @@ -75,7 +72,7 @@ pub fn build(b: *std.Build) void { lib.addIncludePath(.{ .cwd_relative = cache_include }); }, else => { - if (is_android) { + if (t.abi.isAndroid()) { lib.root_module.addCSourceFiles(.{ .files = &android_src_files, }); @@ -116,7 +113,7 @@ pub fn build(b: *std.Build) void { const use_pregenerated_config = switch (t.os.tag) { .windows, .macos, .emscripten => true, - .linux => is_android, + .linux => t.abi.isAndroid(), else => false, }; @@ -159,14 +156,14 @@ pub fn build(b: *std.Build) void { .style = .{ .cmake = b.path("include/SDL_revision.h.cmake") }, .include_path = "SDL_revision.h", }, .{ - .SDL_REVISION = "SDL-2.32.2", + .SDL_REVISION = b.fmt("SDL-{}", .{lib.version.?}), .SDL_VENDOR_INFO = "allyourcodebase.com", }); lib.addConfigHeader(revision_header); lib.installHeader(revision_header.getOutput(), "SDL2/SDL_revision.h"); } - const use_hidapi = b.option(bool, "use_hidapi", "Use hidapi shared library") orelse is_android; + const use_hidapi = b.option(bool, "use_hidapi", "Use hidapi shared library") orelse t.abi.isAndroid(); if (use_hidapi) { const hidapi_lib = b.addSharedLibrary(.{ diff --git a/build.zig.zon b/build.zig.zon index 1dc065ac5e5b3..81c10f8953b12 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,7 +1,8 @@ .{ - .name = "SDL", + .name = .SDL, .version = "2.32.2", - .minimum_zig_version = "0.13.0", + .fingerprint = 0x7ac4ce41df223a25, + .minimum_zig_version = "0.14.0", .dependencies = .{}, .paths = .{ "LICENSE.txt",