diff mbox series

[bug#63065,07/18] gnu: Add yabridge.

Message ID GbYndPgckH86xp7Vvhx6o_nppxczXkXkVg8umTV378DV0erNJieHXDBp7IYbHJEnvhEi15XSa8UnnN4JJ_wH0Yybyq-iOzBxHfjTB0cZykY=@proton.me
State New
Headers show
Series : gnu: Add yabridgectl. | expand

Commit Message

Sughosha April 25, 2023, 9:30 a.m. UTC
* gnu/packages/audio.scm (yabridge): New variable.
* gnu/packages/patches/yabridge-5.0.4-fix-dependency-search.patch:
New file.
* gnu/local.mk: Register the patch file.
---
 gnu/local.mk                                  |   1 +
 gnu/packages/audio.scm                        | 114 ++++++++++++++++++
 ...yabridge-5.0.4-fix-dependency-search.patch |  45 +++++++
 3 files changed, 160 insertions(+)
 create mode 100644 gnu/packages/patches/yabridge-5.0.4-fix-dependency-search.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index b53a04a0cd..2bafdc7f02 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -2038,6 +2038,7 @@  dist_patch_DATA =						\
   %D%/packages/patches/xsane-tighten-default-umask.patch	\
   %D%/packages/patches/xterm-370-explicit-xcursor.patch		\
   %D%/packages/patches/xygrib-fix-finding-data.patch		\
+  %D%/packages/patches/yabridge-5.0.4-fix-dependency-search.patch	\
   %D%/packages/patches/yggdrasil-extra-config.patch	\
   %D%/packages/patches/zig-use-system-paths.patch
 
diff --git a/gnu/packages/audio.scm b/gnu/packages/audio.scm
index 9e111a3b9e..551c9193c6 100644
--- a/gnu/packages/audio.scm
+++ b/gnu/packages/audio.scm
@@ -70,7 +70,9 @@  (define-module (gnu packages audio)
   #:use-module (gnu packages boost)
   #:use-module (gnu packages build-tools)
   #:use-module (gnu packages check)
+  #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages dbm)
   #:use-module (gnu packages documentation)
@@ -129,6 +131,7 @@  (define-module (gnu packages audio)
   #:use-module (gnu packages vim) ;xxd
   #:use-module (gnu packages web)
   #:use-module (gnu packages webkit)
+  #:use-module (gnu packages wine)
   #:use-module (gnu packages wxwidgets)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xiph)
@@ -3449,6 +3452,117 @@  (define-public vst3sdk
                    ;; and vstgui
                    license:bsd-3))))
 
