mirror of
https://github.com/robbert-vdh/yabridge.git
synced 2026-05-17 14:10:02 +02:00
Run $WINELOADER --version under the correct env
This makes the initialization message reflect the correct Wine version when using a `WINELOADER` script to change between Wine versions depending on the Wine prefix.
This commit is contained in:
+39
-35
@@ -24,6 +24,10 @@
|
||||
#include <boost/process/system.hpp>
|
||||
#include <sstream>
|
||||
|
||||
// XXX: With Boost 1.75 at least, this header cannot be included in alphabetical
|
||||
// order because it's missing some includes
|
||||
#include <boost/process/env.hpp>
|
||||
|
||||
// Generated inside of the build directory
|
||||
#include <src/common/config/config.h>
|
||||
|
||||
@@ -90,6 +94,41 @@ boost::filesystem::path PluginInfo::normalize_wine_prefix() const {
|
||||
wine_prefix);
|
||||
}
|
||||
|
||||
std::string PluginInfo::wine_version() const {
|
||||
// The '*.exe' scripts generated by winegcc allow you to override the binary
|
||||
// used to run Wine, so will will handle this in the same way for our Wine
|
||||
// version detection
|
||||
fs::path wine_path;
|
||||
bp::environment env = create_host_env();
|
||||
if (const std::string wineloader_path = env["WINELOADER"].to_string();
|
||||
access(wineloader_path.c_str(), X_OK) == 0) {
|
||||
wine_path = wineloader_path;
|
||||
} else {
|
||||
wine_path = bp::search_path("wine").string();
|
||||
}
|
||||
|
||||
bp::ipstream output;
|
||||
try {
|
||||
bp::system(wine_path, "--version", bp::std_out = output);
|
||||
} catch (const std::system_error&) {
|
||||
return "<NOT FOUND>";
|
||||
}
|
||||
|
||||
// `wine --version` might contain additional output in certain custom Wine
|
||||
// builds, so we only want to look at the first line
|
||||
std::string version_string;
|
||||
std::getline(output, version_string);
|
||||
|
||||
// Strip the `wine-` prefix from the output, could potentially be absent in
|
||||
// custom Wine builds
|
||||
constexpr std::string_view version_prefix("wine-");
|
||||
if (version_string.starts_with(version_prefix)) {
|
||||
version_string = version_string.substr(version_prefix.size());
|
||||
}
|
||||
|
||||
return version_string;
|
||||
}
|
||||
|
||||
fs::path find_plugin_library(const fs::path& this_plugin_path,
|
||||
PluginType plugin_type,
|
||||
bool prefer_32bit_vst3) {
|
||||
@@ -341,41 +380,6 @@ std::vector<boost::filesystem::path> get_augmented_search_path() {
|
||||
return search_path;
|
||||
}
|
||||
|
||||
std::string get_wine_version() {
|
||||
// The '*.exe' scripts generated by winegcc allow you to override the binary
|
||||
// used to run Wine, so will will handle this in the same way for our Wine
|
||||
// version detection
|
||||
fs::path wine_path;
|
||||
bp::environment env = boost::this_process::environment();
|
||||
if (const std::string wineloader_path = env["WINELOADER"].to_string();
|
||||
access(wineloader_path.c_str(), X_OK) == 0) {
|
||||
wine_path = wineloader_path;
|
||||
} else {
|
||||
wine_path = bp::search_path("wine").string();
|
||||
}
|
||||
|
||||
bp::ipstream output;
|
||||
try {
|
||||
bp::system(wine_path, "--version", bp::std_out = output);
|
||||
} catch (const std::system_error&) {
|
||||
return "<NOT FOUND>";
|
||||
}
|
||||
|
||||
// `wine --version` might contain additional output in certain custom Wine
|
||||
// builds, so we only want to look at the first line
|
||||
std::string version_string;
|
||||
std::getline(output, version_string);
|
||||
|
||||
// Strip the `wine-` prefix from the output, could potentially be absent in
|
||||
// custom Wine builds
|
||||
constexpr std::string_view version_prefix("wine-");
|
||||
if (version_string.starts_with(version_prefix)) {
|
||||
version_string = version_string.substr(version_prefix.size());
|
||||
}
|
||||
|
||||
return version_string;
|
||||
}
|
||||
|
||||
Configuration load_config_for(const fs::path& yabridge_path) {
|
||||
// First find the closest `yabridge.tmol` file for the plugin, falling back
|
||||
// to default configuration settings if it doesn't exist
|
||||
|
||||
Reference in New Issue
Block a user