Subject: [bug#45601] [PATCH 3/6] gnu: vlang: Use system tiny-bignum.

From: Ryan Prior <[email-masked]>
Date: Fri, 01 Jan 2021 19:27:24 +0000

* gnu/packages/vlang.scm (vlang): Update to use system tiny-bignum.
---
 gnu/packages/vlang.scm | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/gnu/packages/vlang.scm b/gnu/packages/vlang.scm
index 212862cb1d..a2f6e93945 100644
--- a/gnu/packages/vlang.scm
+++ b/gnu/packages/vlang.scm
@@ -21,6 +21,7 @@
 (define-module (gnu packages vlang)
   #:use-module (gnu packages glib)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages maths)
   #:use-module (gnu packages node)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages tls)
@@ -57,7 +58,12 @@
            (commit version)))
      (file-name (git-file-name name version))
      (sha256
-      (base32 "1x2sf2j6xl11kjvv0i0anjqwsfb1la11xr7yhdnbix9808442wm2"))))
+      (base32 "1x2sf2j6xl11kjvv0i0anjqwsfb1la11xr7yhdnbix9808442wm2"))
+     (modules '((guix build utils)))
+     (snippet
+      '(begin
+         ;; Eventually remove the whole thirdparty directory.
+         (delete-file-recursively "thirdparty/bignum")))))
    (build-system gnu-build-system)
    (arguments
     `(#:make-flags
@@ -72,11 +78,14 @@
       #:phases
       (modify-phases %standard-phases
         (delete 'configure)
-        (add-before 'build 'patch-makefile
-          (lambda _
+        (add-before 'build 'patch-files
+          (lambda* (#:key inputs #:allow-other-keys)
             (substitute* "Makefile"
               (("rm -rf") "true")
-              (("--branch") ""))))
+              (("--branch") ""))
+            (substitute* "vlib/math/big/big.v"
+              (("@VROOT/thirdparty/bignum")
+               (string-append (assoc-ref inputs "tiny-bignum") "/share")))))
         (add-before 'build 'patch-cc
           (lambda _
             (let* ((bin "tmp/bin")
@@ -135,7 +144,8 @@
               (copy-file "v.mod" vmod))
             #t)))))
    (inputs
-    `(("glib" ,glib)))
+    `(("glib" ,glib)
+      ("tiny-bignum" ,tiny-bignum)))
    (native-inputs
     `(("vc"
        ;; Versions are not consistently tagged, but the matching commit will
-- 
2.29.2