Skip to content

Commit

Permalink
Expose CHECKING_LEVEL to CMake and Jucer (#74)
Browse files Browse the repository at this point in the history
Just like we exposed the MISBEHAVIOUR level, expose the CHECKING
LEVEL with which you run.

Closes #69
  • Loading branch information
baconpaul authored Jun 23, 2022
1 parent ab1bfac commit f1e5bc1
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
13 changes: 11 additions & 2 deletions cmake/ClapTargetHelpers.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function(clap_juce_extensions_plugin_internal)
set(oneValueArgs TARGET TARGET_PATH PLUGIN_NAME IS_JUCER DO_COPY CLAP_MANUAL_URL CLAP_SUPPORT_URL CLAP_MISBEHAVIOUR_HANDLER_LEVEL)
set(oneValueArgs TARGET TARGET_PATH PLUGIN_NAME IS_JUCER DO_COPY CLAP_MANUAL_URL CLAP_SUPPORT_URL CLAP_MISBEHAVIOUR_HANDLER_LEVEL CLAP_CHECKING_LEVEL)
set(multiValueArgs CLAP_ID CLAP_FEATURES)

cmake_parse_arguments(CJA "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand All @@ -24,6 +24,13 @@ function(clap_juce_extensions_plugin_internal)
message( STATUS "Setting Misbehaviour handler level to '${CJA_CLAP_MISBEHAVIOUR_HANDLER_LEVEL}'")
endif()

if ("${CJA_CLAP_CHECKING_LEVEL}" STREQUAL "")
message( STATUS "Setting Checking handler level to 'Minimal'")
set(CJA_CLAP_CHECKING_LEVEL "Minimal")
else()
message( STATUS "Setting Checking handler level to '${CJA_CLAP_CHECKING_LEVEL}'")
endif()

# we need the list of features as comma separated quoted strings
foreach(feature IN LISTS CJA_CLAP_FEATURES)
list (APPEND CJA_CLAP_FEATURES_PARSED "\"${feature}\"")
Expand Down Expand Up @@ -76,7 +83,9 @@ function(clap_juce_extensions_plugin_internal)
CLAP_FEATURES=${CJA_CLAP_FEATURES_PARSED}
CLAP_MANUAL_URL="${CJA_CLAP_MANUAL_URL}"
CLAP_SUPPORT_URL="${CJA_CLAP_SUPPORT_URL}"
CLAP_MISBEHAVIOUR_HANDLER_LEVEL=${CJA_CLAP_MISBEHAVIOUR_HANDLER_LEVEL})
CLAP_MISBEHAVIOUR_HANDLER_LEVEL=${CJA_CLAP_MISBEHAVIOUR_HANDLER_LEVEL}
CLAP_CHECKING_LEVEL=${CJA_CLAP_CHECKING_LEVEL}
)

if(${CJA_IS_JUCER})
# Since we're working with a pre-compiled plugin lib we can't build
Expand Down
3 changes: 2 additions & 1 deletion cmake/JucerClap.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# use this function to create a CLAP from a jucer project
function(create_jucer_clap_target)
set(oneValueArgs TARGET PLUGIN_NAME MANUFACTURER_NAME MANUFACTURER_URL VERSION_STRING MANUFACTURER_CODE PLUGIN_CODE EDITOR_NEEDS_KEYBOARD_FOCUS MISBEHAVIOUR_HANDLER_LEVEL)
set(oneValueArgs TARGET PLUGIN_NAME MANUFACTURER_NAME MANUFACTURER_URL VERSION_STRING MANUFACTURER_CODE PLUGIN_CODE EDITOR_NEEDS_KEYBOARD_FOCUS MISBEHAVIOUR_HANDLER_LEVEL CHECKING_LEVEL)
set(multiValueArgs CLAP_ID CLAP_FEATURES CLAP_MANUAL_URL CLAP_SUPPORT_URL)

cmake_parse_arguments(CJA "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
Expand Down Expand Up @@ -45,6 +45,7 @@ function(create_jucer_clap_target)
CLAP_MANUAL_URL "${CJA_CLAP_MANUAL_URL}"
CLAP_SUPPORT_URL "${CJA_CLAP_SUPPORT_URL}"
CLAP_MISBEHAVIOUR_HANDLER_LEVEL "${CJA_MISBEHAVIOUR_HANDLER_LEVEL}"
CLAP_CHECKING_LEVEL "${CJA_CHECKING_LEVEL}"
)

string(REPLACE " " "_" clap_target "${CJA_TARGET}_CLAP")
Expand Down
12 changes: 10 additions & 2 deletions src/wrapper/clap-juce-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,17 @@ JUCE_BEGIN_IGNORE_WARNINGS_MSVC(4996) // allow strncpy
#define CLAP_MISBEHAVIOUR_HANDLER_LEVEL "Ignore"
#endif


#if !defined(CLAP_CHECKING_LEVEL)
#define CLAP_CHECKING_LEVEL "Minimal"
#endif

// This is useful for debugging overrides
// #undef CLAP_MISBEHAVIOUR_HANDLER_LEVEL
// #define CLAP_MISBEHAVIOUR_HANDLER_LEVEL Terminate
// #undef CLAP_CHECKING_LEVEL
// #define CLAP_CHECKING_LEVEL Maximal


/*
* A little class that sets an atomic bool to a value across its lifetime and
Expand All @@ -131,7 +139,7 @@ template <typename T> struct AtomicTGuard
*/
class ClapJuceWrapper : public clap::helpers::Plugin<
clap::helpers::MisbehaviourHandler::CLAP_MISBEHAVIOUR_HANDLER_LEVEL,
clap::helpers::CheckingLevel::Minimal>,
clap::helpers::CheckingLevel::CLAP_CHECKING_LEVEL>,
public juce::AudioProcessorListener,
public juce::AudioPlayHead,
public juce::AudioProcessorParameter::Listener,
Expand All @@ -150,7 +158,7 @@ class ClapJuceWrapper : public clap::helpers::Plugin<

ClapJuceWrapper(const clap_host *host, juce::AudioProcessor *p)
: clap::helpers::Plugin<clap::helpers::MisbehaviourHandler::CLAP_MISBEHAVIOUR_HANDLER_LEVEL,
clap::helpers::CheckingLevel::Minimal>(&desc, host),
clap::helpers::CheckingLevel::CLAP_CHECKING_LEVEL>(&desc, host),
processor(p)
{
processor->setRateAndBufferSizeDetails(0, 0);
Expand Down

0 comments on commit f1e5bc1

Please sign in to comment.