@@ -56,7 +56,7 @@ pub fn build(b: *std.Build) void {
5656 b .installArtifact (glfw );
5757 glfw .installHeadersDirectory (b .path ("libs/glfw/include" ), "" , .{});
5858
59- glfw . addIncludePath ( b . path ( "libs/ glfw/include" ) );
59+ addIncludePaths ( b , glfw , target , options );
6060 glfw .linkLibC ();
6161
6262 const src_dir = "libs/glfw/src/" ;
@@ -205,14 +205,30 @@ pub fn build(b: *std.Build) void {
205205 },
206206 else = > {},
207207 }
208+ addIncludePaths (b , module , target , options );
208209
209- module .addIncludePath (b .path ("libs/glfw/include" ));
210+ const test_step = b .step ("test" , "Run zglfw tests" );
211+ const tests = b .addTest (.{
212+ .name = "zglfw-tests" ,
213+ .root_source_file = b .path ("src/zglfw.zig" ),
214+ .target = target ,
215+ .optimize = optimize ,
216+ });
217+ addIncludePaths (b , tests , target , options );
218+ tests .root_module .addImport ("zglfw_options" , options_module );
219+ tests .linkLibrary (glfw );
220+ b .installArtifact (tests );
221+ test_step .dependOn (& b .addRunArtifact (tests ).step );
222+ }
223+
224+ fn addIncludePaths (b : * std.Build , unit : anytype , target : anytype , options : anytype ) void {
225+ unit .addIncludePath (b .path ("libs/glfw/include" ));
210226 switch (target .result .os .tag ) {
211227 .linux = > {
212228 if (b .lazyDependency ("system_sdk" , .{})) | system_sdk | {
213- module .addSystemIncludePath (system_sdk .path ("linux/include" ));
229+ unit .addSystemIncludePath (system_sdk .path ("linux/include" ));
214230 if (options .enable_wayland ) {
215- glfw .addSystemIncludePath (system_sdk .path ("linux/include/wayland" ));
231+ unit .addSystemIncludePath (system_sdk .path ("linux/include/wayland" ));
216232 }
217233 }
218234 },
0 commit comments