Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest zig and simplify build.zig #3905

Merged
merged 2 commits into from
Apr 10, 2024
Merged

Update to latest zig and simplify build.zig #3905

merged 2 commits into from
Apr 10, 2024

Conversation

freakmangd
Copy link
Contributor

@freakmangd freakmangd commented Apr 9, 2024

  • installHeader's signature was changed recently, so a versioned function was added for it
  • srcdir isn't needed, just adding "src/" before each path is sufficient
  • cabarger's hack seems to not be needed anymore
  • process.Child.run and process.Child.exec was coerced into a single function

Tested on ubuntu x64, on both 0.12.0-dev.3580+e204a6edb and 0.11.0

@raysan5 raysan5 merged commit b3dfa2d into raysan5:master Apr 10, 2024
14 checks passed
@raysan5
Copy link
Owner

raysan5 commented Apr 10, 2024

@freakmangd I'm not an expert on Zig building but it looks good to me. Thanks for the review!

@sykire
Copy link

sykire commented Apr 10, 2024

This breaks #3834 again

@raysan5
Copy link
Owner

raysan5 commented Apr 11, 2024

@freakmangd please, could you review this issue?

@freakmangd
Copy link
Contributor Author

@sykire Hi, sorry about the breakage, I neglected to test building raylib as a local dependency, I'll get that working asap

@freakmangd
Copy link
Contributor Author

@sykire Could you try using #3913 and let me know if it resolves your issue? Thanks!

@sykire
Copy link

sykire commented Apr 12, 2024

It builds successfully using zig build although if I do zig build run. It follows with:

INFO: Initializing raylib 5.1-dev
INFO: Platform backend: DESKTOP (GLFW)
INFO: Supported raylib modules:
INFO:     > rcore:..... loaded (mandatory)
INFO:     > rlgl:...... loaded (mandatory)
INFO:     > rshapes:... loaded (optional)
INFO:     > rtextures:. loaded (optional)
INFO:     > rtext:..... loaded (optional)
INFO:     > rmodels:... loaded (optional)
INFO:     > raudio:.... loaded (optional)
WARNING: GLFW: Error: 65544 Description: X11: Failed to load Xlib
WARNING: GLFW: Failed to initialize GLFW
Segmentation fault at address 0x0
???:?:?: 0x0 in ??? (???)
run 1: error: the following command terminated unexpectedly:
/home/username/Demos/Zig-Raylib/1/zig-out/bin/1
Build Summary: 5/7 steps succeeded; 1 failed (disable with --summary none)
run transitive failure
└─ run 1 failure
error: the following build command failed with exit code 1:
/home/username/Demos/Zig-Raylib/1/zig-cache/o/eff5a969d2db35df28286d86e61d4218/build /nix/store/c6ddcmrgzdhfh23y0j5pmqpj1ilfwi8a-zig-0.11.0/bin/zig /home/username/Demos/Zig-Raylib/1 /home/username/Demos/Zig-Raylib/1/zig-cache /home/username/.cache/zig run

I think that's due to an unrelated thing. I'm new to zig and raylib so don't much about them.

I'm using the configuration from this site: https://siddharthroy.com/posts/how-to-use-raylib-with-zig-without-any-bindings

P.D. This is what is has showing before when doing zig build

zig build-lib raylib Debug native: error: warning: FileNotFound: /home/username/Demos/Zig-Raylib/1/src/rcore.c
error: FileNotFound

zig build-lib raylib Debug native: error: the following command exited with error code 1:
/nix/store/c6ddcmrgzdhfh23y0j5pmqpj1ilfwi8a-zig-0.11.0/bin/zig build-lib -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rcore.c /home/username/Demos/Zig-Raylib/1/src/utils.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/raudio.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rmodels.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rshapes.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rtext.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rtextures.c -cflags -std=gnu99 -D_GNU_SOURCE -DGL_SILENCE_DEPRECATION=199309L -fno-sanitize=undefined -- /home/username/Demos/Zig-Raylib/1/src/rglfw.c -lGL -lX11 -lc --cache-dir /home/username/Demos/Zig-Raylib/1/zig-cache --global-cache-dir /home/username/.cache/zig --name raylib -static -I /home/username/Demos/Zig-Raylib/1/src/external/glfw/include -I /usr/include -D _GLFW_X11 -D PLATFORM_DESKTOP -L /usr/lib --listen=-
Build Summary: 1/5 steps succeeded; 1 failed (disable with --summary none)
install transitive failure
└─ install 1 transitive failure
   └─ zig build-exe 1 Debug native transitive failure
      └─ zig build-lib raylib Debug native failure
error: the following build command failed with exit code 1:
/home/username/Demos/Zig-Raylib/1/zig-cache/o/f768f3d98331ba0f16642c173e6eab8b/build /nix/store/c6ddcmrgzdhfh23y0j5pmqpj1ilfwi8a-zig-0.11.0/bin/zig /home/username/Demos/Zig-Raylib/1 /home/username/Demos/Zig-Raylib/1/zig-cache /home/username/.cache/zig

@freakmangd
Copy link
Contributor Author

freakmangd commented Apr 12, 2024

@sykire I'm using the same configuration to build and run raylib in my testing. Were you able to build and run it before this PR was merged?

Maybe try installing the required libraries for your system if you haven't: https://github.com/raysan5/raylib/wiki/Working-on-GNU-Linux I'd think it'd break during the build process if you don't have X11, but I could be wrong

Edit: Looks like you're getting a GLFW_PLATFORM_ERROR https://www.glfw.org/docs/latest/group__errors.html

@sykire
Copy link

sykire commented Apr 12, 2024

I couldn't build it, I got until the error in the ticket #3834 because of failed path resolution that was solved but then regressed. The other error I think I'm missing to build some library. I'm still in the process of running Raylib + Zig successfully once 😅.

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.

3 participants