diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 171b570a0..b171de32c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -12,7 +12,6 @@ jobs: strategy: fail-fast: false matrix: - zig-version: [0.15.1] os: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.os }} steps: @@ -27,8 +26,6 @@ jobs: - name: Setup Zig uses: mlugg/setup-zig@v2 - with: - version: ${{ matrix.zig-version }} - name: Check Formatting run: zig fmt --ast-check --check . diff --git a/build.zig b/build.zig index 37d675c95..15bfecb8d 100644 --- a/build.zig +++ b/build.zig @@ -8,73 +8,75 @@ pub fn build(b: *std.Build) void { const upstream = b.dependency("SDL_image", .{}); + const mod = b.createModule(.{ + .target = target, + .optimize = optimize, + .link_libc = true, + .sanitize_c = sanitize_c, + }); + const lib = b.addLibrary(.{ .name = "SDL3_image", .version = .{ .major = 3, .minor = 2, .patch = 0 }, .linkage = .static, - .root_module = b.createModule(.{ - .target = target, - .optimize = optimize, - .link_libc = true, - .sanitize_c = sanitize_c, - }), + .root_module = mod, }); const sdl = b.dependency("SDL", .{ .target = target, .optimize = optimize, }).artifact("SDL3"); - lib.linkLibrary(sdl); + mod.linkLibrary(sdl); // Use stb_image for loading JPEG and PNG files. Native alternatives such as // Windows Imaging Component and Apple's Image I/O framework are not yet // supported by this build script. - lib.root_module.addCMacro("USE_STBIMAGE", ""); + mod.addCMacro("USE_STBIMAGE", ""); // The following are options for supported file formats. AVIF, JXL, TIFF, // and WebP are not yet supported by this build script, as they require // additional dependencies. if (b.option(bool, "enable-bmp", "Support loading BMP images") orelse true) - lib.root_module.addCMacro("LOAD_BMP", ""); + mod.addCMacro("LOAD_BMP", ""); if (b.option(bool, "enable-gif", "Support loading GIF images") orelse true) - lib.root_module.addCMacro("LOAD_GIF", ""); + mod.addCMacro("LOAD_GIF", ""); if (b.option(bool, "enable-jpg", "Support loading JPEG images") orelse true) - lib.root_module.addCMacro("LOAD_JPG", ""); + mod.addCMacro("LOAD_JPG", ""); if (b.option(bool, "enable-lbm", "Support loading LBM images") orelse true) - lib.root_module.addCMacro("LOAD_LBM", ""); + mod.addCMacro("LOAD_LBM", ""); if (b.option(bool, "enable-pcx", "Support loading PCX images") orelse true) - lib.root_module.addCMacro("LOAD_PCX", ""); + mod.addCMacro("LOAD_PCX", ""); if (b.option(bool, "enable-png", "Support loading PNG images") orelse true) - lib.root_module.addCMacro("LOAD_PNG", ""); + mod.addCMacro("LOAD_PNG", ""); if (b.option(bool, "enable-pnm", "Support loading PNM images") orelse true) - lib.root_module.addCMacro("LOAD_PNM", ""); + mod.addCMacro("LOAD_PNM", ""); if (b.option(bool, "enable-qoi", "Support loading QOI images") orelse true) - lib.root_module.addCMacro("LOAD_QOI", ""); + mod.addCMacro("LOAD_QOI", ""); if (b.option(bool, "enable-svg", "Support loading SVG images") orelse true) - lib.root_module.addCMacro("LOAD_SVG", ""); + mod.addCMacro("LOAD_SVG", ""); if (b.option(bool, "enable-tga", "Support loading TGA images") orelse true) - lib.root_module.addCMacro("LOAD_TGA", ""); + mod.addCMacro("LOAD_TGA", ""); if (b.option(bool, "enable-xcf", "Support loading XCF images") orelse true) - lib.root_module.addCMacro("LOAD_XCF", ""); + mod.addCMacro("LOAD_XCF", ""); if (b.option(bool, "enable-xpm", "Support loading XPM images") orelse true) - lib.root_module.addCMacro("LOAD_XPM", ""); + mod.addCMacro("LOAD_XPM", ""); if (b.option(bool, "enable-xv", "Support loading XV images") orelse true) - lib.root_module.addCMacro("LOAD_XV", ""); + mod.addCMacro("LOAD_XV", ""); - lib.addIncludePath(upstream.path("include")); - lib.addIncludePath(upstream.path("src")); + mod.addIncludePath(upstream.path("include")); + mod.addIncludePath(upstream.path("src")); - lib.addCSourceFiles(.{ + mod.addCSourceFiles(.{ .root = upstream.path("src"), .files = srcs, }); if (target.result.os.tag == .macos) { - lib.addCSourceFile(.{ + mod.addCSourceFile(.{ .file = upstream.path("src/IMG_ImageIO.m"), }); - lib.linkFramework("Foundation"); - lib.linkFramework("ApplicationServices"); + mod.linkFramework("Foundation", .{}); + mod.linkFramework("ApplicationServices", .{}); } lib.installHeadersDirectory(upstream.path("include"), "", .{});