guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#56368] [PATCH v2 4/4] gnu: Add cppawk and cppawk-egawk.


From: Paul A. Patience
Subject: [bug#56368] [PATCH v2 4/4] gnu: Add cppawk and cppawk-egawk.
Date: Mon, 04 Jul 2022 04:59:36 +0000

* gnu/packages/gawk.scm (cppawk, cppawk-egawk): New variables.
---
 gnu/packages/gawk.scm | 85 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/gnu/packages/gawk.scm b/gnu/packages/gawk.scm
index 6b905f6654..9feaf059fb 100644
--- a/gnu/packages/gawk.scm
+++ b/gnu/packages/gawk.scm
@@ -23,12 +23,16 @@
 (define-module (gnu packages gawk)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages libsigsegv)
   #:use-module (gnu packages multiprecision)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix git-download)
+  #:use-module (guix utils)
+  #:use-module (guix build-system copy)
   #:use-module (guix build-system gnu))

 (define-public gawk
@@ -160,3 +164,84 @@ (define-public mawk
 This version aims to be smaller and faster than GNU Awk, at the expense
 of fewer features and extensions.")
     (license license:gpl2))) ;version 2 only
+
+(define-public cppawk
+  (package
+    (name "cppawk")
+    (version "20220703")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://www.kylheku.com/git/cppawk";)
+             (commit version)))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0b09757q81sz4gn62k3mv5bgllyb2v5m64346s8fc99mqqif70cx"))))
+    (build-system copy-build-system)
+    (arguments
+     `(#:install-plan '(("bin/cppawk" "bin/cppawk")
+                        ("share/cppawk/include" "share/cppawk/include")
+                        ("./" "share/man/man1" #:include-regexp (".*\\.1$")))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'fix-paths
+           (lambda _
+             (substitute* "bin/cppawk"
+               (("/bin/bash") (which "bash"))
+               (("dirname") (which "dirname"))
+               (("mktemp") (which "mktemp"))
+               ;; Extra space to prevent matching Awk's printf.
+               (("printf ") (string-append (which "printf") " "))
+               (("rm -f") (string-append (which "rm") " -f"))
+               (("prepro=cpp") (string-append "prepro=" (which "cpp")))
+               (("sed -e") (string-append (which "sed") " -e")))))
+         (add-after 'fix-paths 'fix-awk-paths
+           (lambda _
+             (substitute* "bin/cppawk"
+               (("awk=gawk") (string-append "awk=" (which "gawk")))
+               (("awk '") (string-append (which "gawk") " '")))))
+         (add-after 'build 'check
+           (lambda _
+             (invoke "./runtests"))))))
+    (native-inputs
+     ;; For tests
+     (list mawk))
+    (inputs
+     (list coreutils                    ; For dirname, mktemp, printf, rm
+           gawk-mpfr                    ; Default variant, but supports others
+           gcc                          ; For cpp
+           sed))
+    (home-page "https://www.kylheku.com/cgit/cppawk/";)
+    (synopsis "Wrapper script that adds C preprocessing to Awk")
+    (description
+     "@command{cppawk} is a shell script that invokes the C preprocessor
+(@command{cpp}) on Awk code and calls Awk (by default GNU Awk) on the result.
+
+@command{cppawk} understands the basic Awk options like @option{-F} and
+@option{-v}, and also understands common @command{cpp} options like
+@option{-I} and @option{-Dmacro=value}.
+
+@command{cppawk} has no dependencies beyond Awk, @command{cpp}, @command{sed}
+and some GNU core utilities (including @command{printf}).  Preprocessed
+programs can be captured and transferred to systems that have Awk but not
+@command{cpp} or @command{cppawk}.")
+    (license license:bsd-2)))
+
+(define-public cppawk-egawk
+  (package/inherit cppawk
+    (name "cppawk-egawk")
+    (arguments
+     (substitute-keyword-arguments (package-arguments cppawk)
+       ((#:phases phases)
+        `(modify-phases ,phases
+           (replace 'fix-awk-paths
+             (lambda _
+               (substitute* "bin/cppawk"
+                 (("awk=gawk") (string-append "awk=" (which "egawk")))
+                 (("awk '") (string-append (which "egawk") " '")))))))))
+    (inputs
+     (modify-inputs (package-inputs cppawk)
+       (delete "gawk-mpfr")
+       (prepend egawk-next)))
+    (synopsis "cppawk that calls Enhanced GNU Awk by default")))
--
2.36.1







reply via email to

[Prev in Thread] Current Thread [Next in Thread]