| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 |
|
| 22 | (define-module (gnu packages bqn)
|
| 23 | #:use-module ((guix licenses) #:prefix license:)
|
| 24 | #:use-module (guix gexp)
|
| 25 | #:use-module (guix packages)
|
| 26 | #:use-module (guix download)
|
| 27 | #:use-module (guix git-download)
|
| 28 | #:use-module (guix build-system gnu)
|
| 29 | #:use-module (guix utils)
|
| 30 | #:use-module (gnu packages)
|
| 31 | #:use-module (gnu packages bash)
|
| 32 | #:use-module (gnu packages libffi)
|
| 33 | #:use-module (gnu packages base)
|
| 34 | #:use-module (gnu packages pkg-config)
|
| 35 | #:use-module (gnu packages llvm)
|
| 36 | #:use-module (gnu packages java)
|
| 37 | #:use-module (gnu packages compression))
|
| 38 |
|
| 39 | (define-public dbqn
|
| 40 | (package
|
| 41 | (name "dbqn")
|
| 42 | (version "0.2.2")
|
| 43 | (source
|
| 44 | (origin
|
| 45 | (method git-fetch)
|
| 46 | (uri (git-reference
|
| 47 | (url "https://github.com/dzaima/BQN")
|
| 48 | (commit (string-append "v" version))))
|
| 49 | (file-name (git-file-name name version))
|
| 50 | (sha256
|
| 51 | (base32 "1zy3y9wbmaw0mrd2sp7d1r912gvs9k0mzw5d3drgmbzkbvpd6iq1"))))
|
| 52 | (build-system gnu-build-system)
|
| 53 | (arguments
|
| 54 | (list
|
| 55 | #:imported-modules `((guix build ant-build-system)
|
| 56 | ,@%default-gnu-imported-modules)
|
| 57 | #:modules '((guix build gnu-build-system)
|
| 58 | ((guix build ant-build-system)
|
| 59 | #:prefix ant:)
|
| 60 | (guix build utils))
|
| 61 | #:phases
|
| 62 | #~(modify-phases %standard-phases
|
| 63 | (delete 'configure)
|
| 64 | (replace 'build
|
| 65 | (lambda _
|
| 66 | (invoke "./build")))
|
| 67 | (replace 'check
|
| 68 | (lambda* (#:key tests? #:allow-other-keys)
|
| 69 | (if tests?
|
| 70 | (invoke "./BQN" "./test/test")
|
| 71 | (begin
|
| 72 | (display "test suite not run")
|
| 73 | (newline)))))
|
| 74 | (add-after 'install 'reorder-jar-content
|
| 75 | (assoc-ref ant:%standard-phases
|
| 76 | 'reorder-jar-content))
|
| 77 | (add-after 'reorder-jar-content 'generate-jar-indices
|
| 78 | (assoc-ref ant:%standard-phases
|
| 79 | 'generate-jar-indices))
|
| 80 | (add-after 'generate-jar-indices 'strip-jar-timestamps
|
| 81 | (assoc-ref ant:%standard-phases
|
| 82 | 'strip-jar-timestamps))
|
| 83 | (replace 'install
|
| 84 | (lambda* (#:key inputs #:allow-other-keys)
|
| 85 | (let ((dest-jar (string-append #$output "/share/java")))
|
| 86 | (rename-file "BQN" "dbqn")
|
| 87 | (substitute* "dbqn"
|
| 88 | (("java")
|
| 89 | (search-input-file inputs "/bin/java"))
|
| 90 | (("BQN.jar")
|
| 91 | (string-append dest-jar "/BQN.jar")))
|
| 92 | (install-file "BQN.jar" dest-jar)
|
| 93 | (install-file "dbqn"
|
| 94 | (string-append #$output "/bin"))))))))
|
| 95 | (native-inputs (list `(,icedtea-8 "jdk") zip))
|
| 96 | (inputs (list bash-minimal icedtea-8))
|
| 97 | (synopsis "BQN implementation based on dzaima/APL")
|
| 98 | (description
|
| 99 | "dbqn is a Java implementation of the
|
| 100 | @uref{https://mlochbaum.github.io/BQN/, BQN programming language} that does
|
| 101 | not need to be bootstrapped, based on an earlier Java implementation of APL by
|
| 102 | the same author.")
|
| 103 | (home-page "https://github.com/dzaima/BQN")
|
| 104 | (license license:expat)))
|
| 105 |
|
| 106 | (define bqn-sources
|
| 107 | |
| 108 | |
| 109 | |
| 110 | (let ((commit "5880fa153bb3e3172afc59a711af7e471aeedcd3"))
|
| 111 | (origin
|
| 112 | (method git-fetch)
|
| 113 | (uri (git-reference
|
| 114 | (url "https://github.com/mlochbaum/BQN")
|
| 115 | (commit commit)))
|
| 116 | (file-name (git-file-name "bqn-sources" commit))
|
| 117 | (sha256
|
| 118 | (base32 "1cap927i0s8ly4mckppw33ahlc5xnp3l2shk1m79wndf362x3r7c")))))
|
| 119 |
|
| 120 | (define %cbqn-version "0.9.0")
|
| 121 |
|
| 122 | (define cbqn-sources
|
| 123 | (let ((version %cbqn-version))
|
| 124 | (origin
|
| 125 | (method git-fetch)
|
| 126 | (uri (git-reference
|
| 127 | (url "https://github.com/dzaima/CBQN")
|
| 128 | (commit (string-append "v" version))))
|
| 129 | (file-name (git-file-name "cbqn" version))
|
| 130 | (sha256
|
| 131 | (base32 "0433hp9lgv6w6mhdz0k1kx2rmxia76yy9i0z7ps4qdk7snf2yr2q")))))
|
| 132 |
|
| 133 | (define %replxx-commit "13f7b60f4f79c2f14f352a76d94860bad0fc7ce9")
|
| 134 |
|
| 135 | (define replxx-sources
|
| 136 | (let ((commit %replxx-commit))
|
| 137 | (origin
|
| 138 | (method git-fetch)
|
| 139 | (uri
|
| 140 | (git-reference
|
| 141 | (url "https://github.com/dzaima/replxx")
|
| 142 | (commit commit)))
|
| 143 | (file-name (git-file-name "replxx" commit))
|
| 144 | (sha256
|
| 145 | (base32 "0440xjvdkrbpxqjrd6nsrnaxki0mgyinsb0b1dcshjj3h3jr1yy4")))))
|
| 146 |
|
| 147 | (define %singeli-commit "53f42ce4331176d281fa577408ec5a652bdd9127")
|
| 148 |
|
| 149 | (define singeli-sources
|
| 150 | (let ((commit %singeli-commit))
|
| 151 | (origin
|
| 152 | (method git-fetch)
|
| 153 | (uri
|
| 154 | (git-reference
|
| 155 | (url "https://github.com/mlochbaum/Singeli")
|
| 156 | (commit commit)))
|
| 157 | (file-name (git-file-name "singeli" commit))
|
| 158 | (sha256
|
| 159 | (base32 "1dzg4gk74lhy6pwvxzhk4zj1qinc83l7i6x6zpvdajdlz5vqvc1m")))))
|
| 160 |
|
| 161 | (define cbqn-bootstrap
|
| 162 | (package
|
| 163 | (name "cbqn-bootstrap")
|
| 164 | (version %cbqn-version)
|
| 165 | (source cbqn-sources)
|
| 166 | (build-system gnu-build-system)
|
| 167 | (arguments
|
| 168 | (list
|
| 169 | #:tests? #f |
| 170 | |
| 171 | #:make-flags
|
| 172 | #~(list (string-append "CC=" #$(cc-for-target))
|
| 173 | |
| 174 | |
| 175 | (string-append "version=" #$version)
|
| 176 | "nogit=1"
|
| 177 | "for-bootstrap")
|
| 178 | #:phases
|
| 179 | #~(modify-phases %standard-phases
|
| 180 | (delete 'configure)
|
| 181 | (replace 'install
|
| 182 | (lambda* (#:key outputs #:allow-other-keys)
|
| 183 | (mkdir-p (string-append #$output "/bin"))
|
| 184 | (chmod "BQN" #o755)
|
| 185 | (rename-file "BQN" "bqn")
|
| 186 | (install-file "bqn"
|
| 187 | (string-append #$output "/bin")))))))
|
| 188 | (inputs (list libffi))
|
| 189 | (synopsis "BQN implementation in C")
|
| 190 | (description
|
| 191 | "This package provides the reference implementation of
|
| 192 | @uref{https://mlochbaum.github.io/BQN/, BQN}, a programming language inspired
|
| 193 | by APL.")
|
| 194 | (home-page "https://mlochbaum.github.io/BQN/")
|
| 195 | |
| 196 | (license (list license:asl2.0 |
| 197 | license:boost1.0
|
| 198 | license:expat |
| 199 | license:lgpl3+ |
| 200 | license:gpl3+
|
| 201 | license:mpl2.0))))
|
| 202 |
|
| 203 | (define* (cbqn-combined-source name version #:key cbqn-sources replxx-sources singeli-sources)
|
| 204 | (origin
|
| 205 | (method (@@ (guix packages) computed-origin-method))
|
| 206 | (file-name (string-append name "-" version ".tar.gz"))
|
| 207 | (sha256 #f)
|
| 208 | (uri
|
| 209 | (delay
|
| 210 | (with-imported-modules '((guix build utils))
|
| 211 | #~(begin
|
| 212 | (use-modules (guix build utils))
|
| 213 | (let* ((dir (string-append "cbqn" #$version))
|
| 214 | (replxx-local-dir "build/replxxLocal")
|
| 215 | (singeli-local-dir "build/singeliLocal"))
|
| 216 |
|
| 217 | (set-path-environment-variable
|
| 218 | "PATH" '("bin")
|
| 219 | (list #+(canonical-package bash)
|
| 220 | #+(canonical-package coreutils)
|
| 221 | #+(canonical-package gzip)
|
| 222 | #+(canonical-package tar)))
|
| 223 | (copy-recursively #+cbqn-sources dir)
|
| 224 |
|
| 225 | (with-directory-excursion dir
|
| 226 | |
| 227 | (mkdir replxx-local-dir)
|
| 228 | (mkdir singeli-local-dir)
|
| 229 | (copy-recursively #+replxx-sources replxx-local-dir)
|
| 230 | (copy-recursively #+singeli-sources singeli-local-dir))
|
| 231 |
|
| 232 | (invoke "tar" "cvfa" #$output
|
| 233 | "--mtime=@0"
|
| 234 | "--owner=root:0"
|
| 235 | "--group=root:0"
|
| 236 | "--sort=name"
|
| 237 | "--hard-dereference"
|
| 238 | dir))))))))
|
| 239 |
|
| 240 | (define-public cbqn
|
| 241 | (package
|
| 242 | (inherit cbqn-bootstrap)
|
| 243 | (name "cbqn")
|
| 244 | (outputs '("out" "lib"))
|
| 245 | (source
|
| 246 | (cbqn-combined-source name %cbqn-version
|
| 247 | #:cbqn-sources cbqn-sources
|
| 248 | #:replxx-sources replxx-sources
|
| 249 | #:singeli-sources singeli-sources))
|
| 250 | (arguments
|
| 251 | (substitute-keyword-arguments
|
| 252 | (strip-keyword-arguments (list #:tests?)
|
| 253 | (package-arguments cbqn-bootstrap))
|
| 254 | ((#:make-flags flags #~(list))
|
| 255 | #~(cons* "shared-o3" "o3" "for-build" #$flags))
|
| 256 | ((#:phases phases #~%standard-phases)
|
| 257 | #~(modify-phases #$phases
|
| 258 | |
| 259 | (add-before 'build 'generate-bytecode
|
| 260 | (lambda* (#:key inputs #:allow-other-keys)
|
| 261 | (let* ((self-hosted-source (dirname (search-input-file
|
| 262 | inputs
|
| 263 | "bqn.bqn"))))
|
| 264 | (mkdir-p "build/bytecodeLocal/gen")
|
| 265 | (invoke "bqn" "build/bootstrap.bqn" self-hosted-source))))
|
| 266 | (replace 'check
|
| 267 | (lambda* (#:key inputs tests? #:allow-other-keys)
|
| 268 | (when tests?
|
| 269 | (system (string-append "./BQN -M 1000 \""
|
| 270 | #+bqn-sources "/test/this.bqn\""))
|
| 271 | (map (lambda (x)
|
| 272 | (system (string-append "./BQN ./test/" x ".bqn")))
|
| 273 | '("cmp"
|
| 274 | "equal"
|
| 275 | "copy"
|
| 276 | "bitcpy"
|
| 277 | "bit"
|
| 278 | "mut"
|
| 279 | "hash"
|
| 280 | "squeezeValid"
|
| 281 | "squeezeExact"
|
| 282 | "various"
|
| 283 | "random"
|
| 284 | "joinReuse"))
|
| 285 | (system "make -C test/ffi"))))
|
| 286 | (replace 'install
|
| 287 | (lambda* (#:key outputs #:allow-other-keys)
|
| 288 | (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
|
| 289 | (lib (string-append (assoc-ref outputs "lib") "/lib"))
|
| 290 | (include (string-append (assoc-ref outputs "lib")
|
| 291 | "/include")))
|
| 292 | (mkdir-p bin)
|
| 293 | (rename-file "BQN" "bqn")
|
| 294 | (install-file "bqn" bin)
|
| 295 | (install-file "libcbqn.so" lib)
|
| 296 | (install-file "include/bqnffi.h" include))))))))
|
| 297 | (native-inputs (list cbqn-bootstrap libffi))
|
| 298 | (inputs (modify-inputs inputs
|
| 299 | (prepend bqn-sources)))
|
| 300 | (license (append (package-license cbqn-bootstrap)
|
| 301 | (list license:isc |
| 302 | license:bsd-3 |
| 303 | license:unicode)))
|
| 304 | (properties `((tunable? . #t)))))
|