From b584e5f5061883baea2561877af729ebc77fe428 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Sun, 31 Jan 2021 23:48:18 -0500 Subject: [PATCH] Use @executable_path for libRack.dylib for plugins on Mac. This is a hack that will need to be changed to @rpath later. --- Makefile | 1 + plugin.mk | 20 +++++++++++--------- src/app/MenuBar.cpp | 2 +- src/plugin.cpp | 4 +++- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 543e3e0c..adc80beb 100644 --- a/Makefile +++ b/Makefile @@ -170,6 +170,7 @@ ifdef ARCH_MAC cp $(STANDALONE_TARGET) dist/Rack.app/Contents/MacOS/ $(STRIP) -S dist/Rack.app/Contents/MacOS/$(TARGET) $(STRIP) -S dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET) + install_name_tool -change $(TARGET) @executable_path/$(TARGET) dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET) # Manually check that no nonstandard shared libraries are linked otool -L dist/Rack.app/Contents/MacOS/$(TARGET) otool -L dist/Rack.app/Contents/MacOS/$(STANDALONE_TARGET) diff --git a/plugin.mk b/plugin.mk index 5cad18d3..f3bb2f49 100644 --- a/plugin.mk +++ b/plugin.mk @@ -42,7 +42,7 @@ endif ifdef ARCH_WIN TARGET := plugin.dll LDFLAGS += -static-libstdc++ - RACK_USER_DIR ?= "$(USERPROFILE)"/Documents/Rack + RACK_USER_DIR ?= $(USERPROFILE)/Documents/Rack endif @@ -59,26 +59,28 @@ clean: dist: all rm -rf dist - mkdir -p dist/"$(SLUG)" + mkdir -p dist/$(SLUG) @# Strip and copy plugin binary - cp $(TARGET) dist/"$(SLUG)"/ + cp $(TARGET) dist/$(SLUG)/ ifdef ARCH_MAC - $(STRIP) -S dist/"$(SLUG)"/$(TARGET) + $(STRIP) -S dist/$(SLUG)/$(TARGET) + install_name_tool -change libRack.dylib @executable_path/libRack.dylib dist/$(SLUG)/$(TARGET) + otool -L dist/$(SLUG)/$(TARGET) else - $(STRIP) -s dist/"$(SLUG)"/$(TARGET) + $(STRIP) -s dist/$(SLUG)/$(TARGET) endif @# Copy distributables ifdef ARCH_MAC - rsync -rR $(DISTRIBUTABLES) dist/"$(SLUG)"/ + rsync -rR $(DISTRIBUTABLES) dist/$(SLUG)/ else - cp -r --parents $(DISTRIBUTABLES) dist/"$(SLUG)"/ + cp -r --parents $(DISTRIBUTABLES) dist/$(SLUG)/ endif @# Create ZIP package - cd dist && ZSTD_CLEVEL=19 tar -cf "$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin --zstd "$(SLUG)" + cd dist && tar -c $(SLUG) | zstd -19 -o $(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin install: dist mkdir -p "$(RACK_USER_DIR)"/plugins-v2/ - cp dist/"$(SLUG)"-"$(VERSION)"-$(ARCH).vcvplugin "$(RACK_USER_DIR)"/plugins-v2/ + cp dist/$(SLUG)-"$(VERSION)"-$(ARCH).vcvplugin "$(RACK_USER_DIR)"/plugins-v2/ .PHONY: clean dist .DEFAULT_GOAL := all diff --git a/src/app/MenuBar.cpp b/src/app/MenuBar.cpp index 70be88e7..a1e082d2 100644 --- a/src/app/MenuBar.cpp +++ b/src/app/MenuBar.cpp @@ -1012,7 +1012,7 @@ struct MenuBar : widget::OpaqueWidget { layout->addChild(helpButton); MenuButton* alphaButton = new MenuButton; - alphaButton->text = "Pre-alpha built for Christoph Scholtes. Not for release"; + alphaButton->text = "Pre-alpha built for Christoph Scholtes. Not for release."; layout->addChild(alphaButton); } diff --git a/src/plugin.cpp b/src/plugin.cpp index e0bfaa81..865ff375 100644 --- a/src/plugin.cpp +++ b/src/plugin.cpp @@ -54,7 +54,9 @@ static void* loadLibrary(std::string libraryPath) { #else // As of Rack v2.0, plugins are linked with `-rpath=.` so change current directory so it can find libRack. std::string cwd = system::getWorkingDirectory(); - system::setWorkingDirectory(asset::systemDir); + std::string libDir = asset::systemDir; + DEBUG("Setting working directory to %s", libDir.c_str()); + system::setWorkingDirectory(libDir); // Change it back when we're finished DEFER({system::setWorkingDirectory(cwd);}); // Load library with dlopen