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 (rename-file "BQN" "dbqn")
97 (install-file "dbqn" dest-bin)
98 (install-file "BQN.jar" dest-jar)
99 (substitute* (string-append dest-bin "/dbqn")
101 (string-append dest-jar "/BQN.jar")))))))))
102 (native-inputs (list `(,icedtea-8 "jdk") zip))
103 (inputs (list icedtea-8 bash-minimal))
104 (synopsis "BQN implementation based on dzaima/APL")
106 "dbqn is a Java implementation of the
107 @uref{https://mlochbaum.github.io/BQN/, BQN programming language} that does
108 not need to be bootstrapped, based on an earlier Java implementation of APL by
110 (home-page "https://github.com/dzaima/BQN")
111 (license license:expat))))
114 ;; Aside from dbqn above, the main bqn repository is used by other
115 ;; implementations as a "known good" set of sources. CBQN uses dbqn to
116 ;; generate an intermediate bytecode for its own compilation.
117 (let ((commit "e219af48401473a7bac49bdd8b89d69082cf5dd8"))
121 (url "https://github.com/mlochbaum/BQN")
123 (file-name (git-file-name "bqn-sources" commit))
125 (base32 "0r6pa9lscl2395g4xlvmg90vpdsjzhin4f1r0s7brymmpvmns2yc")))))
127 (define cbqn-bootstrap
128 (let* ((revision "1")
129 (commit "9c1cbdc99863b1da0116df61cd832137b196dc5c"))
131 (name "cbqn-bootstrap")
132 (version (git-version "0" revision commit))
136 (url "https://github.com/dzaima/CBQN")
138 (file-name (git-file-name name version))
141 "0w38fhwf20drkyijy6nfnhmc5g5gw0zmzgmy1q605x57znlj85a2"))))
142 (build-system gnu-build-system)
144 (list #:tests? #f ;skipping tests for bootstrap
145 #:make-flags #~(list (string-append "CC=" #$(cc-for-target)))
146 #:phases #~(modify-phases %standard-phases
148 (add-before 'build 'generate-bytecode
149 (lambda* (#:key inputs #:allow-other-keys)
150 (system (string-append #+dbqn
151 "/bin/dbqn ./genRuntime "
154 (lambda* (#:key outputs #:allow-other-keys)
155 (mkdir-p (string-append #$output "/bin"))
157 (copy-recursively "BQN"
158 (string-append #$output
160 (native-inputs (list dbqn bqn-sources))
161 (inputs (list icedtea-8 libffi))
162 (synopsis "BQN implementation in C")
163 (description "This package provides the reference implementation of
164 @uref{https://mlochbaum.github.io/BQN/, BQN}, a programming language inspired
166 (home-page "https://mlochbaum.github.io/BQN/")
167 (license license:gpl3))))
171 (inherit cbqn-bootstrap)
173 (outputs '("out" "lib"))
175 (substitute-keyword-arguments (strip-keyword-arguments
177 (package-arguments cbqn-bootstrap))
178 ((#:make-flags flags #~(list))
179 #~(cons* "shared-o3" "o3" #$flags))
180 ((#:phases phases #~%standard-phases)
181 #~(modify-phases #$phases
183 (lambda* (#:key inputs tests? #:allow-other-keys)
185 (system (string-append "./BQN -M 1000 \""
189 (system (string-append "./BQN ./test/" x
191 '("cmp" "equal" "copy" "random"))
192 (system "make -C test/ffi"))))
194 (lambda* (#:key outputs #:allow-other-keys)
195 (let* ((bin (string-append (assoc-ref outputs "out")
197 (lib (string-append (assoc-ref outputs "lib")
200 (copy-recursively "BQN"
201 (string-append bin "/bqn"))
202 (install-file "libcbqn.so" lib))))))))
203 (native-inputs (list dbqn
206 linux-libre-headers))))