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

[build] Support config header in build.zig #3516

Closed
beaumccartney opened this issue Nov 7, 2023 · 5 comments
Closed

[build] Support config header in build.zig #3516

beaumccartney opened this issue Nov 7, 2023 · 5 comments

Comments

@beaumccartney
Copy link

Use zig build's support for config headers.

https://github.com/ziglang/zig/blob/67709b638224ac03820226c6744d8b6ead59184c/lib/std/Build.zig#L738-L755

@raysan5
Copy link
Owner

raysan5 commented Nov 7, 2023

@BeauSLM I'm afraid I don't maintain the Zig build system, feel free to send a PR with the required improvements or maybe point to some Zig developer that could work on this.

@raysan5 raysan5 changed the title [feature] Support config header in build.zig [build] Support config header in build.zig Nov 7, 2023
@Peter0x44
Copy link
Contributor

@BeauSLM is this to replace config.h and allow those variables to be set from zig?

@beaumccartney
Copy link
Author

My idea is to be able to set the variables from zig if building with zig, or using zig bindings.

@Peter0x44
Copy link
Contributor

@BeauSLM okay, exactly what I was thinking then
Just making sure I understood, since I wasn't too clear from the detail provided

@raysan5
Copy link
Owner

raysan5 commented Nov 11, 2023

I'm afraid I'm not maintaining the Zig build system, if anyone needs this feature, feel free to send a PR.

@raysan5 raysan5 closed this as completed Nov 11, 2023
lnc3l0t added a commit to lnc3l0t/raylib that referenced this issue Jul 29, 2024
The new Options field "config" holds a string the user can set in the
format "-Dflag_a=1 -Dflag_b=0 ..." to override the values set in
`config.h`.
The file is parsed and the default values are appended to the
compilation flags, if the user doesn't override them.
The user string is appended to the compilation flags.
The "-DEXTERNAL_CONFIG_FLAGS" is added to prevent "config.h" inclusion.

Note: a certain format is assumed for the formatting of config.h
Note: this commit references the closed issue raysan5#3516
raysan5 pushed a commit that referenced this issue Aug 4, 2024
* [build.zig] Overridable definitions from config.h
The new Options field "config" holds a string the user can set in the
format "-Dflag_a=1 -Dflag_b=0 ..." to override the values set in
`config.h`.
The file is parsed and the default values are appended to the
compilation flags, if the user doesn't override them.
The user string is appended to the compilation flags.
The "-DEXTERNAL_CONFIG_FLAGS" is added to prevent "config.h" inclusion.

Note: a certain format is assumed for the formatting of config.h
Note: this commit references the closed issue #3516

* [build.zig] Only SUPPORT_* definitions are overridable

Lines from `config.h` which contains "SUPPORT" are added to compilation after being parsed:
- remove whitespace
- format to preprocessor option https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html

The user supplied flags have priority over the ones read from the file.

NOTE: extension to commit 4da7f82, the logic is simplified
because the SUPPORT flags only have binary values, which makes them easier to parse.
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

No branches or pull requests

3 participants