2022-09-08 07:19:36 -07:00
const builtin = @import ( " builtin " ) ;
2021-07-06 20:53:10 -07:00
const std = @import ( " std " ) ;
2021-10-30 21:24:15 -07:00
2024-01-13 02:39:26 -07:00
pub fn build ( b : * std . Build ) ! void {
2023-02-07 19:19:47 +01:00
const optimize = b . standardOptimizeOption ( . { } ) ;
2022-07-23 16:52:34 +04:30
const target = b . standardTargetOptions ( . { } ) ;
2024-01-13 02:39:26 -07:00
const glfw_dep = b . dependency ( " glfw " , . {
2023-09-17 13:44:52 -07:00
. target = target ,
. optimize = optimize ,
} ) ;
2024-01-13 02:39:26 -07:00
const module = b . addModule ( " mach-glfw " , . {
. root_source_file = . { . path = " src/main.zig " } ,
} ) ;
module . linkLibrary ( glfw_dep . artifact ( " glfw " ) ) ;
2023-09-17 13:44:52 -07:00
const test_step = b . step ( " test " , " Run library tests " ) ;
const main_tests = b . addTest ( . {
. name = " glfw-tests " ,
. root_source_file = . { . path = " src/main.zig " } ,
. target = target ,
. optimize = optimize ,
} ) ;
2024-01-13 02:39:26 -07:00
main_tests . linkLibrary ( glfw_dep . artifact ( " glfw " ) ) ;
addPaths ( main_tests ) ;
2023-09-17 13:44:52 -07:00
b . installArtifact ( main_tests ) ;
2023-08-08 19:12:40 -07:00
2023-09-17 13:44:52 -07:00
test_step . dependOn ( & b . addRunArtifact ( main_tests ) . step ) ;
2023-07-06 22:30:29 -07:00
}
2023-08-04 12:35:30 -07:00
2024-01-12 14:18:38 -07:00
pub fn link ( b : * std . Build , step : * std . Build . Step . Compile ) void {
2024-01-13 02:39:26 -07:00
_ = b ;
_ = step ;
@panic ( " .link(b, step) has been replaced by .addPaths(step) " ) ;
}
pub fn addPaths ( step : * std . Build . Step . Compile ) void {
@import ( " glfw " ) . addPaths ( step ) ;
2023-08-04 12:35:30 -07:00
}
2024-01-13 02:59:21 -07:00
comptime {
2024-01-14 18:28:22 -07:00
const supported_zig = std . SemanticVersion . parse ( " 0.12.0-dev.2063+804cee3b9 " ) catch unreachable ;
if ( builtin . zig_version . order ( supported_zig ) ! = . eq ) {
2024-01-13 02:59:21 -07:00
@compileError ( std . fmt . comptimePrint ( " unsupported Zig version ({}). Required Zig version 2024.1.0-mach: https://machengine.org/about/nominated-zig/#202410-mach " , . { builtin . zig_version } ) ) ;
}
}