diff --git a/Makefile.plugins.mk b/Makefile.plugins.mk index 81143871..d4f69a5a 100644 --- a/Makefile.plugins.mk +++ b/Makefile.plugins.mk @@ -33,7 +33,6 @@ endif BUILD_C_FLAGS += -I. BUILD_CXX_FLAGS += -I. -I$(DPF_PATH)/distrho -I$(DPF_PATH)/dgl -BUILD_CXX_FLAGS += -Wno-pmf-conversions ifeq ($(HAVE_ALSA),true) BASE_FLAGS += -DHAVE_ALSA @@ -224,6 +223,13 @@ endif # TODO split dsp and ui object build flags BASE_FLAGS += $(DGL_FLAGS) +# --------------------------------------------------------------------------------------------------------------------- +# Runtime test build + +ifeq ($(DPF_RUNTIME_TESTING),true) +BUILD_CXX_FLAGS += -DDPF_RUNTIME_TESTING -Wno-pmf-conversions +endif + # --------------------------------------------------------------------------------------------------------------------- # all needs to be first diff --git a/distrho/DistrhoInfo.hpp b/distrho/DistrhoInfo.hpp index c70752e8..06ff42a9 100644 --- a/distrho/DistrhoInfo.hpp +++ b/distrho/DistrhoInfo.hpp @@ -615,6 +615,34 @@ START_NAMESPACE_DISTRHO /** @} */ +/* ------------------------------------------------------------------------------------------------------------ + * Plugin Macros */ + +/** + @defgroup ExtraPluginMacros Extra Plugin Macros + + C Macros to customize DPF behaviour. + + These are macros that do not set plugin features or information, but instead change DPF internals.@n + They are all optional, none are enabled by default. + + All values are a simple define, their value is meaningless (and unused). + @{ + */ + +/** + Whether to enable runtime plugin tests.@n + This will check, during initialization of the plugin, if parameters, programs and states are setup properly.@n + Useful to enable as part of CI, can safely be skipped.@n + Under DPF makefiles can be enabled by using `make DPF_RUNTIME_TESTING=true`. + + @note Some checks are only available with the GCC compiler, + for detecting if a virtual function has been reimplemented. + */ +#define DPF_RUNTIME_TESTING + +/** @} */ + // ----------------------------------------------------------------------------------------------------------- END_NAMESPACE_DISTRHO diff --git a/distrho/src/DistrhoPluginInternal.hpp b/distrho/src/DistrhoPluginInternal.hpp index 78066fdd..f46e5e8e 100644 --- a/distrho/src/DistrhoPluginInternal.hpp +++ b/distrho/src/DistrhoPluginInternal.hpp @@ -247,30 +247,26 @@ public: DISTRHO_SAFE_ASSERT_RETURN(fPlugin != nullptr,); DISTRHO_SAFE_ASSERT_RETURN(fData != nullptr,); - /* Verify that virtual functions are overriden if parameters, programs or states are in use. +#if defined(DPF_RUNTIME_TESTING) && defined(__GNUC__) && !defined(__clang__) + /* Run-time testing build. + * Verify that virtual functions are overriden if parameters, programs or states are in use. * This does not work on all compilers, but we use it purely as informational check anyway. */ -#if defined(__GNUC__) && !defined(__clang__) -# ifdef DPF_ABORT_ON_ERROR -# define DPF_ABORT abort(); -# else -# define DPF_ABORT -# endif if (fData->parameterCount != 0) { if ((void*)(fPlugin->*(&Plugin::initParameter)) == (void*)&Plugin::initParameter) { d_stderr2("DPF warning: Plugins with parameters must implement `initParameter`"); - DPF_ABORT + abort(); } if ((void*)(fPlugin->*(&Plugin::getParameterValue)) == (void*)&Plugin::getParameterValue) { d_stderr2("DPF warning: Plugins with parameters must implement `getParameterValue`"); - DPF_ABORT + abort(); } if ((void*)(fPlugin->*(&Plugin::setParameterValue)) == (void*)&Plugin::setParameterValue) { d_stderr2("DPF warning: Plugins with parameters must implement `setParameterValue`"); - DPF_ABORT + abort(); } } @@ -280,12 +276,12 @@ public: if ((void*)(fPlugin->*(&Plugin::initProgramName)) == (void*)&Plugin::initProgramName) { d_stderr2("DPF warning: Plugins with programs must implement `initProgramName`"); - DPF_ABORT + abort(); } if ((void*)(fPlugin->*(&Plugin::loadProgram)) == (void*)&Plugin::loadProgram) { d_stderr2("DPF warning: Plugins with programs must implement `loadProgram`"); - DPF_ABORT + abort(); } } # endif @@ -296,13 +292,13 @@ public: if ((void*)(fPlugin->*(&Plugin::initState)) == (void*)&Plugin::initState) { d_stderr2("DPF warning: Plugins with state must implement `initState`"); - DPF_ABORT + abort(); } if ((void*)(fPlugin->*(&Plugin::setState)) == (void*)&Plugin::setState) { d_stderr2("DPF warning: Plugins with state must implement `setState`"); - DPF_ABORT + abort(); } } # endif @@ -313,17 +309,15 @@ public: if ((void*)(fPlugin->*(&Plugin::getState)) == (void*)&Plugin::getState) { d_stderr2("DPF warning: Plugins with full state must implement `getState`"); - DPF_ABORT + abort(); } } else { d_stderr2("DPF warning: Plugins with full state must have at least 1 state"); - DPF_ABORT + abort(); } # endif - -# undef DPF_ABORT #endif #if DISTRHO_PLUGIN_NUM_INPUTS+DISTRHO_PLUGIN_NUM_OUTPUTS > 0