Allow yet another symlinking method, fixing #3

This allows symlinking to a copy of `libyabridge.so.` Now we support:

- A symlink to `libyabridge.so` with a `.dll` file in the same directory
  as that symlink.
- A symlink to `libyabridge.so` with a symlinked `.dll`.
- A copy of `libyabridge.so` with a `.dll` file in the same directory as
  that copy.
- A symlink to a copy of `libyabridge.so` with a `.dll` file in the same
  directory as that copy.
- A symlink to a copy of `libyabridge.so` with a symlinked `.dll` file.

That seems a bit overkill, but hey, more options are always better,
right?
This commit is contained in:
Robbert van der Helm
2020-05-04 13:08:28 +02:00
parent ae92e61bcc
commit ad03d870ee
2 changed files with 33 additions and 11 deletions
+9
View File
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic and this project adheres to [Semantic
Versioning](https://semver.org/spec/v2.0.0.html). Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Changed
- Changed the plugin detection mechanism to support yet another way of
symlinking plugins. Now you can use a symlink to a copy of `libyabridge.so`
that's installed for a plugin in another directory. This is not recommended
though. Fixes #3.
## [1.0.0] - 2020-05-03 ## [1.0.0] - 2020-05-03
### Added ### Added
+23 -10
View File
@@ -85,7 +85,10 @@ fs::path find_vst_host(PluginArchitecture plugin_arch);
/** /**
* Find the VST plugin .dll file that corresponds to this copy of * Find the VST plugin .dll file that corresponds to this copy of
* `libyabridge.so`. This should be the same as the name of this file but with a * `libyabridge.so`. This should be the same as the name of this file but with a
* `.dll` file extension instead of `.so`. * `.dll` file extension instead of `.so`. In case this file does not exist and
* the `.so` file is a symlink, we'll also repeat this check for the file it
* links to. This is to support the workflow described in issue #3 where you use
* symlinks to copies of `libyabridge.so`.
* *
* @return The a path to the accompanying VST plugin .dll file. * @return The a path to the accompanying VST plugin .dll file.
* @throw std::runtime_error If no matching .dll file could be found. * @throw std::runtime_error If no matching .dll file could be found.
@@ -639,22 +642,32 @@ fs::path find_vst_host(PluginArchitecture plugin_arch) {
} }
fs::path find_vst_plugin() { fs::path find_vst_plugin() {
fs::path plugin_path = boost::dll::this_line_location(); const fs::path this_plugin_path = boost::dll::this_line_location();
fs::path plugin_path(this_plugin_path);
plugin_path.replace_extension(".dll"); plugin_path.replace_extension(".dll");
if (fs::exists(plugin_path)) {
// Also resolve symlinks here, to support symlinked .dll files
return fs::canonical(plugin_path);
}
// In case this files does not exist and our `.so` file is a symlink, we'll
// also repeat this check after resolving that symlink to support links to
// copies of `libyabridge.so` as described in issue #3
fs::path alternative_plugin_path = fs::canonical(this_plugin_path);
alternative_plugin_path.replace_extension(".dll");
if (fs::exists(alternative_plugin_path)) {
return fs::canonical(alternative_plugin_path);
}
// This function is used in the constructor's initializer list so we have to // This function is used in the constructor's initializer list so we have to
// throw when the path could not be found // throw when the path could not be found
if (!fs::exists(plugin_path)) { throw std::runtime_error("'" + plugin_path.string() +
throw std::runtime_error( "' does not exist, make sure to rename "
"'" + plugin_path.string() + "'libyabridge.so' to match a "
"' does not exist, make sure to rename 'libyabridge.so' to match a "
"VST plugin .dll file."); "VST plugin .dll file.");
} }
// Also resolve symlinks here
return fs::canonical(plugin_path);
}
PluginArchitecture find_plugin_architecture(fs::path plugin_path) { PluginArchitecture find_plugin_architecture(fs::path plugin_path) {
std::ifstream file(plugin_path, std::ifstream::binary | std::ifstream::in); std::ifstream file(plugin_path, std::ifstream::binary | std::ifstream::in);