Browse Source

Link to the absolute path /tmp/Rack2/libRack.<ext>. Create a symlink at /tmp/Rack2 to the system dir containting libRack.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
36e02a2c93
4 changed files with 26 additions and 8 deletions
  1. +1
    -0
      include/system.hpp
  2. +7
    -3
      plugin.mk
  3. +7
    -5
      src/plugin.cpp
  4. +11
    -0
      src/system.cpp

+ 1
- 0
include/system.hpp View File

@@ -49,6 +49,7 @@ bool createDirectory(const std::string& path);
Returns whether the creation was successful.
*/
bool createDirectories(const std::string& path);
bool createSymbolicLink(const std::string& target, const std::string& link);
/** Deletes a file or empty directory.
Returns whether the deletion was successful.
*/


+ 7
- 3
plugin.mk View File

@@ -67,10 +67,14 @@ dist: all
cp $(TARGET) dist/$(SLUG)/
ifdef ARCH_MAC
$(STRIP) -S dist/$(SLUG)/$(TARGET)
$(INSTALL_NAME_TOOL) -change libRack.dylib @rpath/libRack.dylib dist/$(SLUG)/$(TARGET)
$(INSTALL_NAME_TOOL) -add_rpath . dist/$(SLUG)/$(TARGET)
$(INSTALL_NAME_TOOL) -change libRack.dylib /tmp/Rack2/libRack.dylib dist/$(SLUG)/$(TARGET)
$(OTOOL) -L dist/$(SLUG)/$(TARGET)
else
endif
ifdef ARCH_LIN
$(STRIP) -s dist/$(SLUG)/$(TARGET)
# TODO Change libRack.so path to /tmp/Rack2/libRack.dylib
endif
ifdef ARCH_WIN
$(STRIP) -s dist/$(SLUG)/$(TARGET)
endif
@# Copy distributables


+ 7
- 5
src/plugin.cpp View File

@@ -52,11 +52,13 @@ static void* loadLibrary(std::string libraryPath) {
throw Exception("Failed to load library %s: code %d", libraryPath.c_str(), error);
}
#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);
// Change it back when we're finished
DEFER({system::setWorkingDirectory(cwd);});
// Since Rack 2, plugins on Linux/Mac link to the absolute path /tmp/Rack2/libRack.<ext>
// Create a symlink at /tmp/Rack2 to the system dir containting libRack.
if (!settings::devMode) {
std::string systemDir = system::getAbsolute(asset::systemDir);
std::string linkPath = "/tmp/Rack2";
system::createSymbolicLink(systemDir, linkPath);
}
// Load library with dlopen
void* handle = NULL;
#if defined ARCH_LIN


+ 11
- 0
src/system.cpp View File

@@ -165,6 +165,17 @@ bool createDirectories(const std::string& path) {
}


bool createSymbolicLink(const std::string& target, const std::string& link) {
try {
fs::create_symlink(fs::u8path(target), fs::u8path(link));
return true;
}
catch (fs::filesystem_error& e) {
return false;
}
}


bool remove(const std::string& path) {
try {
return fs::remove(fs::u8path(path));


Loading…
Cancel
Save