@@ -5,26 +5,23 @@ pub fn build(b: *std.Build) void {
55 const optimize = b .standardOptimizeOption (.{});
66 const t = target .result ;
77
8- const is_android = if (@hasDecl (@TypeOf (t ), "isAndroid" )) t .isAndroid () else t .abi .isAndroid ();
9- const is_shared_library = is_android ;
10- const lib = if (! is_shared_library ) b .addStaticLibrary (.{
8+ const lib = b .addLibrary (.{
119 .name = "SDL2" ,
12- .target = target ,
13- .optimize = optimize ,
14- .link_libc = true ,
15- }) else b .addSharedLibrary (.{
16- .name = "SDL2" ,
17- .target = target ,
18- .optimize = optimize ,
19- .link_libc = true ,
10+ .version = .{ .major = 2 , .minor = 32 , .patch = 2 },
11+ .linkage = if (t .abi .isAndroid ()) .dynamic else .static ,
12+ .root_module = b .createModule (.{
13+ .target = target ,
14+ .optimize = optimize ,
15+ .link_libc = true ,
16+ }),
2017 });
2118
2219 const sdl_include_path = b .path ("include" );
2320 lib .addCSourceFiles (.{ .files = & generic_src_files });
2421 lib .root_module .addCMacro ("SDL_USE_BUILTIN_OPENGL_DEFINITIONS" , "1" );
2522 lib .root_module .addCMacro ("HAVE_GCC_ATOMICS" , "1" );
2623 lib .root_module .addCMacro ("HAVE_GCC_SYNC_LOCK_TEST_AND_SET" , "1" );
27- lib . linkLibC ();
24+
2825 switch (t .os .tag ) {
2926 .windows = > {
3027 lib .root_module .addCMacro ("SDL_STATIC_LIB" , "" );
@@ -75,7 +72,7 @@ pub fn build(b: *std.Build) void {
7572 lib .addIncludePath (.{ .cwd_relative = cache_include });
7673 },
7774 else = > {
78- if (is_android ) {
75+ if (t . abi . isAndroid () ) {
7976 lib .root_module .addCSourceFiles (.{
8077 .files = & android_src_files ,
8178 });
@@ -116,7 +113,7 @@ pub fn build(b: *std.Build) void {
116113
117114 const use_pregenerated_config = switch (t .os .tag ) {
118115 .windows , .macos , .emscripten = > true ,
119- .linux = > is_android ,
116+ .linux = > t . abi . isAndroid () ,
120117 else = > false ,
121118 };
122119
@@ -159,14 +156,14 @@ pub fn build(b: *std.Build) void {
159156 .style = .{ .cmake = b .path ("include/SDL_revision.h.cmake" ) },
160157 .include_path = "SDL_revision.h" ,
161158 }, .{
162- .SDL_REVISION = "SDL-2.32.2" ,
159+ .SDL_REVISION = b . fmt ( "SDL-{}" , .{ lib . version .? }) ,
163160 .SDL_VENDOR_INFO = "allyourcodebase.com" ,
164161 });
165162 lib .addConfigHeader (revision_header );
166163 lib .installHeader (revision_header .getOutput (), "SDL2/SDL_revision.h" );
167164 }
168165
169- const use_hidapi = b .option (bool , "use_hidapi" , "Use hidapi shared library" ) orelse is_android ;
166+ const use_hidapi = b .option (bool , "use_hidapi" , "Use hidapi shared library" ) orelse t . abi . isAndroid () ;
170167
171168 if (use_hidapi ) {
172169 const hidapi_lib = b .addSharedLibrary (.{
0 commit comments