[build.zig] Override config.h definitions #4193
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR introduces a new option allowing
build.zig
to overrideconfig.h
settings using a simple string:This example enables support for the JPG format (disabled by default) and disables support for the PNG (enabled by default).
Two commits are present in the PR:
config.h
to be overriden, it has more cumbersome parsing since some definitions have different data typesSUPPORT_*
flags (which simplifies the implementation and you could possibly merge, given my assumptions are correct [below]).Thoughts
build.zig
#3516 suggested theaddConfigHeader
function, but I haven't found a way to use it. My logic mimics what has been done for CMake: parseconfig.h
to retrieve default values and override them with the ones provided by user, then inhibitconfig.h
by supplying-DEXTERNAL_CONFIG_FLAGS
-DEXTERNAL_CONFIG_FLAGS
all the other flags wouldn't be set, but it seems everything is redefined if needed in the various source file (is this assumption correct?).I used a command to find references to all NON-SUPPORT flags (all are redefined elsewhere except CONFIG_H)
config.h
should I remove them? and assume the formatting will always be the sameThank you for considering my PR :)