commit 71b4e5d1c5ae019f507573e13345dadf0e613a79
parent 8b8c76e9d2b0dab9a15e7dffbeaf8c4d2a165123
Author: falkTX <falktx@falktx.com>
Date: Wed, 22 Sep 2021 12:40:33 +0100
Put the runtime checks behind a DPF_RUNTIME_TESTING macro
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
3 files changed, 47 insertions(+), 19 deletions(-)
diff --git 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
@@ -225,6 +224,13 @@ endif
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
all:
diff --git 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
@@ -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