Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Carla support for MacOS #4558

Merged
merged 20 commits into from
Sep 15, 2018
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/build
/target
.*.sw?
.DS_Store
*~
/CMakeLists.txt.user
/plugins/zynaddsubfx/zynaddsubfx/ExternalPrograms/Controller/Makefile
Expand Down
2 changes: 2 additions & 0 deletions .travis/osx..install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ else
fi

brew install $PACKAGES ccache
# FIXME: Move "carla" to $PACKAGES once https://github.com/Homebrew/homebrew-core/pull/31560 is merged
brew install https://gist.githubusercontent.com/tresf/a8ffb8299227c51cf11aaf3929765264/raw/e94ad17aea63084c66bcb7e90009e3d5e848a467/carla.rb

sudo npm install -g appdmg
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
PhysSong marked this conversation as resolved.
Show resolved Hide resolved
# look for carla under old name
IF(NOT CARLA_FOUND)
PKG_CHECK_MODULES(CARLA carla-standalone>=1.9.5)
tresf marked this conversation as resolved.
Show resolved Hide resolved
ENDIF()
IF(CARLA_FOUND)
SET(LMMS_HAVE_CARLA TRUE)
SET(STATUS_CARLA "OK")
Expand Down
41 changes: 33 additions & 8 deletions cmake/apple/install_apple.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
tresf marked this conversation as resolved.
Show resolved Hide resolved
export PATH=$PATH:$(brew --prefix qt)/bin
fi

# Remove any old .app bundles
Expand Down Expand Up @@ -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"
Expand All @@ -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"
6 changes: 5 additions & 1 deletion cmake/modules/BuildPlugin.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions plugins/carlabase/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Expand Down
21 changes: 10 additions & 11 deletions plugins/carlabase/carla.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* carla.cpp - Carla for LMMS
*
* Copyright (C) 2014 Filipe Coelho <[email protected]>
* Copyright (C) 2014-2018 Filipe Coelho <[email protected]>
*
* This file is part of LMMS - https://lmms.io
*
Expand All @@ -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"
Expand Down Expand Up @@ -161,8 +158,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
Expand Down Expand Up @@ -254,7 +252,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;

Expand All @@ -271,9 +269,6 @@ intptr_t CarlaInstrument::handleDispatcher(const NativeHostDispatcherOpcode opco
}
tresf marked this conversation as resolved.
Show resolved Hide resolved

return ret;

// unused for now
(void)index; (void)value; (void)ptr; (void)opt;
}

// -------------------------------------------------------------------
Expand Down Expand Up @@ -448,10 +443,15 @@ 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
#ifdef CARLA_OS_MAC
tresf marked this conversation as resolved.
Show resolved Hide resolved
fHost.uiParentId = 0;
#else
if (QWidget* const window = parent->window())
fHost.uiParentId = window->winId();
else
fHost.uiParentId = 0;
#endif

std::free((char*)fHost.uiName);

Expand Down Expand Up @@ -531,4 +531,3 @@ void CarlaInstrumentView::timerEvent(QTimerEvent* event)
}

// -------------------------------------------------------------------

7 changes: 4 additions & 3 deletions plugins/carlabase/carla.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* carla.h - Carla for LMMS
*
* Copyright (C) 2014 Filipe Coelho <[email protected]>
* Copyright (C) 2014-2018 Filipe Coelho <[email protected]>
*
* This file is part of LMMS - https://lmms.io
*
Expand All @@ -27,7 +27,8 @@

#include <QtCore/QMutex>

#include "CarlaNative.h"
#define REAL_BUILD // FIXME this shouldn't be needed
#include "CarlaNativePlugin.h"

#include "Instrument.h"
#include "InstrumentView.h"
Expand All @@ -44,7 +45,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;
Expand Down
4 changes: 2 additions & 2 deletions plugins/carlapatchbay/carlapatchbay.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* carlapatchbay.cpp - Carla for LMMS (Patchbay)
*
* Copyright (C) 2014 Filipe Coelho <[email protected]>
* Copyright (C) 2014-2018 Filipe Coelho <[email protected]>
*
* This file is part of LMMS - https://lmms.io
*
Expand Down Expand Up @@ -36,7 +36,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlapatchbay_plugin_descriptor =
QT_TRANSLATE_NOOP( "pluginBrowser",
"Carla Patchbay Instrument" ),
"falkTX <falktx/at/falktx.com>",
0x0195,
CARLA_VERSION_HEX,
Plugin::Instrument,
new PluginPixmapLoader( "logo" ),
NULL,
Expand Down
4 changes: 2 additions & 2 deletions plugins/carlarack/carlarack.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* carlarack.cpp - Carla for LMMS (Rack)
*
* Copyright (C) 2014 Filipe Coelho <[email protected]>
* Copyright (C) 2014-2018 Filipe Coelho <[email protected]>
*
* This file is part of LMMS - https://lmms.io
*
Expand Down Expand Up @@ -36,7 +36,7 @@ Plugin::Descriptor PLUGIN_EXPORT carlarack_plugin_descriptor =
QT_TRANSLATE_NOOP( "pluginBrowser",
"Carla Rack Instrument" ),
"falkTX <falktx/at/falktx.com>",
0x0195,
CARLA_VERSION_HEX,
Plugin::Instrument,
new PluginPixmapLoader( "logo" ),
NULL,
Expand Down