Subject: [bug#57984] [PATCH] gnu: Update zynaddsubfx to 3.0.6

From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 14:14:42 +0000

Empty Message

From 2830ada1a24ec2051d865ed84fbf18ec07fedbc7 Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:54:10 +0200
Subject: [PATCH 2/4] gnu: Add font-entypo

* gnu/packages/music.scm (font-entypo): New variable.
---
 gnu/packages/fonts.scm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/gnu/packages/fonts.scm b/gnu/packages/fonts.scm
index 2d653abf32..639d2fa2b9 100644
--- a/gnu/packages/fonts.scm
+++ b/gnu/packages/fonts.scm
@@ -2882,3 +2882,27 @@ (define-public font-chiron-hei-hk
 Kong variant of Adobe’s Source Han Sans.  The font aims at providing a modern,
 region-agnostic glyph set adopting the “modern” glyph style that is similar to
 prevalent typefaces in Traditional Chinese regions.")))
+
+(define-public font-entypo
+  (let ((commit "f94e077449daa87321aa0df5643889460ba8291b")
+        (revision "117"))
+    (package
+      (name "font-entypo")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/danielbruce/entypo")
+               (commit commit)))
+         (sha256
+          (base32
+           "0kgy2ia15q93ksh6kbj8p5n44mmmax95w6a5byimbvcqajmvv7m6"))))
+      (build-system font-build-system)
+      (home-page "https://entypo.com")
+      (synopsis "Entypo font")
+      (description
+       "Entypo font is a pictogram suite.")
+      ;; Icons are distributed under CC-BY-SA 3.0 and fonts are distributed
+      ;; under SIL OFL.
+      (license (list license:cc-by-sa3.0 license:silofl1.1)))))
-- 
2.38.0

From 221e0b7ff0c80b6cb08c33738aed85a6da82b5da Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:52:19 +0200
Subject: [PATCH 1/4] gnu: Add nanovg

* gnu/packages/music.scm (nanovg): New variable.
---
 gnu/packages/music.scm | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 6b37c79389..42d853fc8c 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -2989,6 +2989,43 @@ (define-public vmpk
 instrument or MIDI file player.")
     (license license:gpl3+)))
 
+(define-public nanovg
+  (let ((commit "b83cf926525e7cea8d2483da2a75852b8c7b6d28")
+        (revision "268"))
+    (package
+      (name "nanovg")
+      (version (git-version "0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/memononen/nanovg")
+                      (commit commit)))
+                (sha256
+                 (base32
+                  "1zp355pw6xnb5mjarz67cxkglv7j1s0qzv705fz1wf0gl0sjhy8f"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list #:tests? #f ;no test suite
+             #:phases #~(modify-phases %standard-phases
+                          (delete 'configure)
+                          (replace 'build
+                            (lambda _
+                              (invoke #$(cc-for-target) "src/nanovg.c" "-c"
+                                      "-fPIC")))
+                          (replace 'install
+                            (lambda _
+                              (let ((lib (string-append #$output "/lib")))
+                                (mkdir-p lib)
+                                (invoke "ar" "rc"
+                                        (string-append lib "/libnanovg.a")
+                                        "nanovg.o")))))))
+      (home-page "https://github.com/memononen/nanovg")
+      (synopsis "Antialiased 2D vector drawing library")
+      (description
+       "NanoVG is small antialiased vector graphics rendering library for
+OpenGL.  It has lean API modeled after HTML5 canvas API.")
+      (license license:zlib))))
+
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-- 
2.38.0

From 5fe2faa09f06f9a0231907522291926e93036509 Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:56:23 +0200
Subject: [PATCH 3/4] gnu: Add mruby-zest

* gnu/packages/music.scm (mruby-zest): New variable.
---
 gnu/packages/music.scm | 104 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 104 insertions(+)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 42d853fc8c..1ae54033c0 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -167,6 +167,7 @@ (define-module (gnu packages music)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages rsync)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages sphinx)
@@ -3026,6 +3027,109 @@ (define-public nanovg
 OpenGL.  It has lean API modeled after HTML5 canvas API.")
       (license license:zlib))))
 
+(define-public mruby-zest
+  (package
+    (name "mruby-zest")
+    (version "3.0.6")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/mruby-zest/mruby-zest-build")
+                    (commit version)
+                    ;; TODO: package mruby gems seperately.
+                    (recursive? #t)))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "0dz4zv1km9805lji2q2qqdd8s8hgfd723dxdzcivbhm612szm1mc"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list #:tests? #f ;no test suite
+           #:make-flags #~(list (string-append "CC="
+                                               #$(cc-for-target))
+                                "CONFIG_SHELL=bash")
+           #:phases #~(modify-phases %standard-phases
+                        (delete 'configure) ;no configure script
+                        (add-after 'unpack 'use-installed-libs
+                          (lambda _
+                            (substitute* "Makefile"
+                              (("cd deps/nanovg")
+                               "#cd deps/nanovg")
+                              (("\\$\\(AR\\) rc deps/libnanovg\\.a")
+                               "#\\$\\(AR\\) rc deps/libnanovg\\.a")
+                              (("cd deps/mruby-file-stat")
+                               "#cd deps/mruby-file-stat")
+                              (("\\./deps/libnanovg\\.a")
+                               "-lnanovg"))
+                            (substitute* "build_config.rb"
+                              (("#\\{`pwd`\\.strip\\}/\\.\\./deps/libnanovg\\.a")
+                               (string-append #$nanovg "/lib/libnanovg\\.a")))))
+                        (add-after 'unpack 'disable-unused-deps
+                          (lambda _
+                            (substitute* "build_config.rb"
+                              (("conf\\.gem 'deps/mruby-file-stat'")
+                               "#"))
+                            (substitute* "deps/mruby-dir-glob/mrbgem.rake"
+                              (("spec\\.add_dependency 'mruby-file-stat'")
+                               "#"))))
+                        (replace 'install
+                          (lambda _
+                            (let* ((lib (string-append #$output
+                                                       "/lib/zyn-fusion"))
+                                   (font (string-append lib "/font"))
+                                   (qml (string-append lib "/qml"))
+                                   (roboto (string-append #$font-google-roboto
+                                            "/share/fonts/truetype"))
+                                   (bin (string-append #$output "/bin")))
+                              ;; Hardcoded to use these font in this path.
+                              (mkdir-p (string-append lib "/font"))
+                              (symlink (string-append #$font-entypo
+                                                      "/share/fonts/truetype"
+                                                      "/entypo.ttf")
+                                       (string-append font "/entypo.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Bold.ttf")
+                                       (string-append font "/Roboto-Bold.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Light.ttf")
+                                       (string-append font "/Roboto-Light.ttf"))
+                              (symlink (string-append roboto
+                                                      "/Roboto-Regular.ttf")
+                                       (string-append font
+                                                      "/Roboto-Regular.ttf"))
+                              (copy-recursively "src/mruby-zest/qml" qml)
+                              (copy-recursively "src/mruby-zest/example" qml)
+                              (install-file "src/osc-bridge/schema/test.json"
+                                            (string-append lib "/schema"))
+                              (install-file "libzest.so" lib)
+                              ;; zynaddsubfx requires this name.
+                              (rename-file "zest" "zyn-fusion")
+                              (install-file "zyn-fusion" bin)
+                              (install-file "completions/zyn-fusion"
+                                            (string-append #$output
+                                             "/share/bash-completion/completions")))))
+                        (add-after 'install 'wrap
+                          (lambda _
+                            (wrap-program (string-append #$output
+                                                         "/bin/zyn-fusion")
+                             `("LD_LIBRARY_PATH" ":" prefix
+                                (,(string-append #$output
+                                                 "/lib/zyn-fusion")))))))))
+    (native-inputs (list mruby pkg-config ruby))
+    (inputs (list font-entypo
+                  font-google-roboto
+                  bash-minimal
+                  libuv
+                  libx11
+                  mesa
+                  nanovg))
+    (home-page "https://github.com/mruby-zest/mruby-zest-build")
+    (synopsis "Widget classes for the mruby-zest framework")
+    (description
+     "This repository contains all of the widgets needed to create the
+@code{zyn-fusion} user interface for ZynAddSubFX.")
+    (license license:lgpl2.1)))
+
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-- 
2.38.0

From 7770a8393629eac18a706957757bead1e392776c Mon Sep 17 00:00:00 2001
From: Sughosha <[email-masked]>
Date: Sat, 15 Oct 2022 15:59:55 +0200
Subject: [PATCH 4/4] gnu: zynaddsubfx: Update to 3.0.6 and switch to
 zyn-fusion

* gnu/packages/music.scm (zynaddsubfx): Update to 3.0.6.

[arguments]: Use gexp for simplicity.

Switch from NTK to Zest.

[inputs]: Replace ntk with mruby-zest.

[native-inputs]: New dependencies.
---
 gnu/packages/music.scm | 70 ++++++++++++++++++++++++------------------
 1 file changed, 40 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/music.scm b/gnu/packages/music.scm
index 1ae54033c0..5d3c19bc78 100644
--- a/gnu/packages/music.scm
+++ b/gnu/packages/music.scm
@@ -167,7 +167,7 @@ (define-module (gnu packages music)
   #:use-module (gnu packages rdf)
   #:use-module (gnu packages readline)
   #:use-module (gnu packages rsync)
-  #:use-module (gnu packages ruby)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages sphinx)
@@ -3133,42 +3133,52 @@ (define-public mruby-zest
 (define-public zynaddsubfx
   (package
     (name "zynaddsubfx")
-    (version "3.0.5")
+    (version (package-version mruby-zest))
     (source (origin
               (method url-fetch)
               (uri (string-append
-                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/"
-                    version "/zynaddsubfx-" version ".tar.bz2"))
+                    "mirror://sourceforge/zynaddsubfx/zynaddsubfx/" version
+                    "/zynaddsubfx-" version ".tar.bz2"))
               (sha256
                (base32
-                "0qwzg14h043rmyf9jqdylxhyfy4sl0vsr0gjql51wjhid0i34ivl"))))
+                "1bkirvcg0lz1i7ypnz3dyh218yhrqpnijxs8n3wlgwbcixvn1lfb"))))
     (build-system cmake-build-system)
     (arguments
-     `(#:phases
-       (modify-phases %standard-phases
-         ;; Move SSE compiler optimization flags from generic target to
-         ;; athlon64 and core2 targets, because otherwise the build would fail
-         ;; on non-Intel machines.
-         (add-after 'unpack 'remove-sse-flags-from-generic-target
-          (lambda _
-            (substitute* "src/CMakeLists.txt"
-              (("-msse -msse2 -mfpmath=sse") "")
-              (("-march=(athlon64|core2)" flag)
-               (string-append flag " -msse -msse2 -mfpmath=sse")))
-            #t)))))
-    (inputs
-     (list liblo
-           ntk
-           mesa
-           alsa-lib
-           jack-1
-           fftw
-           minixml
-           libxpm
-           zlib))
-    (native-inputs
-     (list pkg-config))
-    (home-page "http://zynaddsubfx.sf.net/")
+     (list #:configure-flags #~(list "-DGuiModule=zest"
+                                     (string-append "-DZYN_DATADIR="
+                                                    #$output
+                                                    "/share/zynaddsubfx"))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'remove-sse-flags-from-generic-target
+                          (lambda _
+                            (substitute* "src/CMakeLists.txt"
+                              (("-msse -msse2 -mfpmath=sse")
+                               "")
+                              (("-march=(athlon64|core2)" flag)
+                               (string-append flag
+                                              " -msse -msse2 -mfpmath=sse")))))
+                        (add-after 'unpack 'fix-zyn-fusion-path
+                          (lambda _
+                            (substitute* "src/main.cpp"
+                              (("\\./zyn-fusion")
+                               (string-append #$mruby-zest
+                                              "/bin/zyn-fusion")))
+                            (substitute*
+                             "src/Plugin/ZynAddSubFX/ZynAddSubFX-UI-Zest.cpp"
+                              (("\\./libzest\\.so")
+                               (string-append #$mruby-zest
+                                              "/lib/zyn-fusion/libzest.so"))))))))
+    (inputs (list alsa-lib
+                  fftwf
+                  jack-1
+                  liblo
+                  libxpm
+                  mesa
+                  minixml
+                  mruby-zest
+                  zlib))
+    (native-inputs (list doxygen pkg-config ruby))
+    (home-page "https://zynaddsubfx.sourceforge.io/")
     (synopsis "Software synthesizer")
     (description
      "ZynAddSubFX is a feature heavy realtime software synthesizer.  It offers
-- 
2.38.0