Subject: [PATCH 5/5] gnu: cbqn: Update to 0.9.0.

From: Lee Thompson <[email-masked]>
Date: Sat, 5 Apr 2025 16:07:33 +0100

* gnu/packages/bqn.scm (cbqn): Update to 0.9.0. Source-only bootstrap phase to
generate bytecode added. Library dependencies on replxx-sources and
singeli-sources added. New tests added to list. Dependency on dbqn eliminated.

Change-Id: I97ba12dd9d67b944ef7be1d6d76a98f4f2d69e35
---
 gnu/packages/bqn.scm | 67 ++++++++++++++++++++++++++++++--------------
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/gnu/packages/bqn.scm b/gnu/packages/bqn.scm
index fb153696e6..fa3c7bbddc 100644
--- a/gnu/packages/bqn.scm
+++ b/gnu/packages/bqn.scm
@@ -196,39 +196,64 @@ (define-public cbqn
     (name "cbqn")
     (outputs '("out" "lib"))
     (arguments
-     (substitute-keyword-arguments (strip-keyword-arguments
-                                    (list #:tests?)
-                                    (package-arguments cbqn-bootstrap))
-       ((#:make-flags flags #~(list))
-        #~(cons* "shared-o3" "o3" #$flags))
-       ((#:phases phases #~%standard-phases)
+     (substitute-keyword-arguments (strip-keyword-arguments (list #:tests?)
+                                                            (package-arguments
+                                                             cbqn-bootstrap))
+       ((#:make-flags flags
+         #~(list))
+        #~(cons* "shared-o3" "o3"
+                 #$flags))
+       ((#:phases phases
+         #~%standard-phases)
         #~(modify-phases #$phases
+            ;; Symlinking local copies of REPLXX and Singeli is allowed
+            ;; instead of cloning submodules. `singeli-source' and
+            ;; `replxx-source' git hashes match the submodule hashes for this
+            ;; release of CBQN.
+            (add-before 'build 'link-local-replxx
+              (lambda* (#:key inputs #:allow-other-keys)
+                (symlink #+replxx-sources "build/replxxLocal")))
+            (add-before 'build 'link-local-singeli
+              (lambda* (#:key inputs #:allow-other-keys)
+                (symlink #+singeli-sources "build/singeliLocal")))
+            ;; The BQN built as part of `cbqn-bootstrap' is used here to
+            ;; generate bytecode rather than downloading pre-built bytecode.
+            (add-before 'build 'generate-bytecode
+              (lambda* (#:key inputs #:allow-other-keys)
+                (mkdir-p "build/bytecodeLocal/gen")
+                (system (string-append #+cbqn-bootstrap
+                                       "/bin/bqn build/bootstrap.bqn "
+                                       #+bqn-sources))))
             (replace 'check
               (lambda* (#:key inputs tests? #:allow-other-keys)
                 (when tests?
                   (system (string-append "./BQN -M 1000 \""
-                                         #+bqn-sources
-                                         "/test/this.bqn\""))
+                                         #+bqn-sources "/test/this.bqn\""))
                   (map (lambda (x)
-                         (system (string-append "./BQN ./test/" x
-                                                ".bqn")))
-                       '("cmp" "equal" "copy" "random"))
+                         (system (string-append "./BQN ./test/" x ".bqn")))
+                       '("cmp" "equal"
+                         "copy"
+                         "bitcpy"
+                         "bit"
+                         "mut"
+                         "hash"
+                         "squeezeValid"
+                         "squeezeExact"
+                         "various"
+                         "random"
+                         "joinReuse"))
                   (system "make -C test/ffi"))))
             (replace 'install
               (lambda* (#:key outputs #:allow-other-keys)
-                (let* ((bin (string-append (assoc-ref outputs "out")
-                                           "/bin"))
-                       (lib (string-append (assoc-ref outputs "lib")
-                                           "/lib"))
+                (let* ((bin (string-append (assoc-ref outputs "out") "/bin"))
+                       (lib (string-append (assoc-ref outputs "lib") "/lib"))
                        (include (string-append (assoc-ref outputs "lib")
-                                           "/include")))
+                                               "/include")))
                   (mkdir-p bin)
                   (rename-file "BQN" "bqn")
                   (install-file "bqn" bin)
                   (install-file "libcbqn.so" lib)
                   (install-file "include/bqnffi.h" include))))))))
-    (native-inputs (list dbqn
-                         bqn-sources
-                         libffi))
-    (properties
-     `((tunable? . #t)))))
+    (native-inputs (list bqn-sources cbqn-bootstrap replxx-sources
+                         singeli-sources libffi))
+    (properties `((tunable? . #t)))))
-- 
2.48.1