[bug#67755,v6,7/8] gnu: Add imhex-pattern-language.

Message ID 3e69e80e8355c88c21debc4c63c3abc04633f042.1742403600.git.liliana.prikler@gmail.com
State New
Headers
Series gnu: Add imhex |

Commit Message

Liliana Marie Prikler March 19, 2025, 5 p.m. UTC
  * gnu/packages/hexedit.scm (imhex-pattern-language): New variable.

Change-Id: I641bebed0bea9b2c8aca87f54d0fb457064a07d7
---
Changes from v5:
* Use system fmt (fmt-11).
* Use a keep list rather than a delete list.

I think the header-only libraries should be provided as regular inputs,
but haven't done that yet.

 gnu/packages/hexedit.scm | 71 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)
  

Comments

Sergio Pastor Pérez March 19, 2025, 8:25 p.m. UTC | #1
On 3/19/25 18:00, Sergio Pastor Pérez wrote:
> * gnu/packages/hexedit.scm (imhex-pattern-language): New variable.
> 
> Change-Id: I641bebed0bea9b2c8aca87f54d0fb457064a07d7
> ---
> Changes from v5:
> * Use system fmt (fmt-11).

This is fine.

> * Use a keep list rather than a delete list.

Looks good to me.

> I think the header-only libraries should be provided as regular inputs,
> but haven't done that yet.

As you think goes more inline with Guix philosophy.

> +(define-public imhex-pattern-language
 > [...]
> +       (snippet #~(begin
> +                    ;; NOTE: the `throwing-ptr' hasn't been updated in 6 years
> +                    ;; and the testsuite expects to use an outdated version of

I wrote bad english here:
> +                    ;; Conan, since this library if not interesting to have it
> +                    ;; in Guix it will remain bundled.

It should probably be:
`since this library is not interesting for Guix, it will remain bundled.`


Thanks for your work!


Best regards,
Sergio.
  
Liliana Marie Prikler March 26, 2025, 9:58 p.m. UTC | #2
Am Mittwoch, dem 19.03.2025 um 21:25 +0100 schrieb Sergio Pastor Pérez:
> On 3/19/25 18:00, Sergio Pastor Pérez wrote:
> > * gnu/packages/hexedit.scm (imhex-pattern-language): New variable.
> > 
> > Change-Id: I641bebed0bea9b2c8aca87f54d0fb457064a07d7
> > ---
> > Changes from v5:
> > * Use system fmt (fmt-11).
> 
> This is fine.
> 
> > * Use a keep list rather than a delete list.
> 
> Looks good to me.
> 
> > I think the header-only libraries should be provided as regular
> > inputs,
> > but haven't done that yet.
> 
> As you think goes more inline with Guix philosophy.
> 
> > +(define-public imhex-pattern-language
>  > [...]
> > +       (snippet #~(begin
> > +                    ;; NOTE: the `throwing-ptr' hasn't been
> > updated in 6 years
> > +                    ;; and the testsuite expects to use an
> > outdated version of
> 
> I wrote bad english here:
> > +                    ;; Conan, since this library if not
> > interesting to have it
> > +                    ;; in Guix it will remain bundled.
> 
> It should probably be:
> `since this library is not interesting for Guix, it will remain
> bundled.`
Pushed, sadly without the above changes.  I'll mark this as done and
maybe come back later to add the cosmetics.

Cheers
  

Patch

diff --git a/gnu/packages/hexedit.scm b/gnu/packages/hexedit.scm
index 15bf7db8773..ed30e882847 100644
--- a/gnu/packages/hexedit.scm
+++ b/gnu/packages/hexedit.scm
@@ -4,6 +4,7 @@ 
 ;;; Copyright © 2018, 2020, 2022 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
 ;;; Copyright © 2024 Artyom V. Poptsov <poptsov.artyom@gmail.com>
+;;; Copyright © 2025 Sergio Pastor Pérez <sergio.pastorperez@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -22,17 +23,23 @@ 
 
 (define-module (gnu packages hexedit)
   #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (guix gexp)
   #:use-module (guix packages)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages man)
+  #:use-module (gnu packages cpp)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages python)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages pretty-print)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module (guix gexp)
   #:use-module (guix utils)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix build-system cmake))
 
 (define-public hexedit
   (package
@@ -137,6 +144,68 @@  (define-public ht
     (home-page "https://hte.sourceforge.net/")
     (license license:gpl2)))
 
+;; NOTE: The install target of imhex-pattern-language falls short in a few areas
+;; that make this package difficult to use outside of ImHex.  Neither header
+;; files nor package information (using e.g. pkg-config or CMake files) are
+;; currently available.
+(define-public imhex-pattern-language
+  (package
+    (name "imhex-pattern-language")
+    (version "1.37.4")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/WerWolv/PatternLanguage")
+             (commit (string-append "ImHex-v" version))
+             (recursive? #t)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "13mlbclg2r3axv6vz4dsyry5azc6xavcbdkvwan6zyaq9ngk7r3r"))
+       (modules '((guix build utils) (ice-9 ftw)))
+       (snippet #~(begin
+                    ;; NOTE: the `throwing-ptr' hasn't been updated in 6 years
+                    ;; and the testsuite expects to use an outdated version of
+                    ;; Conan, since this library if not interesting to have it
+                    ;; in Guix it will remain bundled.
+                    ;; NOTE: `libwolf' does not have an install target. Until
+                    ;; the maintainers create one, it will be bundled.
+                    (with-directory-excursion "external"
+                      (for-each
+                       (lambda (dir)
+                         (unless (member dir '("." ".." "libwolv" "throwing_ptr"))
+                           (delete-file-recursively dir)))
+                       (scandir ".")))))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:configure-flags ''("-DLIBPL_SHARED_LIBRARY=ON"
+                           "-DLIBPL_ENABLE_TESTS=ON"
+                           "-DUSE_SYSTEM_NLOHMANN_JSON=ON"
+                           "-DUSE_SYSTEM_CLI11=ON"
+                           "-DUSE_SYSTEM_FMT=ON")
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'fix-rel-paths
+            (lambda _
+              (substitute* "tests/include/test_patterns/test_pattern_format.hpp"
+                (("../tests/files/export/")
+                 "../source/tests/files/export/"))))
+          (add-after 'build 'build-tests
+            (lambda _
+              (invoke "make" "pattern_language_tests" "plcli")))
+          (add-before 'check 'plcli-integration-tests
+            (lambda _
+              (with-directory-excursion "../source"
+                (invoke "python3" "tests/integration/integration.py"
+                        "../build/cli/plcli")))))))
+    (native-inputs (list cli11 gcc-14 fmt-11 nlohmann-json python))
+    (home-page "https://imhex.werwolv.net")
+    (synopsis "Pattern language used by the ImHex Hex Editor")
+    (description "This package provides a C-like domain-specific language used
+for specifying patterns in the ImHex Hex Editor.")
+    (license license:lgpl2.1)))
+
 (define-public bvi
   (package
     (name "bvi")