Skip to content

Commit 4508072

Browse files
switch to translate-c for SDL2 to avoid use of "usingnamespace" (#21)
1 parent f0dad83 commit 4508072

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

examples/sdl2/third-party/sdl2/build.zig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,24 @@ pub fn build(b: *std.Build) !void {
169169
// lib.installHeadersDirectory("include", "SDL");
170170
b.installArtifact(lib);
171171

172-
var module = b.addModule("sdl", .{
172+
var sdl_c_module = b.addTranslateC(.{
173+
// NOTE(jae): 2025-03-13
174+
// Using host target platform to avoid include errors when targetting Android
175+
// Otherwise we get errors like: 'sys/types.h' file not found
173176
.target = b.graph.host,
174177
.optimize = .ReleaseFast,
175-
.root_source_file = b.path("src/sdl.zig"),
178+
.root_source_file = b.path("src/sdl.h"),
176179
});
177180
if (sdl_config_header) |config_header| {
178-
module.addConfigHeader(config_header);
181+
sdl_c_module.addConfigHeader(config_header);
179182
}
180-
module.addIncludePath(sdl_include_path);
183+
sdl_c_module.addIncludePath(sdl_include_path);
184+
185+
_ = b.addModule("sdl", .{
186+
.target = target,
187+
.optimize = optimize,
188+
.root_source_file = sdl_c_module.getOutput(),
189+
});
181190
}
182191

183192
const generic_src_files = [_][]const u8{
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#include <SDL.h>

examples/sdl2/third-party/sdl2/src/sdl.zig

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)