Subject: [bug#77552] [PATCH v2 5/5] gnu: cbqn: Update to 0.9.0.

From: Lee Thompson <[email-masked]>
Date: Thu, 10 Apr 2025 14:38:36 +0100

* gnu/packages/bqn.scm (cbqn): Update to 0.9.0.

[arguments]<#:phases>: Phases linking REPLXX and Singeli and to generate
bytecode are added before build, new tests are added to the replaced 'check.
[native-inputs]: Removed `dbqn', added `cbqn-bootstrap', `replxx-sources' and
`singeli-sources'.
[license]: Licenses for REPLXX and Singeli appended to those for just CBQN.

Change-Id: I97ba12dd9d67b944ef7be1d6d76a98f4f2d69e35
---
 gnu/packages/bqn.scm | 41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/bqn.scm b/gnu/packages/bqn.scm
index 1caf6f3c8a..a90007f593 100644
--- a/gnu/packages/bqn.scm
+++ b/gnu/packages/bqn.scm
@@ -210,6 +210,24 @@ (define-public cbqn
         #~(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?
@@ -219,7 +237,17 @@ (define-public cbqn
                   (map (lambda (x)
                          (system (string-append "./BQN ./test/" x
                                                 ".bqn")))
-                       '("cmp" "equal" "copy" "random"))
+                       '("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)
@@ -234,8 +262,11 @@ (define-public cbqn
                   (install-file "bqn" bin)
                   (install-file "libcbqn.so" lib)
                   (install-file "include/bqnffi.h" include))))))))
-    (native-inputs (list dbqn
-                         bqn-sources
-                         libffi))
+    (native-inputs (list bqn-sources cbqn-bootstrap replxx-sources
+                         singeli-sources libffi))
     (properties
-     `((tunable? . #t)))))
+     `((tunable? . #t)))
+    (license (append (package-license cbqn-bootstrap)
+                     (list license:isc   ;Singeli module
+                           license:bsd-3 ;REPLXX module
+                           license:unicode)))))
-- 
2.48.1