1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2022 Christopher Rodriguez <yewscion@gmail.com>
3 ;;; Copyright © 2022 Liliana Marie Prikler <liliana.prikler@gmail.com>
5 ;;; This file is part of GNU Guix.
7 ;;; GNU Guix is free software; you can redistribute it and/or modify it
8 ;;; under the terms of the GNU General Public License as published by
9 ;;; the Free Software Foundation; either version 3 of the License, or (at
10 ;;; your option) any later version.
12 ;;; GNU Guix is distributed in the hope that it will be useful, but
13 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;;; GNU General Public License for more details.
17 ;;; You should have received a copy of the GNU General Public License
18 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20 (define-module (gnu packages bqn)
21 #:use-module ((guix licenses) #:prefix license:)
22 #:use-module (guix gexp)
23 #:use-module (guix packages)
24 #:use-module (guix download)
25 #:use-module (guix git-download)
26 #:use-module (guix build-system copy)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix utils)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages bash)
31 #:use-module (gnu packages libffi)
32 #:use-module (gnu packages base)
33 #:use-module (gnu packages pkg-config)
34 #:use-module (gnu packages llvm)
35 #:use-module (gnu packages java)
36 #:use-module (gnu packages linux)
37 #:use-module (gnu packages compression))
40 (let ((commit "88f2b43966a75cc2c382421218eb30003bb16f4a")
44 (version (git-version "0.2.1" revision commit))
48 (url "https://github.com/dzaima/BQN")
50 (file-name (git-file-name name version))
53 "06mzvv7kmandhgwb6jwz3rivsj4ic549sy8afnb5zr6mfn5isyg5"))))
54 (build-system gnu-build-system)
57 #:imported-modules `(,@%gnu-build-system-modules
59 (guix build ant-build-system))
60 #:modules `((guix build gnu-build-system)
61 ((guix build ant-build-system)
64 #:phases #~(modify-phases %standard-phases
69 (chmod "./BQN" #o755)))
71 (lambda* (#:key tests? #:allow-other-keys)
73 (system "./BQN ./test/test"))))
74 (add-after 'install 'reorder-jar-content
75 (lambda* (#:key outputs #:allow-other-keys)
76 (apply (assoc-ref ant:%standard-phases
78 #:outputs (list outputs))))
79 (add-after 'reorder-jar-content 'jar-indices
80 (lambda* (#:key outputs #:allow-other-keys)
81 (apply (assoc-ref ant:%standard-phases
82 'generate-jar-indices)
83 #:outputs (list outputs))))
84 (add-after 'jar-indices 'fix-jar-timestamps
85 (lambda* (#:key outputs #:allow-other-keys)
86 (apply (assoc-ref ant:%standard-phases
88 #:outputs (list outputs))))
90 (lambda* (#:key outputs #:allow-other-keys)
91 (let* ((out (assoc-ref outputs "out"))
92 (dest-bin (string-append out "/bin"))
93 (dest-jar (string-append out "/share/java")))
96 (copy-recursively "BQN"
97 (string-append dest-bin
99 (install-file "BQN.jar" dest-jar)
100 (substitute* (string-append dest-bin "/dbqn")
102 (string-append dest-jar "/BQN.jar")))))))))
103 (native-inputs (list `(,icedtea-8 "jdk") zip))
104 (inputs (list icedtea-8 bash-minimal))
105 (synopsis "BQN implementation based on dzaima/APL")
107 "dbqn is a Java implementation of the
108 @uref{https://mlochbaum.github.io/BQN/, BQN programming language} that does
109 not need to be bootstrapped, based on an earlier Java implementation of APL by
111 (home-page "https://github.com/dzaima/BQN")
112 (license license:expat))))
115 ;; Aside from dbqn above, the main bqn repository is used by other
116 ;; implementations as a "known good" set of sources. CBQN uses dbqn to
117 ;; generate an intermediate bytecode for its own compilation.
118 (let ((commit "e219af48401473a7bac49bdd8b89d69082cf5dd8"))
122 (url "https://github.com/mlochbaum/BQN")
124 (file-name (git-file-name "bqn-sources" commit))
126 (base32 "0r6pa9lscl2395g4xlvmg90vpdsjzhin4f1r0s7brymmpvmns2yc")))))
128 (define cbqn-bootstrap
129 (let* ((revision "1")
130 (commit "9c1cbdc99863b1da0116df61cd832137b196dc5c"))
132 (name "cbqn-bootstrap")
133 (version (git-version "0" revision commit))
137 (url "https://github.com/dzaima/CBQN")
139 (file-name (git-file-name name version))
142 "0w38fhwf20drkyijy6nfnhmc5g5gw0zmzgmy1q605x57znlj85a2"))))
143 (build-system gnu-build-system)
145 (list #:tests? #f ;skipping tests for bootstrap
146 #:make-flags #~(list (string-append "CC=" #$(cc-for-target)))
147 #:phases #~(modify-phases %standard-phases
149 (add-before 'build 'generate-bytecode
150 (lambda* (#:key inputs #:allow-other-keys)
151 (system (string-append #+dbqn
152 "/bin/dbqn ./genRuntime "
155 (lambda* (#:key outputs #:allow-other-keys)
156 (mkdir-p (string-append #$output "/bin"))
158 (copy-recursively "BQN"
159 (string-append #$output
161 (native-inputs (list dbqn bqn-sources))
162 (inputs (list icedtea-8 libffi))
163 (synopsis "BQN implementation in C")
164 (description "This package provides the reference implementation of
165 @uref{https://mlochbaum.github.io/BQN/, BQN}, a programming language inspired
167 (home-page "https://mlochbaum.github.io/BQN/")
168 (license license:gpl3))))
172 (inherit cbqn-bootstrap)
174 (outputs '("out" "lib"))
176 (substitute-keyword-arguments (strip-keyword-arguments
178 (package-arguments cbqn-bootstrap))
179 ((#:make-flags flags #~(list))
180 #~(cons* "shared-o3" "o3" #$flags))
181 ((#:phases phases #~%standard-phases)
182 #~(modify-phases #$phases
184 (lambda* (#:key inputs tests? #:allow-other-keys)
186 (system (string-append "./BQN -M 1000 \""
190 (system (string-append "./BQN ./test/" x
192 '("cmp" "equal" "copy" "random"))
193 (system "make -C test/ffi"))))
195 (lambda* (#:key outputs #:allow-other-keys)
196 (let* ((bin (string-append (assoc-ref outputs "out")
198 (lib (string-append (assoc-ref outputs "lib")
201 (copy-recursively "BQN"
202 (string-append bin "/bqn"))
203 (install-file "libcbqn.so" lib))))))))
204 (native-inputs (list dbqn
207 linux-libre-headers))))