Skip to content

[build.zig] Refactor#5764

Draft
HaxSam wants to merge 7 commits intoraysan5:masterfrom
HaxSam:refactor-build-zig
Draft

[build.zig] Refactor#5764
HaxSam wants to merge 7 commits intoraysan5:masterfrom
HaxSam:refactor-build-zig

Conversation

@HaxSam
Copy link
Copy Markdown
Contributor

@HaxSam HaxSam commented Apr 15, 2026

Clean up the build.zig file

The platform implementation was not right and only worked on Windows

  • Enable tests again
  • GLFW Platform (done reused code)
  • RGFW Platform (needs testing win,mac)
  • SDL Platform (needs testing win,mac)
  • Memory Platform (weird screen flipped behavor)
  • WIN32 Platform (needs testing)
  • DRM Platform (done reused code)
  • Android Platform (done reused code)
  • create small example repo for people to test

Temporarily disabled the tests
@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Apr 15, 2026

@HaxSam thanks for working on this improvement

EDIT: Maybe @michaelfiber and @Not-Nik (Zig experts) can help with some review/testing

@CrackedPixel
Copy link
Copy Markdown
Contributor

0.15.x worked fine for me but when i tried 0.16.0 it fails:

zig build
build.zig:87:27: error: root source file struct 'mem' has no member named 'trimLeft'
        var flag = std.mem.trimLeft(u8, line, " \t"); // Trim whitespace
                   ~~~~~~~^~~~~~~~~
/home/<REDACTED>/.local/share/zigup/0.16.0/files/lib/std/mem.zig:1:1: note: struct declared here
const std = @import("std.zig");
^~~~~
referenced by:
    compileRaylib: build.zig:144:21
    build: build.zig:488:34
    7 reference(s) hidden; use '-freference-trace=9' to see all references
build.zig:435:113: error: root source file struct 'process' has no member named 'getEnvVarOwned'
            .android_ndk = b.option([]const u8, "android_ndk", "specify path to android ndk") orelse std.process.getEnvVarOwned(b.allocator, "ANDROID_NDK_HOME") catch "",
                                                                                                     ~~~~~~~~~~~^~~~~~~~~~~~~~~
/home/<REDACTED>/.local/share/zigup/0.16.0/files/lib/std/process.zig:1:1: note: struct declared here
const builtin = @import("builtin");

i'll try both on windows and mac next. im using RGFW backend but the error is there for glfw as well

@HaxSam
Copy link
Copy Markdown
Contributor Author

HaxSam commented Apr 16, 2026

@CrackedPixel great catch, thank you
Will fix it

Edit: It seems like you use an older version of the repo because this line doesn't exist anymore and was changed for 0.16.0, so it can't run.
update the repo by zig fetch --save "git+https://github.com/HaxSam/raylib#refactor-build-zig"

PS. Important: when it can run on 0.15.0 it can't on 0.16.0 and vice versa, there were too many breaking changes

@maiconpintoabreu
Copy link
Copy Markdown
Contributor

maiconpintoabreu commented Apr 16, 2026

Hi @HaxSam here is the error that I get when I try to build the lib for Android

maicon@thinkpad02:~/github/personal/raylib$ export ANDROID_NDK_HOME=/home/maicon/Android/Sdk/ndk/28.0.13004108
maicon@thinkpad02:~/github/personal/raylib$ zig build -Dtarget=aarch64-linux-android
install
└─ install raylib
   └─ compile lib raylib Debug aarch64-linux-android failure
error: error: unable to find dynamic system library 'GLX' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'X11' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xcursor' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xext' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xfixes' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xi' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xinerama' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xrandr' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'Xrender' using strategy 'paths_first'. searched paths: none
       error: unable to find dynamic system library 'X11' using strategy 'paths_first'. searched paths: none
       
error: process exited with error code 1
failed command: /home/maicon/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.16.0/zig build-lib -lGLX -lX11 -lXcursor -lXext -lXfixes -lXi -lXinerama -lXrandr -lXrender -lX11 -cflags -std=c99 -- /home/maicon/github/personal/raylib/src/rcore.c /home/maicon/github/personal/raylib/src/rshapes.c /home/maicon/github/personal/raylib/src/rtextures.c /home/maicon/github/personal/raylib/src/rtext.c /home/maicon/github/personal/raylib/src/rmodels.c /home/maicon/github/personal/raylib/src/raudio.c /home/maicon/github/personal/raylib/src/rglfw.c -ODebug -target aarch64-linux-android -mcpu baseline -I /home/maicon/github/personal/raylib/src/platforms -I /home/maicon/github/personal/raylib/src/external/glfw/include -D_GNU_SOURCE= -DGL_SILENCE_DEPRECATION=199309L -DSUPPORT_MODULE_RSHAPES=1 -DSUPPORT_MODULE_RTEXTURES=1 -DSUPPORT_MODULE_RTEXT=1 -DSUPPORT_MODULE_RMODELS=1 -DSUPPORT_MODULE_RAUDIO=1 -DPLATFORM_DESKTOP_GLFW= -D_GLFW_X11= -DGRAPHICS_API_OPENGL_33= -Mroot -lc --cache-dir .zig-cache --global-cache-dir /home/maicon/.cache/zig --name raylib -static --zig-lib-dir /home/maicon/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.16.0/lib/ --listen=-

Build Summary: 0/3 steps succeeded (1 failed)
install transitive failure
└─ install raylib transitive failure
   └─ compile lib raylib Debug aarch64-linux-android failure

error: the following build command failed with exit code 1:
.zig-cache/o/4731e80c2be947344c0f6138cac2fb18/build /home/maicon/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.16.0/zig /home/maicon/.config/VSCodium/User/globalStorage/ziglang.vscode-zig/zig/x86_64-linux-0.16.0/lib /home/maicon/github/personal/raylib .zig-cache /home/maicon/.cache/zig --seed 0x3d20ae4f -Z44a635df048f1af0 -Dtarget=aarch64-linux-android

Error before the refactor:

maicon@thinkpad02:~/github/personal/raylib$ zig build -Dtarget=aarch64-linux-android
install
└─ install raylib
   └─ compile lib raylib Debug aarch64-linux-android failure
error: error(libc_installation): missing field: include_dir
       error: unable to parse libc paths file at path .zig-cache/o/8aec3a751f602066c78d2081b830bcdd/android-libc.txt: ParseError

@HaxSam
Copy link
Copy Markdown
Contributor Author

HaxSam commented Apr 16, 2026

Oh yeh good catch

you need to set the platform to .andoid

@maiconpintoabreu
Copy link
Copy Markdown
Contributor

If possible can you fix the generation of android-libc.txt as well from the previous version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants