From 33b2829a89a9ff6d971fe8fcf323e1b4b90e4628 Mon Sep 17 00:00:00 2001
From: Lumen Keyes <lumenkeyes@gmail.com>
Date: Tue, 1 Apr 2025 10:43:22 -0600
Subject: [PATCH] fix android-libc.txt generation

Previously, the libc paths file `android-libc.txt` was written to
the folder from which the user ran `zig build`. This caused
problems when using raylib as a dependency in other zig
projects, since raylib is not built in the project root, but the
`android-libc.txt` file was still generated in the project root. The file
should now be generated in .zig-cache, which should fix the isssue (and
leave the project root folder cleaner).
---
 build.zig | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/build.zig b/build.zig
index a5f88d2b5..dd0d6df6e 100644
--- a/build.zig
+++ b/build.zig
@@ -238,17 +238,15 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
                 raylib.addSystemIncludePath( .{ .cwd_relative = androidAsmPath});
                 raylib.addSystemIncludePath(.{ .cwd_relative = androidGluePath});
 
-                const libcFile = try std.fs.cwd().createFile("android-libc.txt", .{});
-                const writer = libcFile.writer();
-                const libc = std.zig.LibCInstallation{
+                var libcData = std.ArrayList(u8).init(b.allocator).writer();
+                const writer = libcData.writer();
+                try (std.zig.LibCInstallation{
                     .include_dir = androidIncludePath,
                     .sys_include_dir = androidIncludePath,
                     .crt_dir = androidApiSpecificPath,
-                };
-                try libc.render(writer);
-                libcFile.close();
-
-                raylib.setLibCFile(b.path("android-libc.txt"));
+                }).render(writer);
+                const libcFile = b.addWriteFiles().add("android-libc.txt", try libcData.toOwnedSlice());
+                raylib.setLibCFile(libcFile);
 
                 if (options.opengl_version == .auto) {
                     raylib.root_module.linkSystemLibrary("GLESv2", .{});