diff --git a/.gitignore b/.gitignore index aa4f17ab84c..771eba60762 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ /build /target .*.sw? +.DS_Store *~ /CMakeLists.txt.user /plugins/zynaddsubfx/zynaddsubfx/ExternalPrograms/Controller/Makefile diff --git a/.travis/osx..install.sh b/.travis/osx..install.sh index 45a6762d1f5..dfe1df4d1fb 100644 --- a/.travis/osx..install.sh +++ b/.travis/osx..install.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -PACKAGES="cmake pkgconfig fftw libogg libvorbis lame libsndfile libsamplerate jack sdl libgig libsoundio stk fluid-synth portaudio node fltk" +PACKAGES="cmake pkgconfig fftw libogg libvorbis lame libsndfile libsamplerate jack sdl libgig libsoundio stk fluid-synth portaudio node fltk carla" if [ $QT5 ]; then PACKAGES="$PACKAGES qt5" diff --git a/CMakeLists.txt b/CMakeLists.txt index da5be324a34..3fb0969eb89 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -229,7 +229,11 @@ ENDIF(WANT_TAP) # check for CARLA IF(WANT_CARLA) - PKG_CHECK_MODULES(CARLA carla-standalone>=1.9.5) + PKG_CHECK_MODULES(CARLA carla-native-plugin) + # look for carla under old name + IF(NOT CARLA_FOUND) + PKG_CHECK_MODULES(CARLA carla-standalone>=1.9.5) + ENDIF() IF(CARLA_FOUND) SET(LMMS_HAVE_CARLA TRUE) SET(STATUS_CARLA "OK") diff --git a/cmake/apple/install_apple.sh.in b/cmake/apple/install_apple.sh.in index 057cf5445e3..2597342083a 100644 --- a/cmake/apple/install_apple.sh.in +++ b/cmake/apple/install_apple.sh.in @@ -21,14 +21,7 @@ echo -e "$MSG_COLOR\n\nCreating App Bundle \"$APP\"...$COLOR_RESET" # Locate macdeployqt, assume homebrew & Qt5 which macdeployqt > /dev/null 2>&1 if [ $? -ne 0 ]; then - brew --prefix qt55 > /dev/null 2>&1 - if [ $? -eq 0 ]; then - # Prefer Qt 5.5 (QTBUG-53533) - export PATH=$PATH:$(brew --prefix qt55)/bin - else - # Fallback Qt 5.6+ - export PATH=$PATH:$(brew --prefix qt5)/bin - fi + export PATH=$PATH:$(brew --prefix qt)/bin fi # Remove any old .app bundles @@ -71,6 +64,17 @@ install_name_tool -change @rpath/libZynAddSubFxCore.dylib \ @loader_path/../../$zynfmk \ "$APP/Contents/$zynlib" +# Replace @rpath with @loader_path for Carla +# See also plugins/carlabase/CMakeLists.txt +# This MUST be done BEFORE calling macdeployqt +install_name_tool -change @rpath/libcarlabase.dylib \ + @loader_path/libcarlabase.dylib \ + "$APP/Contents/lib/lmms/libcarlapatchbay.so" + +install_name_tool -change @rpath/libcarlabase.dylib \ + @loader_path/libcarlabase.dylib \ + "$APP/Contents/lib/lmms/libcarlarack.so" + # Link lmms binary _executables="${_executables} -executable=$APP/Contents/$zynbin" _executables="${_executables} -executable=$APP/Contents/$zynfmk" @@ -90,6 +94,27 @@ done # Finalize .app macdeployqt "$APP" $_executables +# Carla is a standalone plugin. Remove library, look for it side-by-side LMMS.app +# This MUST be done AFTER calling macdeployqt +# +# For example: +# /Applications/LMMS.app +# /Applications/Carla.app +carlalibs=$(echo "@CARLA_LIBRARIES@"|tr ";" "\n") + +# Loop over all libcarlas, fix linking +for file in "$APP/Contents/lib/lmms/"libcarla*; do + _thisfile="$APP/Contents/lib/lmms/${file##*/}" + for lib in $carlalibs; do + _oldpath="../../Frameworks/lib${lib}.dylib" + _newpath="Carla.app/Contents/MacOS/lib${lib}.dylib" + install_name_tool -change @loader_path/$_oldpath \ + @executable_path/../../../$_newpath \ + "$_thisfile" + rm -f "$APP/Contents/Frameworks/lib${lib}.dylib" + done +done + # Cleanup rm -rf "$APP/Contents/bin" echo -e "\nFinished.\n\n" diff --git a/cmake/modules/BuildPlugin.cmake b/cmake/modules/BuildPlugin.cmake index f1dd95db6d3..25cca92afbc 100644 --- a/cmake/modules/BuildPlugin.cmake +++ b/cmake/modules/BuildPlugin.cmake @@ -73,7 +73,11 @@ MACRO(BUILD_PLUGIN PLUGIN_NAME) INSTALL(TARGETS ${PLUGIN_NAME} LIBRARY DESTINATION "${PLUGIN_DIR}") IF(LMMS_BUILD_APPLE) - SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader \"${CMAKE_BINARY_DIR}/lmms\"") + IF ("${PLUGIN_LINK}" STREQUAL "SHARED") + SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") + ELSE() + SET_TARGET_PROPERTIES(${PLUGIN_NAME} PROPERTIES LINK_FLAGS "-bundle_loader \"${CMAKE_BINARY_DIR}/lmms\"") + ENDIF() ADD_DEPENDENCIES(${PLUGIN_NAME} lmms) ENDIF(LMMS_BUILD_APPLE) IF(LMMS_BUILD_WIN32) diff --git a/plugins/carlabase/CMakeLists.txt b/plugins/carlabase/CMakeLists.txt index 8fdde2ec51f..4fa81a4916f 100644 --- a/plugins/carlabase/CMakeLists.txt +++ b/plugins/carlabase/CMakeLists.txt @@ -1,3 +1,11 @@ +# For MacOS, use "OLD" RPATH install_name behavior +# This can be changed to "NEW" safely if install_apple.sh.in +# is updated to relink libcarlabase.dylib. MacOS 10.8 uses +# cmake 3.9.6, so this can be done at any time. +IF(NOT CMAKE_VERSION VERSION_LESS 3.9) + CMAKE_POLICY(SET CMP0068 OLD) +ENDIF() + if(LMMS_HAVE_CARLA) INCLUDE(BuildPlugin) INCLUDE_DIRECTORIES(${CARLA_INCLUDE_DIRS}) diff --git a/plugins/carlabase/carla.cpp b/plugins/carlabase/carla.cpp index 9221ad4f28e..b25677f5c5f 100644 --- a/plugins/carlabase/carla.cpp +++ b/plugins/carlabase/carla.cpp @@ -1,7 +1,7 @@ /* * carla.cpp - Carla for LMMS * - * Copyright (C) 2014 Filipe Coelho + * Copyright (C) 2014-2018 Filipe Coelho * * This file is part of LMMS - https://lmms.io * @@ -24,9 +24,6 @@ #include "carla.h" -#define REAL_BUILD // FIXME this shouldn't be needed -#include "CarlaHost.h" - #include "Engine.h" #include "Song.h" #include "gui_templates.h" @@ -132,14 +129,6 @@ static const char* host_ui_save_file(NativeHostHandle, bool isDir, const char* t // ----------------------------------------------------------------------- -CARLA_EXPORT -const NativePluginDescriptor* carla_get_native_patchbay_plugin(); - -CARLA_EXPORT -const NativePluginDescriptor* carla_get_native_rack_plugin(); - -// ----------------------------------------------------------------------- - CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const Descriptor* const descriptor, const bool isPatchbay) : Instrument(instrumentTrack, descriptor), kIsPatchbay(isPatchbay), @@ -161,8 +150,9 @@ CarlaInstrument::CarlaInstrument(InstrumentTrack* const instrumentTrack, const D path.cdUp(); resourcesPath = path.absolutePath() + "/share/carla/resources"; #elif defined(CARLA_OS_MAC) - // assume standard install location - resourcesPath = "/Applications/Carla.app/Contents/MacOS/resources"; + // parse prefix from dll filename + QDir path = QFileInfo(dllName).dir(); + resourcesPath = path.absolutePath() + "/resources"; #elif defined(CARLA_OS_WIN32) || defined(CARLA_OS_WIN64) // not yet supported #endif @@ -254,7 +244,7 @@ void CarlaInstrument::handleUiClosed() emit uiClosed(); } -intptr_t CarlaInstrument::handleDispatcher(const NativeHostDispatcherOpcode opcode, const int32_t index, const intptr_t value, void* const ptr, const float opt) +intptr_t CarlaInstrument::handleDispatcher(const NativeHostDispatcherOpcode opcode, const int32_t, const intptr_t, void* const, const float) { intptr_t ret = 0; @@ -267,13 +257,10 @@ intptr_t CarlaInstrument::handleDispatcher(const NativeHostDispatcherOpcode opco qApp->processEvents(); break; default: - break; + break; } return ret; - - // unused for now - (void)index; (void)value; (void)ptr; (void)opt; } // ------------------------------------------------------------------- @@ -448,9 +435,12 @@ bool CarlaInstrument::handleMidiEvent(const MidiEvent& event, const MidiTime&, f PluginView* CarlaInstrument::instantiateView(QWidget* parent) { +// Disable plugin focus per https://bugreports.qt.io/browse/QTBUG-30181 +#ifndef CARLA_OS_MAC if (QWidget* const window = parent->window()) fHost.uiParentId = window->winId(); else +#endif fHost.uiParentId = 0; std::free((char*)fHost.uiName); diff --git a/plugins/carlabase/carla.h b/plugins/carlabase/carla.h index 6431e5300de..fb54e2271da 100644 --- a/plugins/carlabase/carla.h +++ b/plugins/carlabase/carla.h @@ -1,7 +1,7 @@ /* * carla.h - Carla for LMMS * - * Copyright (C) 2014 Filipe Coelho + * Copyright (C) 2014-2018 Filipe Coelho * * This file is part of LMMS - https://lmms.io * @@ -27,7 +27,19 @@ #include -#include "CarlaNative.h" +#define REAL_BUILD // FIXME this shouldn't be needed +#if CARLA_VERSION_HEX >= 0x010911 + #include "CarlaNativePlugin.h" +#else + #include "CarlaBackend.h" + #include "CarlaNative.h" + #include "CarlaUtils.h" + CARLA_EXPORT + const NativePluginDescriptor* carla_get_native_patchbay_plugin(); + + CARLA_EXPORT + const NativePluginDescriptor* carla_get_native_rack_plugin(); +#endif #include "Instrument.h" #include "InstrumentView.h" @@ -44,7 +56,7 @@ class PLUGIN_EXPORT CarlaInstrument : public Instrument CarlaInstrument(InstrumentTrack* const instrumentTrack, const Descriptor* const descriptor, const bool isPatchbay); virtual ~CarlaInstrument(); - // CarlaNative functions + // Carla NativeHostDescriptor functions uint32_t handleGetBufferSize() const; double handleGetSampleRate() const; bool handleIsOffline() const; diff --git a/plugins/carlapatchbay/carlapatchbay.cpp b/plugins/carlapatchbay/carlapatchbay.cpp index ae6ca1906e3..42786d18a9d 100644 --- a/plugins/carlapatchbay/carlapatchbay.cpp +++ b/plugins/carlapatchbay/carlapatchbay.cpp @@ -1,7 +1,7 @@ /* * carlapatchbay.cpp - Carla for LMMS (Patchbay) * - * Copyright (C) 2014 Filipe Coelho + * Copyright (C) 2014-2018 Filipe Coelho * * This file is part of LMMS - https://lmms.io * @@ -36,7 +36,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlapatchbay_plugin_descriptor = QT_TRANSLATE_NOOP( "pluginBrowser", "Carla Patchbay Instrument" ), "falkTX ", - 0x0195, + CARLA_VERSION_HEX, Plugin::Instrument, new PluginPixmapLoader( "logo" ), NULL, diff --git a/plugins/carlarack/carlarack.cpp b/plugins/carlarack/carlarack.cpp index 0a52c63c53d..2149e66040a 100644 --- a/plugins/carlarack/carlarack.cpp +++ b/plugins/carlarack/carlarack.cpp @@ -1,7 +1,7 @@ /* * carlarack.cpp - Carla for LMMS (Rack) * - * Copyright (C) 2014 Filipe Coelho + * Copyright (C) 2014-2018 Filipe Coelho * * This file is part of LMMS - https://lmms.io * @@ -36,7 +36,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlarack_plugin_descriptor = QT_TRANSLATE_NOOP( "pluginBrowser", "Carla Rack Instrument" ), "falkTX ", - 0x0195, + CARLA_VERSION_HEX, Plugin::Instrument, new PluginPixmapLoader( "logo" ), NULL,