-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce build config sentinels for DGL main flags
Signed-off-by: falkTX <[email protected]>
- Loading branch information
Showing
2 changed files
with
106 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* DISTRHO Plugin Framework (DPF) | ||
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]> | ||
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | ||
* or without fee is hereby granted, provided that the above copyright notice and this | ||
|
@@ -27,6 +27,41 @@ END_NAMESPACE_DISTRHO | |
|
||
START_NAMESPACE_DGL | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
// build config sentinels | ||
|
||
/** | ||
This set of static variables act as a build sentinel that detects a configuration error. | ||
Usually this means the way DGL was built and how it is being used and linked into your program are different, | ||
we want to avoid such combinations as memory layout would then also be different | ||
leading to all sort of nasty memory corruption issues. | ||
Make sure the flags used to build DGL match the ones used by your program and the link errors should go away. | ||
*/ | ||
#define BUILD_CONFIG_SENTINEL(NAME) \ | ||
static struct DISTRHO_JOIN_MACRO(_, NAME) { bool ok; DISTRHO_JOIN_MACRO(_, NAME)() noexcept; } NAME; | ||
|
||
#ifdef DPF_DEBUG | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dpf_debug_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dpf_debug_off) | ||
#endif | ||
|
||
#ifdef DGL_USE_FILE_BROWSER | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_file_browser_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_file_browser_off) | ||
#endif | ||
|
||
#ifdef DGL_USE_WEB_VIEW | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_web_view_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_web_view_off) | ||
#endif | ||
|
||
#undef BUILD_CONFIG_SENTINEL | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* | ||
* DISTRHO Plugin Framework (DPF) | ||
* Copyright (C) 2012-2022 Filipe Coelho <[email protected]> | ||
* Copyright (C) 2012-2024 Filipe Coelho <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any purpose with | ||
* or without fee is hereby granted, provided that the above copyright notice and this | ||
|
@@ -24,6 +24,55 @@ | |
|
||
START_NAMESPACE_DGL | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
// build config sentinels | ||
|
||
#define BUILD_CONFIG_SENTINEL(NAME) \ | ||
DISTRHO_JOIN_MACRO(_, NAME)::DISTRHO_JOIN_MACRO(_, NAME)() noexcept : ok(false) {} | ||
|
||
#ifdef DPF_DEBUG | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dpf_debug_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dpf_debug_off) | ||
#endif | ||
|
||
#ifdef DGL_USE_FILE_BROWSER | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_file_browser_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_file_browser_off) | ||
#endif | ||
|
||
#ifdef DGL_USE_WEB_VIEW | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_web_view_on) | ||
#else | ||
BUILD_CONFIG_SENTINEL(fail_to_link_is_mismatch_dgl_use_web_view_off) | ||
#endif | ||
|
||
#undef BUILD_CONFIG_SENTINEL | ||
|
||
static inline | ||
bool dpf_check_build_status() noexcept | ||
{ | ||
return ( | ||
#ifdef DPF_DEBUG | ||
fail_to_link_is_mismatch_dpf_debug_on.ok && | ||
#else | ||
fail_to_link_is_mismatch_dpf_debug_off.ok && | ||
#endif | ||
#ifdef DGL_USE_FILE_BROWSER | ||
fail_to_link_is_mismatch_dgl_use_file_browser_on.ok && | ||
#else | ||
fail_to_link_is_mismatch_dgl_use_file_browser_off.ok && | ||
#endif | ||
#ifdef DGL_USE_WEB_VIEW | ||
fail_to_link_is_mismatch_dgl_use_web_view_on.ok && | ||
#else | ||
fail_to_link_is_mismatch_dgl_use_web_view_off.ok && | ||
#endif | ||
true | ||
); | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------------------------------- | ||
|
||
#ifdef __EMSCRIPTEN__ | ||
|
@@ -34,7 +83,26 @@ static void app_idle(void* const app) | |
#endif | ||
|
||
Application::Application(const bool isStandalone) | ||
: pData(new PrivateData(isStandalone)) {} | ||
: pData(new PrivateData(isStandalone)) | ||
{ | ||
// build config sentinels | ||
#ifdef DPF_DEBUG | ||
fail_to_link_is_mismatch_dpf_debug_on.ok = true; | ||
#else | ||
fail_to_link_is_mismatch_dpf_debug_off.ok = true; | ||
#endif | ||
#ifdef DGL_USE_FILE_BROWSER | ||
fail_to_link_is_mismatch_dgl_use_file_browser_on.ok = true; | ||
#else | ||
fail_to_link_is_mismatch_dgl_use_file_browser_off.ok = true; | ||
#endif | ||
#ifdef DGL_USE_WEB_VIEW | ||
fail_to_link_is_mismatch_dgl_use_web_view_on.ok = true; | ||
#else | ||
fail_to_link_is_mismatch_dgl_use_web_view_off.ok = true; | ||
#endif | ||
DISTRHO_SAFE_ASSERT(dpf_check_build_status()); | ||
} | ||
|
||
Application::~Application() | ||
{ | ||
|