diff mbox series

[bug#70087,v2,1/4] gnu: gecode: Update to 6.2.0-1.f7f0d7c.

Message ID a5751f750c3aa223830e82826d4f3204c509c314.1715786322.git.herman@rimm.ee
State New
Headers show
Series [bug#70087,v2,1/4] gnu: gecode: Update to 6.2.0-1.f7f0d7c. | expand

Commit Message

Herman Rimm May 15, 2024, 3:51 p.m. UTC
* gnu/packages/maths.scm (gecode): Update to 6.2.0-1.f7f0d7c.
[version]: Use version.
[source]: Use commit.
[arguments]: Add patch-msc-and-version phase.
(minizinc)[arguments]: Copy provided gecode.msc file instead.

Change-Id: I5e89105f3fef61d6aa677a4a118225679220ce5d
---
 gnu/packages/maths.scm | 174 +++++++++++++++++++----------------------
 1 file changed, 82 insertions(+), 92 deletions(-)


base-commit: 059c9ed104c91f7a537f369c4524b91d6cf8a13e

Comments

Andreas Enge May 15, 2024, 5:08 p.m. UTC | #1
Hello Herman,

it looks like we have worked in parallel on this patchset, sorry for this!
With my previous commits to master, your v2 does not apply any more.

I have updated chuffed to version 0.13.2, which covers your patch 2.
Your patch 3 has already been applied in a form derived from your v1.
I have compiled minizinc with the new chuffed, and could use them together
to solve the magic square. So we are in a working and consistent state.

Could you please send a v3 of your patches 1 and 4, based on current
master? I suppose patch 4 can remain as it is.
For patch 1, the new revision should then be 3, as we are currently at 2.
As written above, updating minizinc and gecode simultaneously to their
latest versions did not work out of the box for me. I suppose that these
two features:

Am Wed, May 15, 2024 at 05:51:22PM +0200 schrieb Herman Rimm:
> [arguments]: Add patch-msc-and-version phase.
> (minizinc)[arguments]: Copy provided gecode.msc file instead.

solve the problem?

I have reopened the bug, and will let you go ahead now; I think you
are in a better position than me for adapting your patches to the
current master.

Thanks,

Andreas
diff mbox series

Patch

diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm
index d551b751e6..48f43f264b 100644
--- a/gnu/packages/maths.scm
+++ b/gnu/packages/maths.scm
@@ -63,6 +63,7 @@ 
 ;;; Copyright © 2023 Jake Leporte <jakeleporte@outlook.com>
 ;;; Copyright © 2023 Camilo Q.S. (Distopico) <distopico@riseup.net>
 ;;; Copyright © 2023 David Elsing <david.elsing@posteo.net>
+;;; Copyright © 2024 Herman Rimm <herman@rimm.ee>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -2612,73 +2613,81 @@  (define-public clp
     (license license:epl1.0)))
 
 (define-public gecode
-  (package
-    (name "gecode")
-    (version "6.2.0")
-    (source (origin
-              (method git-fetch)
-              (uri (git-reference
-                    (url "https://github.com/Gecode/gecode")
-                    (commit (string-append "release-" version))))
-              (file-name (git-file-name name version))
-              (sha256
-               (base32
-                "0b1cq0c810j1xr2x9y9996p894571sdxng5h74py17c6nr8c6dmk"))
-              (modules '((guix build utils)))
-              (snippet
-               '(begin
-                  ;; delete generated sources
-                  (for-each delete-file
-                            '("gecode/kernel/var-imp.hpp"
-                              "gecode/kernel/var-type.hpp"))))))
-    (outputs '("out" "examples"))
-    (build-system gnu-build-system)
-    (arguments
-     `(#:configure-flags
-       (list (string-append "GLDFLAGS=-Wl,-rpath="
-                            (assoc-ref %outputs "out")
-                            "/lib")
-             "--enable-examples=no")
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (ice-9 rdelim)
-                  (ice-9 popen))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'build 'build-examples
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "make" "compileexamples")))
-         ;; The Makefile disrespects GLDFLAGS for some reason, so we have to
-         ;; patch it ourselves... *sigh*
-         (add-after 'install 'fix-rpath
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let ((libdir (string-append (assoc-ref outputs "out") "/lib")))
-               (for-each
-                (lambda (file)
-                  (let* ((pipe (open-pipe* OPEN_READ "patchelf"
-                                          "--print-rpath" file))
-                         (line (read-line pipe)))
-                    (and (zero? (close-pipe pipe))
-                         (invoke "patchelf" "--set-rpath"
-                                 (string-append libdir ":" line)
-                                 file))))
-                (find-files libdir ".*\\.so$")))))
-         (add-after 'install 'install-examples
-           (lambda* (#:key outputs #:allow-other-keys)
-             (invoke "make" "installexamples"
-                     (string-append "bindir=" (assoc-ref outputs "examples")
-                                    "/bin"))))
-         ;; Tests depend on installed libraries.
-         (delete 'check)
-         (add-after 'fix-rpath 'check
-           (assoc-ref %standard-phases 'check)))))
-    (native-inputs
-     (list patchelf perl sed))
-    (home-page "https://www.gecode.org")
-    (synopsis "Toolkit for developing constraint-based systems")
-    (description "Gecode is a C++ toolkit for developing constraint-based
-systems and applications.  It provides a modular and extensible solver.")
-    (license license:expat)))
+  (let* ((commit "f7f0d7c273d6844698f01cec8229ebe0b66a016a")
+         (version (git-version "6.2.0" "1" commit)))
+    (package
+      (name "gecode")
+      (version version)
+      (source
+        (origin
+          (method git-fetch)
+          (uri (git-reference
+                 (url "https://github.com/Gecode/gecode")
+                 (commit commit)))
+          (file-name (git-file-name name version))
+          (sha256
+           (base32
+             "16gzwa64w90vifaflmii515rsrqclf2y7nziq621m4ad9cjgcixj"))
+          (modules '((guix build utils)))
+          ;; delete generated sources
+          (snippet '(for-each delete-file
+                              '("gecode/kernel/var-imp.hpp"
+                                "gecode/kernel/var-type.hpp")))))
+      (outputs '("out" "examples"))
+      (build-system gnu-build-system)
+      (arguments
+        (list
+          #:configure-flags
+          #~(list (string-append "GLDFLAGS=-Wl,-rpath="
+                                 (assoc-ref %outputs "out") "/lib")
+                  "--enable-examples=no")
+          #:modules '((guix build gnu-build-system)
+                      (guix build utils)
+                      (ice-9 rdelim)
+                      (ice-9 popen))
+          #:phases
+          #~(modify-phases %standard-phases
+              (add-before 'configure 'patch-msc-and-version
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let ((out (assoc-ref outputs "out")))
+                    (substitute* "tools/flatzinc/gecode.msc.in"
+                      (("\\.\\./../..") out)
+                      (("\\.\\.")
+                       (string-append out "/share/minizinc")))
+                    (substitute* "configure"
+                      (("(PACKAGE_[^0-9]*)[0-9\\.]+" all match)
+                       (string-append match #$version))))))
+              (add-after 'build 'build-examples
+                (lambda _
+                  (invoke "make" "compileexamples")))
+              ;; The Makefile disrespects GLDFLAGS for some reason, so
+              ;; we have to patch it ourselves... *sigh*
+              (add-after 'install 'fix-rpath
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let* ((out (assoc-ref outputs "out"))
+                         (libdir (string-append out "/lib")))
+                    (for-each
+                      (lambda (file)
+                        (let* ((pipe (open-pipe* OPEN_READ "patchelf"
+                                                 "--print-rpath" file))
+                               (line (read-line pipe)))
+                          (and (zero? (close-pipe pipe))
+                               (invoke "patchelf" "--set-rpath"
+                                       (string-append libdir ":" line)
+                                       file))))
+                      (find-files libdir ".*\\.so$")))))
+              (add-after 'install 'install-examples
+                (lambda* (#:key outputs #:allow-other-keys)
+                  (let* ((examples (assoc-ref outputs "examples"))
+                         (bindir (format #f "bindir=~a/bin" examples)))
+                    (invoke "make" "installexamples" bindir)))))))
+      (native-inputs (list patchelf perl sed))
+      (home-page "https://www.gecode.org")
+      (synopsis "Toolkit for developing constraint-based systems")
+      (description
+        "Gecode is a C++ toolkit for developing constraint-based systems
+and applications.  It provides a modular and extensible solver.")
+      (license license:expat))))
 
 (define-public libfixmath
   (let ((commit "1416c9979635c69f344d3c1de84b3246001a6540")
@@ -4083,31 +4092,12 @@  (define-public minizinc
 }"
                             port)
                    (newline port)))
-
-               (mkdir-p (string-append pkgdatadir "/solvers"))
-               (call-with-output-file (string-append pkgdatadir
-                                                     "/solvers/gecode.msc")
-                 (lambda (port)
-                   (format port
-                    "\
-{
-  \"id\": \"org.gecode.gecode\",
-  \"name\": \"Gecode\",
-  \"description\": \"Gecode FlatZinc executable\",
-  \"version\": ~s,
-  \"mznlib\": ~s,
-  \"executable\": ~s,
-  \"supportsMzn\": false,
-  \"supportsFzn\": true,
-  \"needsSolns2Out\": true,
-  \"needsMznExecutable\": false,
-  \"needsStdlibDir\": false,
-  \"isGUIApplication\": false
-}"
-                    (last (string-split gecode #\-))
-                    (string-append gecode "/share/gecode/mznlib")
-                    (string-append gecode "/bin/fzn-gecode"))
-                   (newline port)))))))))
+               (for-each
+                 (lambda (solver)
+                   (copy-recursively
+                     (string-append solver "/share/minizinc/solvers")
+                     (string-append pkgdatadir "/solvers")))
+                 (list gecode))))))))
     (native-inputs
      (list bison flex))
     (inputs