Work around issue with invalid plugin paths #2

I'm not sure what would be causing this in some cases.
This commit is contained in:
Robbert van der Helm
2020-05-06 18:30:38 +02:00
parent 8a094dacb5
commit f79115992b
2 changed files with 22 additions and 5 deletions
+2
View File
@@ -26,6 +26,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).
### Fixed ### Fixed
- Fixed plugins failing to load on certain Debian based distros because of paths
starting with two forward slashes.
- Redirect the output from the Wine host process earlier in the startup. - Redirect the output from the Wine host process earlier in the startup.
Otherwise errors printed startup won't be visible, making it very hard to Otherwise errors printed startup won't be visible, making it very hard to
diagnose problems. diagnose problems.
+20 -5
View File
@@ -128,6 +128,12 @@ std::optional<fs::path> find_wineprefix();
*/ */
fs::path generate_endpoint_name(); fs::path generate_endpoint_name();
/**
* Return a path to this `.so` file. This can be used to find out from where
* this link to or copy of `libyabridge.so` was loaded.
*/
fs::path get_this_file_location();
/** /**
* Locate the Wine prefix and set the `WINEPREFIX` environment variable if * Locate the Wine prefix and set the `WINEPREFIX` environment variable if
* found. This way it's also possible to run .dll files outside of a Wine prefix * found. This way it's also possible to run .dll files outside of a Wine prefix
@@ -642,8 +648,7 @@ std::string create_logger_prefix(const fs::path& socket_path) {
std::optional<fs::path> find_wineprefix() { std::optional<fs::path> find_wineprefix() {
// Try to locate the Wine prefix this .so file is located in by finding the // Try to locate the Wine prefix this .so file is located in by finding the
// first parent directory that contains a directory named `dosdevices` // first parent directory that contains a directory named `dosdevices`
fs::path wineprefix_path = fs::path wineprefix_path = get_this_file_location().remove_filename();
boost::dll::this_line_location().remove_filename();
while (wineprefix_path != "") { while (wineprefix_path != "") {
if (fs::is_directory(wineprefix_path / "dosdevices")) { if (fs::is_directory(wineprefix_path / "dosdevices")) {
return wineprefix_path; return wineprefix_path;
@@ -709,8 +714,7 @@ fs::path find_vst_host(PluginArchitecture plugin_arch) {
} }
fs::path host_path = fs::path host_path =
fs::canonical(boost::dll::this_line_location()).remove_filename() / fs::canonical(get_this_file_location()).remove_filename() / host_name;
host_name;
if (fs::exists(host_path)) { if (fs::exists(host_path)) {
return host_path; return host_path;
} }
@@ -728,7 +732,7 @@ fs::path find_vst_host(PluginArchitecture plugin_arch) {
fs::path find_vst_plugin() { fs::path find_vst_plugin() {
const fs::path this_plugin_path = const fs::path this_plugin_path =
"/" / fs::path("/" + boost::dll::this_line_location().string()); "/" / fs::path("/" + get_this_file_location().string());
fs::path plugin_path(this_plugin_path); fs::path plugin_path(this_plugin_path);
plugin_path.replace_extension(".dll"); plugin_path.replace_extension(".dll");
@@ -786,6 +790,17 @@ fs::path generate_endpoint_name() {
return candidate_endpoint; return candidate_endpoint;
} }
fs::path get_this_file_location() {
// HACK: Not sure why, but `boost::dll::this_line_location()` returns a path
// starting with a double slash on some systems. I've seen this happen
// on both Ubuntu 18.04 and 20.04, but not on Arch based distros.
// Under Linux a path starting with two slashes is treated the same as
// a path starting with only a single slash, but Wine will refuse to
// load any files when the path starts with two slashes. Prepending
// `/` to a pad coerces theses two slashes into a single slash.
return "/" / boost::dll::this_line_location();
}
bp::environment set_wineprefix() { bp::environment set_wineprefix() {
auto env = boost::this_process::environment(); auto env = boost::this_process::environment();