Skip to content

Commit

Permalink
Updates for JUCE 7.0.6 (#133)
Browse files Browse the repository at this point in the history
* CI change for testing JUCE 7.0.6

* Update defaults to C++17

* Fix compilation on MacOS

* Trying to repair both backwards and current compatibility

* Trying to fix Linux and Windows issues

* A few more compatibility tweaks

* Trying to fix missing macros in older JUCEs
  • Loading branch information
jatinchowdhury18 authored Aug 4, 2023
1 parent 7433a92 commit 10bc7d4
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false # show all errors for each platform (vs. cancel jobs on error)
matrix:
os: [ubuntu-latest, windows-2019, macOS-latest]
juce_version: ["6.0.7", "6.1.5", "6.1.6", "7.0.0"]
juce_version: ["6.0.7", "6.1.5", "6.1.6", "7.0.0", "7.0.6"]

steps:
- name: Install Linux Deps
Expand Down
15 changes: 5 additions & 10 deletions .github/workflows/build-projucer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,17 @@ jobs:
- os: ubuntu-latest
jucer: build/_deps/juce-src/extras/Projucer/Builds/LinuxMakefile/build/Projucer
clap_gen: "Unix Makefiles"
juce_version: "6.1.5"
cxx_standard: 14
juce_version: "7.0.6"
cxx_standard: 17
- os: macos-latest
jucer: build/_deps/juce-src/extras/Projucer/Builds/MacOSX/build/Debug/Projucer.app/Contents/MacOS/Projucer
clap_gen: "Xcode"
juce_version: "6.1.5"
cxx_standard: 14
- os: windows-2019
jucer: build/_deps/juce-src/extras/Projucer/Builds/VisualStudio2019/x64/Debug/App/Projucer.exe
clap_gen: "Visual Studio 16 2019"
juce_version: "6.1.5"
cxx_standard: 14
juce_version: "7.0.6"
cxx_standard: 17
- os: windows-2022
jucer: build/_deps/juce-src/extras/Projucer/Builds/VisualStudio2019/x64/Debug/App/Projucer.exe
clap_gen: "Visual Studio 17 2022"
juce_version: "7.0.3"
juce_version: "7.0.6"
cxx_standard: 17

steps:
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ project(clap-juce-extensions VERSION 0.1.0 LANGUAGES C CXX)
if (CMAKE_CXX_STANDARD)
set(CLAP_CXX_STANDARD ${CMAKE_CXX_STANDARD})
else()
set(CLAP_CXX_STANDARD 14)
set(CLAP_CXX_STANDARD 17)
endif()
if (${CLAP_CXX_STANDARD} LESS 14)
set(CLAP_CXX_STANDARD 14)
Expand All @@ -38,7 +38,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)
option(CLAP_JUCE_EXTENSIONS_BUILD_EXAMPLES "Add targets for building and running clap-juce-extensions examples" ${is_toplevel})
if(CLAP_JUCE_EXTENSIONS_BUILD_EXAMPLES)
# The examples need JUCE to be imported before the CLAP helper targets
set(CLAP_JUCE_VERSION "6.1.5" CACHE STRING "Version of JUCE to use for building example plugins")
set(CLAP_JUCE_VERSION "7.0.6" CACHE STRING "Version of JUCE to use for building example plugins")
message(STATUS "Building examples with JUCE version: ${CLAP_JUCE_VERSION}")
include(examples/cmake/CPM.cmake)
CPMAddPackage("gh:juce-framework/JUCE#${CLAP_JUCE_VERSION}")
Expand All @@ -61,11 +61,13 @@ set_target_properties(clap_juce_extensions PROPERTIES
CXX_VISIBILITY_PRESET hidden
)

