@@ -33,7 +33,7 @@ pub fn build(b: *std.Build) void {
33
33
const test_step = b .step ("test" , "Run bindings tests" );
34
34
{ // Test SDL2 bindings
35
35
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 );
37
37
prebuilt_sdl2 .addLibraryPathsTo (zsdl2_tests );
38
38
}
39
39
{ // Test SDL2_ttf bindings
@@ -46,8 +46,7 @@ pub fn build(b: *std.Build) void {
46
46
"zsdl2" ,
47
47
zsdl2_module ,
48
48
);
49
- link_SDL2 (zsdl2_ttf_tests );
50
- link_SDL2_ttf (zsdl2_ttf_tests );
49
+ link_SDL2_libs_testing (zsdl2_ttf_tests );
51
50
prebuilt_sdl2 .addLibraryPathsTo (zsdl2_ttf_tests );
52
51
}
53
52
{ // Test SDL2_image bindings
@@ -60,13 +59,12 @@ pub fn build(b: *std.Build) void {
60
59
"zsdl2" ,
61
60
zsdl2_module ,
62
61
);
63
- link_SDL2 (zsdl2_image_tests );
64
- link_SDL2_image (zsdl2_image_tests );
62
+ link_SDL2_libs_testing (zsdl2_image_tests );
65
63
prebuilt_sdl2 .addLibraryPathsTo (zsdl2_image_tests );
66
64
}
67
65
{ // Test SDL3 bindings
68
66
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 );
70
68
prebuilt_sdl3 .addLibraryPathsTo (zsdl3_tests );
71
69
}
72
70
@@ -80,73 +78,73 @@ pub fn build(b: *std.Build) void {
80
78
}
81
79
}
82
80
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 {
84
82
switch (compile_step .rootModuleTarget ().os .tag ) {
85
83
.windows = > {
86
84
compile_step .linkSystemLibrary ("SDL2" );
87
85
compile_step .linkSystemLibrary ("SDL2main" );
86
+ compile_step .linkSystemLibrary ("SDL2_ttf" );
87
+ compile_step .linkSystemLibrary ("SDL2_image" );
88
88
},
89
89
.linux = > {
90
90
compile_step .linkSystemLibrary ("SDL2" );
91
+ compile_step .linkSystemLibrary ("SDL2_ttf" );
92
+ compile_step .linkSystemLibrary ("SDL2_image" );
91
93
compile_step .root_module .addRPathSpecial ("$ORIGIN" );
92
94
},
93
95
.macos = > {
94
96
compile_step .linkFramework ("SDL2" );
97
+ compile_step .linkFramework ("SDL2_ttf" );
98
+ compile_step .linkFramework ("SDL2_image" );
95
99
compile_step .root_module .addRPathSpecial ("@executable_path" );
96
100
},
97
101
else = > {},
98
102
}
99
103
}
100
104
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 {
102
106
switch (compile_step .rootModuleTarget ().os .tag ) {
103
107
.windows = > {
104
- compile_step .linkSystemLibrary ("SDL2_ttf " );
108
+ compile_step .linkSystemLibrary ("SDL3 " );
105
109
},
106
110
.linux = > {
107
- compile_step .linkSystemLibrary ("SDL2_ttf " );
111
+ compile_step .linkSystemLibrary ("SDL3 " );
108
112
compile_step .root_module .addRPathSpecial ("$ORIGIN" );
109
113
},
110
114
.macos = > {
111
- compile_step .linkFramework ("SDL2_ttf " );
115
+ compile_step .linkFramework ("SDL3 " );
112
116
compile_step .root_module .addRPathSpecial ("@executable_path" );
113
117
},
114
118
else = > {},
115
119
}
116
120
}
117
121
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
+
118
136
pub 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." );
133
139
}
134
140
135
141
pub 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.
150
148
}
151
149
152
150
pub 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
159
157
}),
160
158
});
161
159
162
- link_SDL2 (test_sdl2_version_check );
160
+ link_SDL2_libs_testing (test_sdl2_version_check );
163
161
164
162
prebuilt_sdl2 .addLibraryPathsTo (test_sdl2_version_check );
165
163
@@ -391,7 +389,7 @@ fn addTests(
391
389
.optimize = optimize ,
392
390
}),
393
391
});
394
- b . installArtifact (tests );
392
+ const install = b . addInstallArtifact (tests , .{} );
395
393
396
394
const run = b .addRunArtifact (tests );
397
395
if (target .result .os .tag == .windows ) {
@@ -400,6 +398,7 @@ fn addTests(
400
398
});
401
399
}
402
400
401
+ run .step .dependOn (& install .step );
403
402
test_step .dependOn (& run .step );
404
403
return tests ;
405
404
}
0 commit comments