@@ -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