Skip to content

[build][Zig] Fix raygui inclusion in windows cross compilation #4489

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

Merged
merged 1 commit into from
Nov 20, 2024

Conversation

kimierik
Copy link
Contributor

Problem:

Cross compiling to windows when adding Raygui would error due to how zig handles the C #include macro.

Solution:

Added explicit include path for raylib.h for the raylib dependency when adding raygui.

Extra Info:

  • Build and executable tested only on my local machine.
  • Only tested with argument -Dtarget=x86_64-windows

@deathbeam
Copy link
Contributor

deathbeam commented Nov 14, 2024

wouldnt it be better to just get rid of addRaygui and provide the raygui dependency reference as parameter in options (e.g the approach i started, but this part wasnt finished)? That should be possible I think. Instead of trying to make addRaygui work.

EDIT:

Looks like passing the dependency via options is indeed not possible. Maybe just adding the raygui dependency to build.zig.zon and simply making it lazy and optional makes most sense?

EDIT2:

Benefit of having the raygui dep in build.zig.zon directly is also that user will always have actual functional build instead of potentionally mismatched raylib and raygui versions

@kimierik
Copy link
Contributor Author

kimierik commented Nov 14, 2024

Benefit of having the raygui dep in build.zig.zon directly is also that user will always have actual functional build instead of potentionally mismatched raylib and raygui versions

I dont think having raygui in the build.zig.zon is that good. The hash would have to be updated whenever raygui updates. And it could still lead to non functional builds if raylib updates and the raygui version has not.

I agree that addRaygui is not that good of a solution to the problem and a better alternative should be considered.

EDIT1:
If there is a way to get the pointer to the root build in the raylibs build.zig then it would be possible to use a boolean option to determine if raygui should be added. However AFAIK i dont think that is possible without giving it as a parameter of some sort, and then we would just have another fn that adds raygui.

In anycase this PR only fixes windows cross compile builds

@raysan5 raysan5 changed the title [BUILD][ZIG]: Fix raygui inclusion in windows cross compilation [build][Zig] Fix raygui inclusion in windows cross compilation Nov 16, 2024
@raysan5 raysan5 merged commit 532167d into raysan5:master Nov 20, 2024
2 checks passed
@raysan5
Copy link
Owner

raysan5 commented Nov 20, 2024

@kimierik thanks for the review!

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