-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[config.h] Consider changing how defines are used in raylib to support configuration from build systems #4411
Comments
I think this could be achieved by passing the define with the |
@znichola no that won't work, we have already tried it. Here's a test you can try: #include <stdio.h>
#ifndef EXAMPLE_OPTION
#define EXAMPLE_OPTION 1
#endif
int main(void)
{
#if EXAMPLE_OPTION == 1
puts("option enabled");
#endif
} |
Ah yes of course I see, that's dumb of me, I was thinking from the angle of disabling flags that were added with |
In regards to the current Zig build system, there's currently no way to undefine a macro so it's currently impossible to disable something like I was thinking if it would make sense to make it so if the value of a SUPPORT macro is set to 0, it should be equivalent to not setting the value. |
@sagehane that's exactly what this issue is about, changing all the #if defined (...) to #if will do that |
I missed that -DEXTERNAL_CONFIG_FLAGS exists, the change seems unnecessary. Close? |
This means nothing in config.h ends up defined at all, so you need to put everything in from scratch and it's more inconvenient. For the case of "stock raylib + jpg" or so you then have to pick every config option that is on by default, then also enable jpg. But I've taken a look and adjusting raylib for this doesn't seem particularly trivial either. |
Yes, we need to do this change, the current system is not really useable. |
I have created PR#4554 That implements this. |
@JeffM2501 I have to review this change carefully, all my tools pipelines depend on a custom config and I don't know if it could break my implementations.
It's a big change and affects |
It is a big change yes. 1 & 2) The main use case for this is that I need to disable built in screen capture and GIF recording. I do not want to maintain a fork of raylib with a custom config.h. I do not want to provide an entire config.h. Both of these thigns have a maintnenance and update cost that I do not want to pay. I simply want to disable the one feature I don't need via the build system since I am building raylib with my project.
The platform defines do NOT change, only the support and built in RLGL limits. Code that was checking I agree this is a HUGE change, but I feel it is absolutely necessary. The current way that #defines are used is basically useless unless you want to maintain a fork of raylib, or duplicate an entire file. This detracts from the simple nature of raylib. Because all the checks are just checking #if defined(), then it doesn't matter what the define in the config is. The only other real option is to remove many things from config.h entirely and make things be more dynamically settable at runtime, not compile time. |
#define OPTION
#undef OPTION
#include <stdio.h>
#include "config.h"
#include "custom.h"
int main(void)
{
#ifdef OPTION
puts("option enabled");
#else
puts("option disabled");
#endif
} This does not allow you to disable from command line, but unless I'm missing something you don't need a full copy of the config, only a custom config to EDIT: #inlcude "config.h"
#undef OPTION It's annoying, but I don't think quite as bad as you describe. |
@znichola I have distributions like that also, where some files are user-modifiable with respect to compiler options. I keep those all near each other along with instructions about how to preserve modified forms before installing or re-installing the distributed version in place. |
@orcmid But, could I not have a custom config that
#ifndef MY_CONFIG
# define MY_CONFIG
# include "raylib/config.h" // include raylib config, it's transparent to any changes upstream
#undef SUPPORT_FILEFORMAT_PNG // disabled for my custom build
#endif // MY_CONFIG |
@znichola surely this requires editing raylib source code anyway, right? |
Description:
Currently, raylib uses
#if defined(SUPPORT_X)
to conditionally enable/disable certain features like file format support. However, setting a define to0
from the build system (e.g.,-DSUPPORT_FILEFORMAT_PNG=0
) doesn't actually disable the feature because the macro is still considered "defined."This limitation makes it difficult to selectively disable certain features without manually editing
config.h
, especially when working with different build systems or when trying to configure raylib via command-line flags alone.Proposed Change:
Switch the current
#if defined(SUPPORT_X)
checks to something like#if SUPPORT_X == 1
. This would allow features to be properly toggled off by defining them as0
from the build system.Example:
This would enable features to be turned off using
-DSUPPORT_FILEFORMAT_PNG=0
in the build system, without requiring edits to the default configuration file.Discussion Summary:
This topic was discussed on the raylib Discord server. The current method was found to be limiting for build systems that rely on command-line defines. While the change is agreed to be useful, it was also acknowledged that it's better suited for a future release after the current planned version has been completed.
The text was updated successfully, but these errors were encountered: