yabridge, yabridgectl: 3.8.1 → 4.0.0

This commit is contained in:
Kira Bruneau 2022-07-06 09:56:07 -04:00
parent 85deee6d6c
commit 5d9749589d
6 changed files with 178 additions and 74 deletions

View File

@ -8,17 +8,24 @@
, ninja
, pkg-config
, wine
, boost
, libxcb
, nix-update-script
}:
let
# Derived from subprojects/asio.wrap
asio = fetchFromGitHub {
owner = "chriskohlhoff";
repo = "asio";
rev = "asio-1-22-1";
sha256 = "sha256-UDLhx2yI6Txg0wP5H4oNIhgKIB2eMxUGCyT2x/7GgVg=";
};
# Derived from subprojects/bitsery.wrap
bitsery = fetchFromGitHub {
owner = "fraillt";
repo = "bitsery";
rev = "c0fc083c9de805e5825d7553507569febf6a6f93";
rev = "v5.2.2";
sha256 = "sha256-VwzVtxt+E/SVcxqIJw8BKPO2q7bu/hkhY+nB7FHrZpY=";
};
@ -26,15 +33,23 @@ let
function2 = fetchFromGitHub {
owner = "Naios";
repo = "function2";
rev = "02ca99831de59c7c3a4b834789260253cace0ced";
rev = "4.2.0";
sha256 = "sha256-wrt+fCcM6YD4ZRZYvqqB+fNakCNmltdPZKlNkPLtgMs=";
};
# Derived from subprojects/ghc_filesystem.wrap
ghc_filesystem = fetchFromGitHub {
owner = "gulrak";
repo = "filesystem";
rev = "v1.5.12";
sha256 = "sha256-j4RE5Ach7C7Kef4+H9AHSXa2L8OVyJljDwBduKcC4eE=";
};
# Derived from subprojects/tomlplusplus.wrap
tomlplusplus = fetchFromGitHub {
owner = "marzer";
repo = "tomlplusplus";
rev = "8e669aa6990e0ed219c169d491472d749f54c393";
rev = "v3.0.1";
sha256 = "sha256-l8ckbCqjz3GUfwStcl3H2C+un5dZfT2uLtayvdu93D4=";
};
@ -42,29 +57,29 @@ let
vst3 = fetchFromGitHub {
owner = "robbert-vdh";
repo = "vst3sdk";
rev = "v3.7.4_build_25-patched";
rev = "v3.7.5_build_44-patched";
fetchSubmodules = true;
sha256 = "sha256-oHRJZItw+he5M+beVZkUrhJir6rgFZ80ORzA73mJT2A=";
sha256 = "sha256-6cuEUa+BXa6MnAYIBq873n0NRLadcPfMX+kpf4ysE6M=";
};
in multiStdenv.mkDerivation rec {
pname = "yabridge";
version = "3.8.1";
version = "4.0.0";
# NOTE: Also update yabridgectl's cargoHash when this is updated
src = fetchFromGitHub {
owner = "robbert-vdh";
repo = pname;
rev = version;
sha256 = "sha256-5Mi/aIjOKbn7guTj+AKGQRv+k7w4gzfdA9Mw4ocUlOE=";
sha256 = "sha256-L1YOeAYlq640CJZThW6euiOyrX0TeVbhZ3k/ZsmUC8I=";
};
# Unpack subproject sources
postUnpack = ''(
cd "$sourceRoot/subprojects"
cp -R --no-preserve=mode,ownership ${asio} asio
cp -R --no-preserve=mode,ownership ${bitsery} bitsery
cp packagefiles/bitsery/* bitsery
cp -R --no-preserve=mode,ownership ${function2} function2
cp packagefiles/function2/* function2
cp -R --no-preserve=mode,ownership ${ghc_filesystem} ghc_filesystem
cp -R --no-preserve=mode,ownership ${tomlplusplus} tomlplusplus
cp -R --no-preserve=mode,ownership ${vst3} vst3
)'';
@ -73,14 +88,23 @@ in multiStdenv.mkDerivation rec {
# Hard code bitbridge & runtime dependencies
(substituteAll {
src = ./hardcode-dependencies.patch;
boost32 = pkgsi686Linux.boost;
libxcb32 = pkgsi686Linux.xorg.libxcb;
inherit libnotify wine;
})
# Patch the chainloader to search for libyabridge through NIX_PROFILES
./libyabridge-from-nix-profiles.patch
];
postPatch = ''
patchShebangs .
(
cd subprojects
cp packagefiles/asio/* asio
cp packagefiles/bitsery/* bitsery
cp packagefiles/function2/* function2
cp packagefiles/ghc_filesystem/* ghc_filesystem
)
'';
nativeBuildInputs = [
@ -91,18 +115,12 @@ in multiStdenv.mkDerivation rec {
];
buildInputs = [
boost
libxcb
];
# Meson is no longer able to pick up Boost automatically.
# https://github.com/NixOS/nixpkgs/issues/86131
BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";
mesonFlags = [
"--cross-file" "cross-wine.conf"
"-Dwith-bitbridge=true"
"-Dbitbridge=true"
# Requires CMake and is unnecessary
"-Dtomlplusplus:generate_cmake_config=false"
@ -111,10 +129,8 @@ in multiStdenv.mkDerivation rec {
installPhase = ''
runHook preInstall
mkdir -p "$out/bin" "$out/lib"
cp yabridge-group*.exe{,.so} "$out/bin"
cp yabridge-host*.exe{,.so} "$out/bin"
cp libyabridge-vst2.so "$out/lib"
cp libyabridge-vst3.so "$out/lib"
cp yabridge-host{,-32}.exe{,.so} "$out/bin"
cp libyabridge{,-chainloader}-{vst2,vst3}.so "$out/lib"
runHook postInstall
'';
@ -131,8 +147,8 @@ in multiStdenv.mkDerivation rec {
};
meta = with lib; {
description = "Yet Another VST bridge, run Windows VST2 plugins under Linux";
homepage = "https://github.com/robbert-vdh/yabridge";
description = "A modern and transparent way to use Windows VST2 and VST3 plugins on Linux";
homepage = src.meta.homepage;
license = licenses.gpl3Plus;
maintainers = with maintainers; [ kira-bruneau ];
platforms = [ "x86_64-linux" ];

View File

@ -1,16 +1,8 @@
diff --git a/meson.build b/meson.build
index c71d4fdb..b3f381ba 100644
index 8e1b8bfd..0696bfe6 100644
--- a/meson.build
+++ b/meson.build
@@ -201,6 +201,7 @@ if with_32bit_libraries or with_bitbridge
'boost_filesystem',
static : with_static_boost,
dirs : [
+ '@boost32@/lib',
# Used by Arch based distros
'/usr/local/lib32',
'/usr/lib32',
@@ -224,7 +225,7 @@ if is_64bit_system
@@ -186,7 +186,7 @@ if is_64bit_system
xcb_64bit_dep = dependency('xcb')
endif
if with_32bit_libraries or with_bitbridge
@ -19,25 +11,29 @@ index c71d4fdb..b3f381ba 100644
endif
# These are all headers-only libraries, and thus won't require separate 32-bit
diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp
index fc2c8b25..c73249e3 100644
--- a/src/plugin/utils.cpp
+++ b/src/plugin/utils.cpp
@@ -107,7 +107,7 @@ std::string PluginInfo::wine_version() const {
access(wineloader_path.c_str(), X_OK) == 0) {
wine_path = wineloader_path;
} else {
- wine_path = bp::search_path("wine").string();
+ wine_path = "@wine@/bin/wine";
diff --git a/src/common/notifications.cpp b/src/common/notifications.cpp
index da27a1bf..18482e06 100644
--- a/src/common/notifications.cpp
+++ b/src/common/notifications.cpp
@@ -49,7 +49,7 @@ bool send_notification(const std::string& title,
}
}
bp::ipstream output;
@@ -436,7 +436,7 @@ Configuration load_config_for(const fs::path& yabridge_path) {
bool send_notification(const std::string& title,
const std::string body,
bool append_origin) {
- const fs::path notify_send_path = bp::search_path("notify-send");
+ const fs::path notify_send_path = "@libnotify@/bin/notify-send";
if (notify_send_path.empty()) {
return false;
}
- Process process("notify-send");
+ Process process("@libnotify@/bin/notify-send");
process.arg("--urgency=normal");
process.arg("--app-name=yabridge");
process.arg(title);
diff --git a/src/plugin/utils.cpp b/src/plugin/utils.cpp
index ae2a7b43..5a0d61e1 100644
--- a/src/plugin/utils.cpp
+++ b/src/plugin/utils.cpp
@@ -93,7 +93,7 @@ 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. We'll be using `execvpe`
- std::string wine_path = "wine";
+ std::string wine_path = "@wine@/bin/wine";
// NOLINTNEXTLINE(concurrency-mt-unsafe)
if (const char* wineloader_path = getenv("WINELOADER");
wineloader_path && access(wineloader_path, X_OK) == 0) {

View File

@ -0,0 +1,71 @@
diff --git a/src/chainloader/utils.cpp b/src/chainloader/utils.cpp
index ccd65d33..c7136b37 100644
--- a/src/chainloader/utils.cpp
+++ b/src/chainloader/utils.cpp
@@ -29,8 +29,10 @@
namespace fs = ghc::filesystem;
void* find_plugin_library(const std::string& name) {
+ Logger logger = Logger::create_exception_logger();
+
// Just using a goto for this would probably be cleaner, but yeah...
- const auto impl = [&name]() -> void* {
+ const auto impl = [&name, &logger]() -> void* {
// If `name` exists right next to the Wine plugin host binary, then
// we'll try loading that. Otherwise we'll fall back to regular
// `dlopen()` for distro packaged versions of yabridge
@@ -52,27 +54,28 @@ void* find_plugin_library(const std::string& name) {
}
}
- if (void* handle = dlopen(name.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
- return handle;
+ auto nix_profiles = getenv("NIX_PROFILES");
+ if (!nix_profiles || nix_profiles[0] == '\0') {
+ logger.log("");
+ logger.log("ERROR: 'NIX_PROFILES' environment variable is not set");
+ logger.log("");
+ return nullptr;
}
- // One last Hail Mary, in case ldconfig was not set up correctly. This
- // might be relevant for some of the `/usr/local/*` locations (although
- // you really, really shouldn't install yabridge there, please, thank
- // you). Yabridgectl searches through these same directories.
- for (const auto& lib_dir : {
- "/usr/lib",
- "/usr/lib/x86_64-linux-gnu",
- "/usr/lib64",
- "/usr/local/lib",
- "/usr/local/lib/x86_64-linux-gnu",
- "/usr/local/lib64",
- }) {
- const fs::path candidate = fs::path(lib_dir) / name;
- if (void* handle =
- dlopen(candidate.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
+ // NIX_PROFILES is iterated in reverse from the most specific (the
+ // user profile) to the least specific (the system profile).
+ const std::string_view nix_profiles_view = nix_profiles;
+ auto segment_end = nix_profiles_view.size();
+ while (segment_end != std::string::npos) {
+ const auto next_segment_end = nix_profiles_view.rfind(' ', segment_end - 1);
+ const auto segment_begin = next_segment_end + 1;
+ const auto profile = nix_profiles_view.substr(segment_begin, segment_end - segment_begin);
+ const auto candidate = fs::path(profile) / "lib" / name;
+ if (auto handle = dlopen(candidate.c_str(), RTLD_LAZY | RTLD_LOCAL)) {
return handle;
}
+
+ segment_end = next_segment_end;
}
return nullptr;
@@ -82,8 +85,6 @@ void* find_plugin_library(const std::string& name) {
if (!handle) {
const fs::path this_plugin_path = get_this_file_location();
- Logger logger = Logger::create_exception_logger();
-
logger.log("");
logger.log("Could not find '" + name + "'");
logger.log("");

View File

@ -1,23 +1,23 @@
diff --git a/tools/yabridgectl/src/config.rs b/tools/yabridgectl/src/config.rs
index bc5f6a81..0fcd38d3 100644
index 523a083b..399302e0 100644
--- a/tools/yabridgectl/src/config.rs
+++ b/tools/yabridgectl/src/config.rs
@@ -23,6 +23,7 @@ use std::collections::{BTreeMap, BTreeSet, HashSet};
@@ -22,6 +22,7 @@ use serde_derive::{Deserialize, Serialize};
use std::collections::{BTreeMap, BTreeSet, HashSet};
use std::env;
use std::fmt::Display;
use std::fs;
+use std::iter;
use std::path::{Path, PathBuf};
use which::which;
use xdg::BaseDirectories;
@@ -235,34 +236,27 @@ impl Config {
@@ -213,34 +214,27 @@ impl Config {
}
}
None => {
- // Search in the system library locations and in `~/.local/share/yabridge` if no
- // path was set explicitely. We'll also search through `/usr/local/lib` just in case
- // but since we advocate against installing yabridge there we won't list this path
- // in the error message when `libyabridge-vst2.so` can't be found.
- // in the error message when `libyabridge-chainloader-vst2.so` can't be found.
- let system_path = Path::new("/usr/lib");
+ // Search through NIX_PROFILES & data home directory if no path was set explicitly.
+ // NIX_PROFILES is iterated in reverse from the most specific (the user profile) to
@ -43,7 +43,7 @@ index bc5f6a81..0fcd38d3 100644
+
let mut candidates = lib_directories
- .iter()
.map(|directory| directory.join(LIBYABRIDGE_VST2_NAME));
.map(|directory| directory.join(VST2_CHAINLOADER_NAME));
+
match candidates.find(|directory| directory.exists()) {
Some(candidate) => candidate,
@ -53,21 +53,21 @@ index bc5f6a81..0fcd38d3 100644
- default search path using 'yabridgectl set --path=<path>'.",
+ "Could not find '{}' through 'NIX_PROFILES' or '{}'. You can override the \
+ default search path using 'yabridgectl set --path=<path>'.",
LIBYABRIDGE_VST2_NAME,
VST2_CHAINLOADER_NAME,
- system_path.display(),
user_path.display()
));
}
diff --git a/tools/yabridgectl/src/main.rs b/tools/yabridgectl/src/main.rs
index 48cce4fa..209e40e4 100644
index 302ff8ae..9d9bbeac 100644
--- a/tools/yabridgectl/src/main.rs
+++ b/tools/yabridgectl/src/main.rs
@@ -151,7 +151,7 @@ fn main() -> Result<()> {
.help("Path to the directory containing 'libyabridge-{vst2,vst3}.so'")
@@ -130,7 +130,7 @@ fn main() -> Result<()> {
.help("Path to the directory containing 'libyabridge-chainloader-{vst2,vst3}.so'")
.long_help(
"Path to the directory containing 'libyabridge-{vst2,vst3}.so'. If this \
- is not set, then yabridgectl will look in both '/usr/lib' and \
+ is not set, then yabridgectl will look through 'NIX_PROFILES' and \
"Path to the directory containing 'libyabridge-chainloader-{vst2,vst3}.so'. \
- If this is not set, then yabridgectl will look in both '/usr/lib' and \
+ If this is not set, then yabridgectl will look through 'NIX_PROFILES' and \
'~/.local/share/yabridge' by default.",
)
.validator(validate_path)

View File

@ -11,13 +11,14 @@ rustPlatform.buildRustPackage rec {
src = yabridge.src;
sourceRoot = "source/tools/yabridgectl";
cargoSha256 = "sha256-ducF55d5OvCwlNFtt2r6pG5e9VevM2AzHSvPnWvIp1Y=";
cargoSha256 = "sha256-o3VavYIeWLXomQ33DWRpmHSSUoRb8je2JyZH4yF+kwk=";
patches = [
# By default, yabridgectl locates libyabridge.so by using
# hard coded distro specific lib paths. This patch replaces those
# hard coded paths with lib paths from NIX_PROFILES.
./libyabridge-from-nix-profiles.patch
# Patch yabridgectl to search for the chainloader through NIX_PROFILES
./chainloader-from-nix-profiles.patch
# Dependencies are hardcoded in yabridge, so the check is unnecessary and likely incorrect
./remove-dependency-verification.patch
];
patchFlags = [ "-p3" ];
@ -26,12 +27,14 @@ rustPlatform.buildRustPackage rec {
postFixup = ''
wrapProgram "$out/bin/yabridgectl" \
--prefix PATH : ${lib.makeBinPath [ wine ]}
--prefix PATH : ${lib.makeBinPath [
wine # winedump
]}
'';
meta = with lib; {
description = "A small, optional utility to help set up and update yabridge for several directories at once";
homepage = "https://github.com/robbert-vdh/yabridge/tree/master/tools/yabridgectl";
homepage = "${src.meta.homepage}/tree/${version}/tools/yabridgectl";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ kira-bruneau ];
platforms = yabridge.meta.platforms;

View File

@ -0,0 +1,18 @@
diff --git a/tools/yabridgectl/src/actions.rs b/tools/yabridgectl/src/actions.rs
index 848bc867..e363a93a 100644
--- a/tools/yabridgectl/src/actions.rs
+++ b/tools/yabridgectl/src/actions.rs
@@ -674,13 +674,6 @@ pub fn do_sync(config: &mut Config, options: &SyncOptions) -> Result<()> {
// be the case if we get to this point though.
verify_path_setup(config)?;
- // This check is only performed once per combination of Wine and yabridge versions
- verify_wine_setup(config)?;
-
- // Yabridge uses notify-send to relay important information when something's very wrong, so
- // we'll check whether this is installed
- verify_external_dependencies()?;
-
Ok(())
}