+(define-public yabridge
+  (package
+    (name "yabridge")
+    (version "5.0.4")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/robbert-vdh/yabridge")
+                    (commit version)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "08p92a2qx5k2531wr38mrksn7g16j0mz611rwla1m0igfc4r75fp"))
+              (modules '((guix build utils)))
+              (snippet '(delete-file-recursively "subprojects"))
+              (patches
+               (search-patches
+                "yabridge-5.0.4-fix-dependency-search.patch"))))
+    (build-system meson-build-system)
+    (arguments
+     (list #:configure-flags #~(list "-Dbitbridge=false" ;TODO: enable it
+                                     (string-append "--cross-file="
+                                                    #$source
+                                                    "/cross-wine.conf"))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'link-vst3sdk
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            (mkdir-p "subprojects")
+                            (symlink (assoc-ref inputs "vst3sdk")
+                                     "subprojects/vst3")))
+                        (replace 'install
+                          (lambda _
+                            (let ((bin (string-append #$output "/bin"))
+                                  (lib (string-append #$output "/lib")))
+                              (for-each
+                                (lambda (file)
+                                  (install-file file bin))
+                                (find-files "." "-host(|-32)\\.exe(|\\.so)$"))
+                              (for-each
+                                (lambda (file)
+                                  (install-file file lib))
+                                (find-files "." "libyabridge")))))
+                        (add-after 'unpack 'fix-loading-wine-libs
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            (let ((wine #$(match (%current-system)
+                                            ((or "x86_64-linux" "aarch64-linux")
+                                             "wine64")
+                                            (_ "wine32")))
+                                  (arch #$(match (%current-system)
+                                            ((or "x86_64-linux" "aarch64-linux")
+                                             "x86_64-unix")
+                                            (_ "i386-unix"))))
+                              (substitute* "meson.build"
+                                (("-lole32")
+                                 (search-input-file inputs
+                                                    (string-append "/lib/"
+                                                     wine "/wine/" arch
+                                                     "/libole32.a")))
+                                (("-lshell32")
+                                 (search-input-file inputs
+                                                    (string-append "/lib/"
+                                                     wine "/wine/" arch
+                                                     "/libshell32.a")))
+                                (("-luuid")
+                                 (search-input-file inputs
+                                                    (string-append "/lib/"
+                                                     wine "/wine/" arch
+                                                     "/libuuid.a"))))))))))
+    (native-inputs
+     `(("clap" ,clap)
+       ("cmake-minimal" ,cmake-minimal)
+       ("function2" ,function2)
+       ("gulrak-filesystem" ,gulrak-filesystem)
+       ("pkg-config" ,pkg-config)
+       ("tomlplusplus" ,tomlplusplus)
+       ;; This is VST3 SDK v3.7.7_build_19 with the documentation and VSTGUI
+       ;; submodules removed and a dummy `meson.build` file that just lists all
+       ;; source files.
+       ("vst3sdk"
+        ,(origin
+           (method git-fetch)
+           (uri (git-reference
+                 (url "https://github.com/robbert-vdh/vst3sdk")
+                 (commit (string-append "v3.7.7_build_19-patched"))
+                 ;; Required for vst3_base, vst3_pluginterfaces,
+                 ;; and vst3_public_sdk.
+                 (recursive? #t)))
+           (file-name (git-file-name name version))
+           (sha256
+            (base32
+             "09axvpshwbf5061kcbl26v74dcmwxmgmlxb15b75bnqbh0zcghrf"))
+           (patches
+            (search-patches
+             "vst3sdk-3.7.7-allow-winelib-compilation.patch"))))))
+    (inputs (list asio bitsery dbus libxcb
+                  (match (%current-system)
+                    ((or "x86_64-linux" "aarch64") wine64)
+                    (_ wine))))
+    ;; Platforms supported by wine and wine64 should support.
+    (supported-systems
+     (list "i686-linux" "x86_64-linux" "armhf-linux" "aarch64-linux"))
+    (home-page "https://github.com/robbert-vdh/yabridge")
+    (synopsis "Implementation of Windows VST2, VST3 and CLAP plugin APIs")
+    (description
+     "@code{yabridge} is Yet Another way to use Windows audio plugins.  It
+supports using both 32-bit and 64-bit Windows VST2, VST3, and CLAP plugins in
+64-bit Linux plugin hosts as if they were native plugins, with optional support
+for plugin groups to enable inter-plugin communication for VST2 plugins and
+quick startup times.")
+    (license license:gpl3+)))
+
 (define-public patchage
   (package
     (name "patchage")
diff --git a/gnu/packages/patches/yabridge-5.0.4-fix-dependency-search.patch b/gnu/packages/patches/yabridge-5.0.4-fix-dependency-search.patch
new file mode 100644
index 0000000000..a9e1ed1c62
--- /dev/null
+++ b/gnu/packages/patches/yabridge-5.0.4-fix-dependency-search.patch
@@ -0,0 +1,45 @@ 
+Meson fails to detect bitsery, function2 and gulrak-filesystem.
+https://github.com/robbert-vdh/yabridge/issues/18
+
+From c3cb50cff354c585afc3c94e676ac50a420e871b Mon Sep 17 00:00:00 2001
+From: Sughosha <sughosha@proton.me>
+Date: Sun, 23 Apr 2023 08:44:50 +0200
+Subject: [PATCH] Fix dependency search
+
+---
+ meson.build | 15 +++------------
+ 1 file changed, 3 insertions(+), 12 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index f76f5acf..ca85af68 100644
+--- a/meson.build
++++ b/meson.build
+@@ -248,22 +248,13 @@ else
+   asio_dep = dependency('asio', version : '>=1.22.0')
+ endif
+ 
+-if meson.version().version_compare('>=0.60')
+-  # Bitsery's CMake build definition is capitalized for some reason
+-  bitsery_dep = dependency('bitsery', 'Bitsery', version : '>=5.2.0')
+-else
+-  # Mmeson <=0.6.0 didn't support multiple names for a dependency, and since at
+-  # the moment this is only relevant for packing on Arch btw, it's probably
+-  # better to remove this conditional later than it is to bump the minimum Meson
+-  # version now.
+-  bitsery_dep = dependency('bitsery', version : '>=5.2.0')
+-endif
++bitsery_dep = declare_dependency()
+ 
+ # The D-Bus headers are also only accessed through the include path. We don't
+ # link to libdbus-1 to make soname changes don't completely break yabridge.
+ dbus_dep = dependency('dbus-1').partial_dependency(compile_args : true, includes : true)
+-function2_dep = dependency('function2', version : '>=4.0.0')
+-ghc_filesystem_dep = dependency('ghc_filesystem', modules : 'ghcFilesystem::ghc_filesystem', version : '>=1.5.0')
++function2_dep = declare_dependency()
++ghc_filesystem_dep = declare_dependency()
+ threads_dep = dependency('threads')
+ # Tomlplusplus recently added a shraed library version. We don't want to link to that.
+ tomlplusplus_dep = dependency('tomlplusplus', version : '>=3.3.0', default_options : ['compile_library=false']).partial_dependency(compile_args : true, includes : true)
+-- 
+2.39.2
+