Skip to content

Commit aab5701

Browse files
committed
Fix build for Zig 0.16.0-dev.1657+985a3565c, drop 0.14.x support
1 parent ee89d33 commit aab5701

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

.github/workflows/ci.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jobs:
1212
strategy:
1313
fail-fast: false
1414
matrix:
15-
zig-version: [0.15.1]
1615
os: [ubuntu-latest, macos-latest, windows-latest]
1716
runs-on: ${{ matrix.os }}
1817
steps:
@@ -27,8 +26,6 @@ jobs:
2726
2827
- name: Setup Zig
2928
uses: mlugg/setup-zig@v2
30-
with:
31-
version: ${{ matrix.zig-version }}
3229

3330
- name: Check Formatting
3431
run: zig fmt --ast-check --check .

build.zig

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,73 +8,75 @@ pub fn build(b: *std.Build) void {
88

99
const upstream = b.dependency("SDL_image", .{});
1010

11+
const mod = b.createModule(.{
12+
.target = target,
13+
.optimize = optimize,
14+
.link_libc = true,
15+
.sanitize_c = sanitize_c,
16+
});
17+
1118
const lib = b.addLibrary(.{
1219
.name = "SDL3_image",
1320
.version = .{ .major = 3, .minor = 2, .patch = 0 },
1421
.linkage = .static,
15-
.root_module = b.createModule(.{
16-
.target = target,
17-
.optimize = optimize,
18-
.link_libc = true,
19-
.sanitize_c = sanitize_c,
20-
}),
22+
.root_module = mod,
2123
});
2224

2325
const sdl = b.dependency("SDL", .{
2426
.target = target,
2527
.optimize = optimize,
2628
}).artifact("SDL3");
27-
lib.linkLibrary(sdl);
29+
mod.linkLibrary(sdl);
2830

2931
// Use stb_image for loading JPEG and PNG files. Native alternatives such as
3032
// Windows Imaging Component and Apple's Image I/O framework are not yet
3133
// supported by this build script.
32-
lib.root_module.addCMacro("USE_STBIMAGE", "");
34+
mod.addCMacro("USE_STBIMAGE", "");
3335

3436
// The following are options for supported file formats. AVIF, JXL, TIFF,
3537
// and WebP are not yet supported by this build script, as they require
3638
// additional dependencies.
3739
if (b.option(bool, "enable-bmp", "Support loading BMP images") orelse true)
38-
lib.root_module.addCMacro("LOAD_BMP", "");
40+
mod.addCMacro("LOAD_BMP", "");
3941
if (b.option(bool, "enable-gif", "Support loading GIF images") orelse true)
40-
lib.root_module.addCMacro("LOAD_GIF", "");
42+
mod.addCMacro("LOAD_GIF", "");
4143
if (b.option(bool, "enable-jpg", "Support loading JPEG images") orelse true)
42-
lib.root_module.addCMacro("LOAD_JPG", "");
44+
mod.addCMacro("LOAD_JPG", "");
4345
if (b.option(bool, "enable-lbm", "Support loading LBM images") orelse true)
44-
lib.root_module.addCMacro("LOAD_LBM", "");
46+
mod.addCMacro("LOAD_LBM", "");
4547
if (b.option(bool, "enable-pcx", "Support loading PCX images") orelse true)
46-
lib.root_module.addCMacro("LOAD_PCX", "");
48+
mod.addCMacro("LOAD_PCX", "");
4749
if (b.option(bool, "enable-png", "Support loading PNG images") orelse true)
48-
lib.root_module.addCMacro("LOAD_PNG", "");
50+
mod.addCMacro("LOAD_PNG", "");
4951
if (b.option(bool, "enable-pnm", "Support loading PNM images") orelse true)
50-
lib.root_module.addCMacro("LOAD_PNM", "");
52+
mod.addCMacro("LOAD_PNM", "");
5153
if (b.option(bool, "enable-qoi", "Support loading QOI images") orelse true)
52-
lib.root_module.addCMacro("LOAD_QOI", "");
54+
mod.addCMacro("LOAD_QOI", "");
5355
if (b.option(bool, "enable-svg", "Support loading SVG images") orelse true)
54-
lib.root_module.addCMacro("LOAD_SVG", "");
56+
mod.addCMacro("LOAD_SVG", "");
5557
if (b.option(bool, "enable-tga", "Support loading TGA images") orelse true)
56-
lib.root_module.addCMacro("LOAD_TGA", "");
58+
mod.addCMacro("LOAD_TGA", "");
5759
if (b.option(bool, "enable-xcf", "Support loading XCF images") orelse true)
58-
lib.root_module.addCMacro("LOAD_XCF", "");
60+
mod.addCMacro("LOAD_XCF", "");
5961
if (b.option(bool, "enable-xpm", "Support loading XPM images") orelse true)
60-
lib.root_module.addCMacro("LOAD_XPM", "");
62+
mod.addCMacro("LOAD_XPM", "");
6163
if (b.option(bool, "enable-xv", "Support loading XV images") orelse true)
62-
lib.root_module.addCMacro("LOAD_XV", "");
64+
mod.addCMacro("LOAD_XV", "");
6365

64-
lib.addIncludePath(upstream.path("include"));
65-
lib.addIncludePath(upstream.path("src"));
66+
mod.addIncludePath(upstream.path("include"));
67+
mod.addIncludePath(upstream.path("src"));
6668

67-
lib.addCSourceFiles(.{
69+
mod.addCSourceFiles(.{
6870
.root = upstream.path("src"),
6971
.files = srcs,
7072
});
7173

7274
if (target.result.os.tag == .macos) {
73-
lib.addCSourceFile(.{
75+
mod.addCSourceFile(.{
7476
.file = upstream.path("src/IMG_ImageIO.m"),
7577
});
76-
lib.linkFramework("Foundation");
77-
lib.linkFramework("ApplicationServices");
78+
mod.linkFramework("Foundation", .{});
79+
mod.linkFramework("ApplicationServices", .{});
7880
}
7981

8082
lib.installHeadersDirectory(upstream.path("include"), "", .{});

0 commit comments

Comments
 (0)