@@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
3333 const test_step = b .step ("test" , "Run bindings tests" );
3434 { // Test SDL2 bindings
3535 const zsdl2_tests = addTests (test_step , target , optimize , "zsdl2-tests" , "src/sdl2.zig" );
36- link_SDL2 (zsdl2_tests );
36+ link_SDL2_libs_testing (zsdl2_tests );
3737 prebuilt_sdl2 .addLibraryPathsTo (zsdl2_tests );
3838 }
3939 { // Test SDL2_ttf bindings
@@ -46,8 +46,7 @@ pub fn build(b: *std.Build) void {
4646 "zsdl2" ,
4747 zsdl2_module ,
4848 );
49- link_SDL2 (zsdl2_ttf_tests );
50- link_SDL2_ttf (zsdl2_ttf_tests );
49+ link_SDL2_libs_testing (zsdl2_ttf_tests );
5150 prebuilt_sdl2 .addLibraryPathsTo (zsdl2_ttf_tests );
5251 }
5352 { // Test SDL2_image bindings
@@ -60,13 +59,12 @@ pub fn build(b: *std.Build) void {
6059 "zsdl2" ,
6160 zsdl2_module ,
6261 );
63- link_SDL2 (zsdl2_image_tests );
64- link_SDL2_image (zsdl2_image_tests );
62+ link_SDL2_libs_testing (zsdl2_image_tests );
6563 prebuilt_sdl2 .addLibraryPathsTo (zsdl2_image_tests );
6664 }
6765 { // Test SDL3 bindings
6866 const zsdl3_tests = addTests (test_step , target , optimize , "zsdl3-tests" , "src/sdl3.zig" );
69- link_SDL3 (zsdl3_tests );
67+ link_SDL3_libs_testing (zsdl3_tests );
7068 prebuilt_sdl3 .addLibraryPathsTo (zsdl3_tests );
7169 }
7270
@@ -80,73 +78,73 @@ pub fn build(b: *std.Build) void {
8078 }
8179}
8280
83- pub fn link_SDL2 (compile_step : * std.Build.Step.Compile ) void {
81+ fn link_SDL2_libs_testing (compile_step : * std.Build.Step.Compile ) void {
8482 switch (compile_step .rootModuleTarget ().os .tag ) {
8583 .windows = > {
8684 compile_step .linkSystemLibrary ("SDL2" );
8785 compile_step .linkSystemLibrary ("SDL2main" );
86+ compile_step .linkSystemLibrary ("SDL2_ttf" );
87+ compile_step .linkSystemLibrary ("SDL2_image" );
8888 },
8989 .linux = > {
9090 compile_step .linkSystemLibrary ("SDL2" );
91+ compile_step .linkSystemLibrary ("SDL2_ttf" );
92+ compile_step .linkSystemLibrary ("SDL2_image" );
9193 compile_step .root_module .addRPathSpecial ("$ORIGIN" );
9294 },
9395 .macos = > {
9496 compile_step .linkFramework ("SDL2" );
97+ compile_step .linkFramework ("SDL2_ttf" );
98+ compile_step .linkFramework ("SDL2_image" );
9599 compile_step .root_module .addRPathSpecial ("@executable_path" );
96100 },
97101 else = > {},
98102 }
99103}
100104
101- pub fn link_SDL2_ttf (compile_step : * std.Build.Step.Compile ) void {
105+ fn link_SDL3_libs_testing (compile_step : * std.Build.Step.Compile ) void {
102106 switch (compile_step .rootModuleTarget ().os .tag ) {
103107 .windows = > {
104- compile_step .linkSystemLibrary ("SDL2_ttf " );
108+ compile_step .linkSystemLibrary ("SDL3 " );
105109 },
106110 .linux = > {
107- compile_step .linkSystemLibrary ("SDL2_ttf " );
111+ compile_step .linkSystemLibrary ("SDL3 " );
108112 compile_step .root_module .addRPathSpecial ("$ORIGIN" );
109113 },
110114 .macos = > {
111- compile_step .linkFramework ("SDL2_ttf " );
115+ compile_step .linkFramework ("SDL3 " );
112116 compile_step .root_module .addRPathSpecial ("@executable_path" );
113117 },
114118 else = > {},
115119 }
116120}
117121
122+ pub fn link_SDL2 (compile_step : * std.Build.Step.Compile ) void {
123+ _ = compile_step ;
124+ @compileError ("link_SDL2 no longer supported. Refer to README for linking instructions." );
125+
126+ // link_SDL2 is no longer supported for linking, as it assumes too much
127+ // about the build environment. You should instead copy the relevant link
128+ // calls from the README into your build.zig file and adjust as necessary.
129+ }
130+
131+ pub fn link_SDL2_ttf (compile_step : * std.Build.Step.Compile ) void {
132+ _ = compile_step ;
133+ @compileError ("link_SDL2_ttf no longer supported. Refer to README for linking instructions." );
134+ }
135+
118136pub fn link_SDL2_image (compile_step : * std.Build.Step.Compile ) void {
119- switch (compile_step .rootModuleTarget ().os .tag ) {
120- .windows = > {
121- compile_step .linkSystemLibrary ("SDL2_image" );
122- },
123- .linux = > {
124- compile_step .linkSystemLibrary ("SDL2_image" );
125- compile_step .root_module .addRPathSpecial ("$ORIGIN" );
126- },
127- .macos = > {
128- compile_step .linkFramework ("SDL2_image" );
129- compile_step .root_module .addRPathSpecial ("@executable_path" );
130- },
131- else = > {},
132- }
137+ _ = compile_step ;
138+ @compileError ("link_SDL2_image no longer supported. Refer to README for linking instructions." );
133139}
134140
135141pub fn link_SDL3 (compile_step : * std.Build.Step.Compile ) void {
136- switch (compile_step .rootModuleTarget ().os .tag ) {
137- .windows = > {
138- compile_step .linkSystemLibrary ("SDL3" );
139- },
140- .linux = > {
141- compile_step .linkSystemLibrary ("SDL3" );
142- compile_step .root_module .addRPathSpecial ("$ORIGIN" );
143- },
144- .macos = > {
145- compile_step .linkFramework ("SDL3" );
146- compile_step .root_module .addRPathSpecial ("@executable_path" );
147- },
148- else = > {},
149- }
142+ _ = compile_step ;
143+ @compileError ("link_SDL3 no longer supported. Refer to README for linking instructions." );
144+
145+ // link_SDL3 is no longer supported for linking, as it assumes too much
146+ // about the build environment. You should instead copy the relevant link
147+ // calls from the README into your build.zig file and adjust as necessary.
150148}
151149
152150pub fn testVersionCheckSDL2 (b : * std.Build , target : std.Build.ResolvedTarget ) * std.Build.Step {
@@ -159,7 +157,7 @@ pub fn testVersionCheckSDL2(b: *std.Build, target: std.Build.ResolvedTarget) *st
159157 }),
160158 });
161159
162- link_SDL2 (test_sdl2_version_check );
160+ link_SDL2_libs_testing (test_sdl2_version_check );
163161
164162 prebuilt_sdl2 .addLibraryPathsTo (test_sdl2_version_check );
165163
@@ -391,7 +389,7 @@ fn addTests(
391389 .optimize = optimize ,
392390 }),
393391 });
394- b . installArtifact (tests );
392+ const install = b . addInstallArtifact (tests , .{} );
395393
396394 const run = b .addRunArtifact (tests );
397395 if (target .result .os .tag == .windows ) {
@@ -400,6 +398,7 @@ fn addTests(
400398 });
401399 }
402400
401+ run .step .dependOn (& install .step );
403402 test_step .dependOn (& run .step );
404403 return tests ;
405404}
0 commit comments