Skip to content

Adapt build.zig to redesigned raylib build features config system#5645

Merged
raysan5 merged 1 commit intoraysan5:masterfrom
Wertual08:build-zig
Mar 13, 2026
Merged

Adapt build.zig to redesigned raylib build features config system#5645
raysan5 merged 1 commit intoraysan5:masterfrom
Wertual08:build-zig

Conversation

@Wertual08
Copy link
Copy Markdown
Contributor

Hello, It`s my first time submitting the PR, so, sorry to waste you time if it does not worth to be merged...

Problem:
Since commit 5361265 raylib config system was redesigned, and current build.zig stopped working at all by providing empty defines. Furthermore, I believe that with new config system there is no need to parse config.h to extract default defines.

Solution:
I removed default config.h parsing and replaced passing -D flags with appropriate addCMacro build call.
Overriding default values can now be done by users as in example below instead of passing options.config which seemed to me like a crutch O_o

const raylib_library = raylib_dependency.artifact("raylib");
raylib_library.root_module.sanitize_c = .off;
raylib_library.root_module.sanitize_thread = false;
raylib_library.root_module.addCMacro("SUPPORT_MOUSE_GESTURES", "0");

I`ve tested building of my projects on Windows 11 and latest Linux arch.

Thanks you very much in advance for your time. Hope this will be helpful...

@felipeasimos
Copy link
Copy Markdown

Hi @Wertual08, I ended up also opening a PR that ends up tackling the same issue in parsing config.h. I ended up taking another approach though, so I guess is up to raysan to choose which way we should go. Either way, I just want to let you know that this solution seems to result in a black screen when running examples, using the latest zig version (0.16.0-dev.2860+9c5460316).

@felipeasimos
Copy link
Copy Markdown

I was taking a look at it, and the black screen in zig master is probably because not all macros are included and also don't have their default values included in the try raylib_flags_arr.append(b.allocator, "-DMACRO"); statements.

As far as I understand, not using a value was compatible with the previous config system where only defined(MACRO) was used, so now we need to also pass the value, correct? (ex.: -DMACRO=1)

@Wertual08
Copy link
Copy Markdown
Contributor Author

Yeah, but new config.h already provides meaningfull default values, so why parse it to override them with the same ones?

@felipeasimos
Copy link
Copy Markdown

I am not entirely familiar with the build process, so I could be missing something obvious, but I feel like like the default values are not being propagated the way you think they are? For example, I managed to find exactly what makes zig build core_basic_window result in a black screen. Just add this to line 225:

try raylib_flags_arr.append(b.allocator, "-DSUPPORT_CUSTOM_FRAME_CONTROL=0");

If you add this, the example now works! Using =1 or leaving it empty doesn't.

I think your approach is good, I just think we need to validate with zig master.

@Wertual08
Copy link
Copy Markdown
Contributor Author

Thanks, I`ll check this out today.

@felipeasimos
Copy link
Copy Markdown

Actually, I am sorry, I ended up using the master branch from your fork. The example works correctly! I'll close my PR

@Wertual08
Copy link
Copy Markdown
Contributor Author

Oh, no problem! Thanks you very much for testing my PR. I was surprised, because I tried it on two systems, but now we came to agreement. Thanks for your time!

@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Mar 13, 2026

@Wertual08 @felipeasimos thanks for the improvement and further reviews!

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