1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2022 Christopher Rodriguez <yewscion@gmail.com>
4 ;;; This file is part of GNU Guix.
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.
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.
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/>.
19 (define-module (gnu packages bqn)
20 #:use-module ((guix licenses) #:prefix license:)
21 #:use-module (guix gexp)
22 #:use-module (guix packages)
23 #:use-module (guix download)
24 #:use-module (guix git-download)
25 #:use-module (guix build-system copy)
26 #:use-module (guix build-system gnu)
27 #:use-module (guix utils)
28 #:use-module (gnu packages)
29 #:use-module (gnu packages bash)
30 #:use-module (gnu packages libffi)
31 #:use-module (gnu packages base)
32 #:use-module (gnu packages pkg-config)
33 #:use-module (gnu packages llvm)
34 #:use-module (gnu packages java)
35 #:use-module (gnu packages linux)
36 #:use-module (gnu packages compression))
39 (let ((commit "88f2b43966a75cc2c382421218eb30003bb16f4a")
43 (version (git-version "0.2.1" revision commit))
47 (url "https://github.com/dzaima/BQN")
49 (file-name (git-file-name name version))
52 "06mzvv7kmandhgwb6jwz3rivsj4ic549sy8afnb5zr6mfn5isyg5"))))
53 (build-system gnu-build-system)
56 #:imported-modules `(,@%gnu-build-system-modules
58 (guix build ant-build-system))
59 #:modules `((guix build gnu-build-system)
60 ((guix build ant-build-system)
63 #:phases #~(modify-phases %standard-phases
68 (chmod "./BQN" #o755)))
70 (lambda* (#:key tests? #:allow-other-keys)
72 (system "./BQN ./test/test"))))
73 (add-after 'install 'reorder-jar-content
74 (lambda* (#:key outputs #:allow-other-keys)
75 (apply (assoc-ref ant:%standard-phases
77 #:outputs (list outputs))))
78 (add-after 'reorder-jar-content 'jar-indices
79 (lambda* (#:key outputs #:allow-other-keys)
80 (apply (assoc-ref ant:%standard-phases
81 'generate-jar-indices)
82 #:outputs (list outputs))))
83 (add-after 'jar-indices 'fix-jar-timestamps
84 (lambda* (#:key outputs #:allow-other-keys)
85 (apply (assoc-ref ant:%standard-phases
87 #:outputs (list outputs))))
89 (lambda* (#:key outputs #:allow-other-keys)
90 (let* ((out (assoc-ref outputs "out"))
91 (dest-bin (string-append out "/bin"))
92 (dest-jar (string-append out "/share/java")))
95 (copy-recursively "BQN"
96 (string-append 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" "1" 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 #:phases #~(modify-phases %standard-phases
147 (add-before 'build 'generate-bytecode
148 (lambda* (#:key inputs #:allow-other-keys)
149 (system (string-append #+dbqn
150 "/bin/dbqn ./genRuntime "
153 (lambda* (#:key outputs #:allow-other-keys)
154 (mkdir-p (string-append #$output "/bin"))
156 (copy-recursively "BQN"
157 (string-append #$output
159 (native-inputs (list dbqn clang-toolchain bqn-sources))
160 (inputs (list icedtea-8 libffi))
161 (synopsis "BQN implementation in C")
162 (description "This package provides the reference implementation of
163 @uref{https://mlochbaum.github.io/BQN/, BQN}, a programming language inspired
165 (home-page "https://mlochbaum.github.io/BQN/")
166 (license license:gpl3))))
170 (inherit cbqn-bootstrap)
172 (outputs '("out" "lib"))
174 (list #:make-flags '(list "shared-o3" "o3")
175 #:phases #~(modify-phases %standard-phases
177 (add-before 'build 'generate-bytecode
178 (lambda* (#:key inputs #:allow-other-keys)
179 (system (string-append #+dbqn
180 "/bin/dbqn ./genRuntime "
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
198 (lib (string-append (assoc-ref outputs
202 (copy-recursively "BQN"
203 (string-append bin "/bqn"))
204 (install-file "libcbqn.so" lib)))))))
205 (native-inputs (list dbqn
209 linux-libre-headers))))