Skip to content

Commit 88d9713

Browse files
committed
Try to fix natives multiarch build
Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
1 parent f853267 commit 88d9713

1 file changed

Lines changed: 16 additions & 13 deletions

File tree

src/Raylib.NET.Native/build.zig

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,29 @@ pub fn build(b: *std.Build) !void {
3737
const raylib = raylib_dep.artifact("raylib");
3838

3939
// Add platform-specific include/library paths for cross-compiling
40-
// Note: On Ubuntu/Debian, cross-compilation libraries are installed in multiarch paths.
41-
// On other distros (like Arch), these paths don't exist and Zig will warn but continue.
42-
// The warnings are cosmetic and don't affect the build - standard paths are added first.
40+
// Due to *terrible* zig default behaviour for include paths when cross-compiling I have to do this
41+
// The includes are resolved properly only when -Dtarget=native (or omitted) is passed
4342
switch (target.result.os.tag) {
4443
.linux => {
45-
// Add standard paths that work on all distros
46-
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
47-
raylib.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
48-
49-
// Add Ubuntu/Debian multiarch paths for cross-compilation
50-
// These are needed for CI builds on Ubuntu when cross-compiling to different architectures
5144
if (target.result.cpu.arch == .aarch64) {
5245
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib/aarch64-linux-gnu/" });
5346
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/aarch64-linux-gnu/" });
47+
raylib.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
5448
} else if (target.result.cpu.arch == .x86) {
5549
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib/i386-linux-gnu/" });
5650
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/i386-linux-gnu/" });
51+
raylib.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
5752
// https://github.com/ziglang/zig/issues/7935
5853
raylib.link_z_notext = true;
5954
} else if (target.result.cpu.arch == .x86_64) {
6055
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib/x86_64-linux-gnu/" });
6156
raylib.addIncludePath(.{ .cwd_relative = "/usr/include/x86_64-linux-gnu/" });
57+
raylib.addIncludePath(.{ .cwd_relative = "/usr/include" });
58+
} else {
59+
raylib.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
6260
}
61+
62+
raylib.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
6363
},
6464
else => {},
6565
}
@@ -98,21 +98,24 @@ pub fn build(b: *std.Build) !void {
9898
// Add same platform-specific paths for static lib
9999
switch (target.result.os.tag) {
100100
.linux => {
101-
raylib_static.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
102-
raylib_static.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
103-
104-
// Add multiarch paths for cross-compilation
105101
if (target.result.cpu.arch == .aarch64) {
106102
raylib_static.addLibraryPath(.{ .cwd_relative = "/usr/lib/aarch64-linux-gnu/" });
107103
raylib_static.addIncludePath(.{ .cwd_relative = "/usr/include/aarch64-linux-gnu/" });
104+
raylib_static.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
108105
} else if (target.result.cpu.arch == .x86) {
109106
raylib_static.addLibraryPath(.{ .cwd_relative = "/usr/lib/i386-linux-gnu/" });
110107
raylib_static.addIncludePath(.{ .cwd_relative = "/usr/include/i386-linux-gnu/" });
108+
raylib_static.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
111109
raylib_static.link_z_notext = true;
112110
} else if (target.result.cpu.arch == .x86_64) {
113111
raylib_static.addLibraryPath(.{ .cwd_relative = "/usr/lib/x86_64-linux-gnu/" });
114112
raylib_static.addIncludePath(.{ .cwd_relative = "/usr/include/x86_64-linux-gnu/" });
113+
raylib_static.addIncludePath(.{ .cwd_relative = "/usr/include" });
114+
} else {
115+
raylib_static.addSystemIncludePath(.{ .cwd_relative = "/usr/include" });
115116
}
117+
118+
raylib_static.addLibraryPath(.{ .cwd_relative = "/usr/lib" });
116119
},
117120
else => {},
118121
}

0 commit comments

Comments
 (0)