@@ -5,26 +5,23 @@ pub fn build(b: *std.Build) void {
5
5
const optimize = b .standardOptimizeOption (.{});
6
6
const t = target .result ;
7
7
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 (.{
11
9
.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
+ }),
20
17
});
21
18
22
19
const sdl_include_path = b .path ("include" );
23
20
lib .addCSourceFiles (.{ .files = & generic_src_files });
24
21
lib .root_module .addCMacro ("SDL_USE_BUILTIN_OPENGL_DEFINITIONS" , "1" );
25
22
lib .root_module .addCMacro ("HAVE_GCC_ATOMICS" , "1" );
26
23
lib .root_module .addCMacro ("HAVE_GCC_SYNC_LOCK_TEST_AND_SET" , "1" );
27
- lib . linkLibC ();
24
+
28
25
switch (t .os .tag ) {
29
26
.windows = > {
30
27
lib .root_module .addCMacro ("SDL_STATIC_LIB" , "" );
@@ -75,7 +72,7 @@ pub fn build(b: *std.Build) void {
75
72
lib .addIncludePath (.{ .cwd_relative = cache_include });
76
73
},
77
74
else = > {
78
- if (is_android ) {
75
+ if (t . abi . isAndroid () ) {
79
76
lib .root_module .addCSourceFiles (.{
80
77
.files = & android_src_files ,
81
78
});
@@ -116,7 +113,7 @@ pub fn build(b: *std.Build) void {
116
113
117
114
const use_pregenerated_config = switch (t .os .tag ) {
118
115
.windows , .macos , .emscripten = > true ,
119
- .linux = > is_android ,
116
+ .linux = > t . abi . isAndroid () ,
120
117
else = > false ,
121
118
};
122
119
@@ -159,14 +156,14 @@ pub fn build(b: *std.Build) void {
159
156
.style = .{ .cmake = b .path ("include/SDL_revision.h.cmake" ) },
160
157
.include_path = "SDL_revision.h" ,
161
158
}, .{
162
- .SDL_REVISION = "SDL-2.32.2" ,
159
+ .SDL_REVISION = b . fmt ( "SDL-{}" , .{ lib . version .? }) ,
163
160
.SDL_VENDOR_INFO = "allyourcodebase.com" ,
164
161
});
165
162
lib .addConfigHeader (revision_header );
166
163
lib .installHeader (revision_header .getOutput (), "SDL2/SDL_revision.h" );
167
164
}
168
165
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 () ;
170
167
171
168
if (use_hidapi ) {
172
169
const hidapi_lib = b .addSharedLibrary (.{
0 commit comments