add_library(clap_juce_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper/clap-juce-wrapper.cpp)
add_library(clap_juce_sources INTERFACE)
set_property(TARGET clap_juce_sources PROPERTY CXX_STANDARD ${CLAP_CXX_STANDARD})
set_property(TARGET clap_juce_sources PROPERTY CLAP_JUCE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
if (APPLE)
target_sources(clap_juce_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper/clap-juce-mac.mm)
else()
target_sources(clap_juce_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/wrapper/clap-juce-wrapper.cpp)
endif()
target_include_directories(clap_juce_sources INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/include)

Expand Down
6 changes: 5 additions & 1 deletion cmake/JucerClap.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ function(create_jucer_clap_target)
message(WARNING "Plugin code not set! Using \"Xyz5\"")
set(CJA_PLUGIN_CODE "Xyz5")
endif()
target_compile_definitions(${clap_target} PRIVATE JucePlugin_PluginCode=${CJA_PLUGIN_CODE})
target_compile_definitions(${clap_target}
PRIVATE
JucePlugin_PluginCode="${CJA_PLUGIN_CODE}"
JucePlugin_VSTUniqueID="${CJA_PLUGIN_CODE}"
)

if(${CJA_EDITOR_NEEDS_KEYBOARD_FOCUS})
target_compile_definitions(${clap_target} PRIVATE JucePlugin_EditorRequiresKeyboardFocus=1)
Expand Down
6 changes: 6 additions & 0 deletions src/wrapper/clap-juce-mac.mm
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include <juce_core/juce_core.h>

#if JUCE_VERSION < 0x070006
/*
* This file allows our CLAP extension to load the objective
* C extensions that JUCE uses to create a UI on mac in the
Expand All @@ -11,3 +14,6 @@

#define JucePlugin_Build_VST3 1
#include "juce_audio_plugin_client/VST/juce_VST_Wrapper.mm"
#endif

#include "clap-juce-wrapper.cpp"
43 changes: 37 additions & 6 deletions src/wrapper/clap-juce-wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,19 @@
#include <new>

#define JUCE_GUI_BASICS_INCLUDE_XHEADERS 1
#include <juce_core/system/juce_CompilerWarnings.h>
#include <juce_core/system/juce_TargetPlatform.h>
#include <juce_audio_processors/juce_audio_processors.h>
#include <juce_gui_basics/juce_gui_basics.h>
#include <juce_audio_processors/format_types/juce_LegacyAudioParameter.cpp>

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE("-Wunused-parameter", "-Wsign-conversion", "-Wfloat-conversion")
#if JUCE_VERSION >= 0x070006
#include <juce_audio_plugin_client/detail/juce_IncludeSystemHeaders.h>
#include <juce_audio_plugin_client/detail/juce_PluginUtilities.h>
#include <juce_audio_plugin_client/detail/juce_VSTWindowUtilities.h>
#endif

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE("-Wunused-parameter", "-Wsign-conversion", "-Wfloat-conversion", "-Wfloat-equal")
JUCE_BEGIN_IGNORE_WARNINGS_MSVC(4100 4127 4244)
// Sigh - X11.h eventually does a #define None 0L which doesn't work
// with an enum in clap land being called None, so just undef it
Expand All @@ -38,7 +46,9 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE
#include <clap-juce-extensions/clap-juce-extensions.h>

#if JUCE_LINUX
#if JUCE_VERSION > 0x060008
#if JUCE_VERSION >= 0x070006
#include <juce_audio_plugin_client/detail/juce_LinuxMessageThread.h>
#elif JUCE_VERSION > 0x060008
#include <juce_audio_plugin_client/utility/juce_LinuxMessageThread.h>
#endif
#endif
Expand All @@ -60,6 +70,14 @@ JUCE_END_IGNORE_WARNINGS_GCC_LIKE
extern void *clapJuceExtensionCustomFactory(const char *);
#endif

#if ! JUCE_MAC
template <typename T>
using Point = juce::Point<T>;
#if JUCE_VERSION < 0x070006
using Component = juce::Component;
#endif
#endif

/*
* This is a utility lock free queue based on the JUCE abstract fifo
*/
Expand Down Expand Up @@ -97,6 +115,7 @@ template <typename T, int qSize = 4096> class PushPopQ
T dq[(size_t)qSize];
};

#if JUCE_VERSION < 0x070006
/*
* These functions are the JUCE VST2/3 NSView attachment functions. We compile them into
* our clap dll by, on macos, also linking clap_juce_mac.mm
Expand All @@ -107,6 +126,7 @@ extern JUCE_API void initialiseMacVST();
extern JUCE_API void *attachComponentToWindowRefVST(Component *, void *parentWindowOrView,
bool isNSView);
} // namespace juce
#endif

JUCE_BEGIN_IGNORE_WARNINGS_MSVC(4996) // allow strncpy

Expand Down Expand Up @@ -159,7 +179,7 @@ class EditorContextMenu : public juce::HostProvidedContextMenu
return builder.menuStack.front();
}

void showNativeMenu(juce::Point<int> pos) const override
void showNativeMenu(Point<int> pos) const override
{
if (!host.contextMenuCanPopup(host.host()))
return;
Expand Down Expand Up @@ -479,7 +499,11 @@ class ClapJuceWrapper : public clap::helpers::Plugin<
juce::ScopedJuceInitialiser_GUI libraryInitialiser;
const juce::MessageManagerLock mmLock;

#if JUCE_VERSION > 0x060008
#if JUCE_VERSION >= 0x070006
while (juce::detail::dispatchNextMessageOnSystemQueue(true))
{
}
#elif JUCE_VERSION > 0x060008
while (juce::dispatchNextMessageOnSystemQueue(true))
{
}
Expand Down Expand Up @@ -1216,8 +1240,10 @@ class ClapJuceWrapper : public clap::helpers::Plugin<
{
newValue = getNormalisedParameterValue(param, newValue);

JUCE_BEGIN_IGNORE_WARNINGS_GCC_LIKE("-Wfloat-equal")
if (param.processorParam->getValue() == newValue)
return;
JUCE_END_IGNORE_WARNINGS_GCC_LIKE

param.processorParam->setValue(newValue);

Expand Down Expand Up @@ -1658,7 +1684,7 @@ class ClapJuceWrapper : public clap::helpers::Plugin<
}
}

void componentMovedOrResized(juce::Component &component, bool wasMoved,
void componentMovedOrResized(Component &component, bool wasMoved,
bool wasResized) override
{
juce::ignoreUnused(wasMoved);
Expand Down Expand Up @@ -1707,7 +1733,7 @@ class ClapJuceWrapper : public clap::helpers::Plugin<

auto aspectRatio = (float)cst->getFixedAspectRatio();

if (aspectRatio != 0.0f)
if (aspectRatio > 0.0f)
{
/*
* This is obviously an unsatisfactory algorithm, but we wanted to have
Expand Down Expand Up @@ -1915,8 +1941,13 @@ class ClapJuceWrapper : public clap::helpers::Plugin<
#if JUCE_MAC
bool guiCocoaAttach(void *nsView) noexcept
{
#if JUCE_VERSION < 0x070006
juce::initialiseMacVST();
auto hostWindow = juce::attachComponentToWindowRefVST(editor.get(), nsView, true);
#else
const auto desktopFlags = juce::detail::PluginUtilities::getDesktopFlags (editor.get());
auto hostWindow = juce::detail::VSTWindowUtilities::attachComponentToWindowRefVST(editor.get(), desktopFlags, nsView);
#endif
juce::ignoreUnused(hostWindow);
return true;
}
Expand Down

0 comments on commit 10bc7d4

Please sign in to comment.