dynapi: Abstract out the environment variable name.
This commit is contained in:
parent
cf0cb44df8
commit
a3225ae6de
1 changed files with 5 additions and 3 deletions
|
@ -24,6 +24,8 @@
|
||||||
|
|
||||||
#if SDL_DYNAMIC_API
|
#if SDL_DYNAMIC_API
|
||||||
|
|
||||||
|
#define SDL_DYNAMIC_API_ENVVAR "SDL3_DYNAMIC_API"
|
||||||
|
|
||||||
#ifdef HAVE_STDIO_H
|
#ifdef HAVE_STDIO_H
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -383,21 +385,21 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
||||||
static void
|
static void
|
||||||
SDL_InitDynamicAPILocked(void)
|
SDL_InitDynamicAPILocked(void)
|
||||||
{
|
{
|
||||||
const char *libname = SDL_getenv_REAL("SDL_DYNAMIC_API");
|
const char *libname = SDL_getenv_REAL(SDL_DYNAMIC_API_ENVVAR);
|
||||||
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
|
||||||
SDL_bool use_internal = SDL_TRUE;
|
SDL_bool use_internal = SDL_TRUE;
|
||||||
|
|
||||||
if (libname) {
|
if (libname) {
|
||||||
entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry");
|
entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry");
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
dynapi_warn("Couldn't load overriding SDL library. Please fix or remove the SDL_DYNAMIC_API environment variable. Using the default SDL.");
|
dynapi_warn("Couldn't load overriding SDL library. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL.");
|
||||||
/* Just fill in the function pointers from this library, later. */
|
/* Just fill in the function pointers from this library, later. */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry) {
|
if (entry) {
|
||||||
if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0) {
|
if (entry(SDL_DYNAPI_VERSION, &jump_table, sizeof (jump_table)) < 0) {
|
||||||
dynapi_warn("Couldn't override SDL library. Using a newer SDL build might help. Please fix or remove the SDL_DYNAMIC_API environment variable. Using the default SDL.");
|
dynapi_warn("Couldn't override SDL library. Using a newer SDL build might help. Please fix or remove the " SDL_DYNAMIC_API_ENVVAR " environment variable. Using the default SDL.");
|
||||||
/* Just fill in the function pointers from this library, later. */
|
/* Just fill in the function pointers from this library, later. */
|
||||||
} else {
|
} else {
|
||||||
use_internal = SDL_FALSE; /* We overrode SDL! Don't use the internal version! */
|
use_internal = SDL_FALSE; /* We overrode SDL! Don't use the internal version! */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue