projects/guix·blob javascript-team · refs

174 lines · 7.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2025 Sughosha <[email protected]>
3;;;
4;;; This file is part of GNU Guix.
5;;;
6;;; GNU Guix is free software; you can redistribute it and/or modify it
7;;; under the terms of the GNU General Public License as published by
8;;; the Free Software Foundation; either version 3 of the License, or (at
9;;; your option) any later version.
10;;;
11;;; GNU Guix is distributed in the hope that it will be useful, but
12;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14;;; GNU General Public License for more details.
15;;;
16;;; You should have received a copy of the GNU General Public License
17;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
18
19(define-module (gnu packages mruby-xyz)
20 #:use-module (guix gexp)
21 #:use-module (guix packages)
22 #:use-module (guix git-download)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix build-system gnu)
25 #:use-module (guix utils)
26 #:use-module (gnu packages)
27 #:use-module (gnu packages audio)
28 #:use-module (gnu packages fonts)
29 #:use-module (gnu packages gl)
30 #:use-module (gnu packages libevent)
31 #:use-module (gnu packages pkg-config)
32 #:use-module (gnu packages ruby)
33 #:use-module (gnu packages xorg)
34 #:use-module (ice-9 match))
35
36(define-public mruby-zest
37 (package
38 (name "mruby-zest")
39 (version "3.0.6")
40 (source (origin
41 (method git-fetch)
42 (uri (git-reference
43 (url "https://github.com/mruby-zest/mruby-zest-build")
44 (commit version)
45 ;; Clone recursively for the mruby sources and gems that
46 ;; are needed for compilation. The rest of the bundled
47 ;; dependencies will be deleted in the snippet.
48 (recursive? #t)))
49 (file-name (git-file-name name version))
50 (sha256
51 (base32
52 "0dz4zv1km9805lji2q2qqdd8s8hgfd723dxdzcivbhm612szm1mc"))
53 (modules '((guix build utils)))
54 (snippet
55 '(begin
56 ;; This package contains a custom "pugl". Replacing it with
57 ;; the system "pugl" fails to build.
58 ;; Delete the bundled "libuv", "nanovg" and "rtosc".
59 (with-directory-excursion "deps"
60 (for-each delete-file-recursively
61 (list "libuv" "nanovg" "rtosc")))
62 ;; Do not compile "nanovg" and "libuv" and replace them with
63 ;; the respective system libraries.
64 (substitute* "Makefile"
65 (("cd deps/nanovg") "#cd deps/nanovg")
66 (("\\$\\(AR\\) rc deps/libnanovg\\.a")
67 "#$(AR) rc deps/libnanovg.a")
68 (("\\./deps/libnanovg\\.a")
69 "-lnanovg")
70 (("cd deps/libuv") "#cd deps/libuv")
71 (("\\./deps/libuv/\\.libs/libuv\\.a")
72 "-luv")
73 (("\\./deps/libuv/\\.libs/libuv-win\\.a")
74 "-luv-win"))
75 ;; Do not include the bundled "nanovg" and "uv" and replace
76 ;; them with the respective system libraries.
77 (substitute* "build_config.rb"
78 (("cc\\.include_paths.*\\./deps/nanovg/.*$" all)
79 (string-append "#" all))
80 (("cc\\.include_paths.*\\./deps/libuv/.*$" all)
81 (string-append "#" all))
82 (("#\\{`pwd`\\.strip\\}/\\.\\./deps/libnanovg\\.a")
83 "-lnanovg")
84 (("#\\{`pwd`\\.strip\\}/\\.\\./deps/libuv\\.a")
85 "-luv"))
86 ;; Fix including "nanovg" headers.
87 (substitute* (find-files "deps/mruby-nanovg" "\\.(c|h)")
88 (("nanovg\\.h") "nanovg/nanovg.h")
89 (("nanovg_gl\\.h") "nanovg/nanovg_gl.h")
90 (("\"\\.\\./\\.\\./nanovg/.*/stb_image_write\\.h\"")
91 "<nanovg/stb_image_write.h>"))
92 ;; Fix including "rtosc" headers.
93 (substitute* "src/mruby-widget-lib/src/gem.c"
94 (("\"\\.\\./\\.\\./\\.\\./deps/.*/rtosc\\.h\"")
95 "<rtosc/rtosc.h>"))))))
96 (build-system gnu-build-system)
97 (arguments
98 (list #:tests? #f ;no test suite
99 #:make-flags
100 #~(list (string-append "CC=" #$(cc-for-target))
101 "CONFIG_SHELL=bash")
102 #:modules
103 `(,@%default-gnu-modules
104 (srfi srfi-26))
105 #:phases
106 #~(modify-phases %standard-phases
107 (delete 'configure) ;no configure script
108 (add-after 'unpack 'patch-paths
109 (lambda* (#:key inputs #:allow-other-keys)
110 ;; Patch paths to the missing fonts.
111 (substitute*
112 "src/mruby-widget-lib/mrblib/script.rb"
113 (("sans = \\[")
114 (string-append
115 "sans = [\""
116 (search-input-file inputs
117 "/share/fonts/truetype/Roboto-Regular.ttf")
118 "\", "))
119 (("bold = \\[")
120 (string-append
121 "bold = [\""
122 (search-input-file inputs
123 "/share/fonts/truetype/Roboto-Bold.ttf")
124 "\", ")))
125 ;; Patch paths to the zyn-fusion files.
126 (substitute* "src/osc-bridge/src/bridge.c"
127 (("fopen\\(\\\"schema/")
128 (string-append
129 "fopen(\"" #$output "/share/zyn-fusion/schema/")))
130 (substitute* "test-libversion.c"
131 (("./libzest.so")
132 (string-append #$output "/lib/libzest.so")))
133 (substitute* "src/mruby-widget-lib/src/api.c"
134 ((", \\\"\\./qml/") ", \"../share/zyn-fusion/qml/")
135 (("\\./qml/")
136 (string-append #$output "/share/zyn-fusion/qml")))))
137 ;; No install target.
138 (replace 'install
139 (lambda _
140 (let* ((bin (string-append #$output "/bin"))
141 (lib (string-append #$output "/lib"))
142 (share (string-append #$output "/share"))
143 (qml (string-append share "/zyn-fusion/qml"))
144 (schema (string-append share "/zyn-fusion/schema"))
145 (completions
146 (string-append share
147 "/bash-completion/completions")))
148 ;; zynaddsubfx looks for "zyn-fusion" instead of "zest".
149 (rename-file "zest" "zyn-fusion")
150 (install-file "zyn-fusion" bin)
151 (install-file "libzest.so" lib)
152 (for-each (cut install-file <> qml)
153 (append (find-files "src/mruby-zest/qml"
154 "\\.qml$")
155 (find-files "src/mruby-zest/example"
156 "\\.qml$")))
157 (install-file "src/osc-bridge/schema/test.json" schema)
158 (install-file "completions/zyn-fusion" completions)))))))
159 (native-inputs
160 (list pkg-config ruby))
161 (inputs
162 (list font-google-roboto
163 libuv
164 libx11
165 mesa
166 nanovg
167 rtosc))
168 (home-page "https://github.com/mruby-zest/mruby-zest-build")
169 (synopsis "Zyn-Fusion user interface")
170 (description
171 "This package provides Zyn-Fusion user interface for
172@command{zynaddsubfx}.")
173 (license
174 (list license:lgpl2.1))))