diff mbox series

[bug#69661,v2] gnu: Add redo-apenwarr.

Message ID 01018827d399b901ecbb41165f568ebe0458a19e.1710255932.git.mzan@dokmelody.org
State New
Headers show
Series [bug#69661,v2] gnu: Add redo-apenwarr. | expand

Commit Message

Massimo Zaniboni March 12, 2024, 3:05 p.m. UTC
* gnu/packages/build-tools.scm (redo-apenwarr): New variable.

Change-Id: Ied142a7dc3e9baf9babdeff046f350e647a7a5cc
---
 gnu/packages/build-tools.scm | 128 +++++++++++++++++++++++++++++++++++
 1 file changed, 128 insertions(+)


base-commit: d79c88e8809d2079452fd276bf4d17eb16636ff9
diff mbox series

Patch

diff --git a/gnu/packages/build-tools.scm b/gnu/packages/build-tools.scm
index 15d88de..11dd337 100644
--- a/gnu/packages/build-tools.scm
+++ b/gnu/packages/build-tools.scm
@@ -15,6 +15,7 @@ 
 ;;; Copyright © 2021 qblade <qblade@protonmail.com>
 ;;; Copyright © 2021, 2023 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2022, 2023 Juliana Sims <juli@incana.org>
+;;; Copyright © 2024 Massimo Zaniboni <mzan@dokmelody.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -457,6 +458,133 @@  (define-public premake5
 scripted definition of a software project and outputs @file{Makefile}s or
 other lower-level build files.")))
 
+(define-public redo-apenwarr
+  (let ((origin-url "https://github.com/apenwarr/redo")
+        (origin-date "2021-07-27 20:48:36 -0700")
+        (origin-version "0.42d")
+        (origin-commit "7f00abc36be15f398fa3ecf9f4e5283509c34a00"))
+    
+    (package
+      (name "redo-apenwarr")
+      (version origin-version)
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url origin-url)
+               (commit (string-append "redo-" version))))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32 "0z78fmkb85k9hnpvh0pgi8cahljjgnr6j7mb614cykvpa3xsyl0p"))))
+
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:test-target "test"
+        #:make-flags #~(list (string-append "PREFIX="
+                                            #$output "/out") "DESTDIR=/")
+        #:phases #~(modify-phases %standard-phases
+                     (delete 'configure)
+                     (add-before 'build 'patch-shell-scripts
+                       (lambda* _
+                         
+                         ;; The building tool queries the Git repository,
+                         ;; for retrieving info about the commit hash and date,
+                         ;; but this information is not anymore present in the
+                         ;; source code downloaded from Guix.
+                         ;; So this information will be generated manually here,
+                         ;; using the data specified in the `origin-*' params.
+                         (substitute* '("redo/version/gitvars.pre")
+                           (("\\$Format:%H\\$")
+                            #$origin-commit)
+                           (("\\$Format:%d\\$")
+                            (format #f "(HEAD -> main, tag: redo-~a)"
+                                    #$origin-version))
+                           (("\\$Format:%ci\\$")
+                            #$origin-date))
+
+                         ;; redo-apenwarr can generate support scripts having
+                         ;; shebangs headers. We will patch these scripts
+                         ;; for using the `sh' in the store.
+                         (substitute* '("bin/default.do"
+                                        "t/203-make/whichmake.do"
+                                        "redo/py.do"
+                                        "redoconf/link.od"
+                                        "redoconf/run.od"
+                                        "redoconf/link-shlib.od"
+                                        "redoconf/_compile.od"
+                                        "redoconf/compile.od"
+                                        "minimal/do")
+                           (("#!/bin/sh")
+                            (string-append "#!"
+                                           #$(file-append bash "/bin/sh"))))
+
+                         ;; Use `pwd' on the store.
+                         (substitute* '("t/all.do" "t/105-sympath/all.do"
+                                        "t/110-compile/hello.o.do"
+                                        "minimal/do" "minimal/do.test" "do")
+                           (("/bin/pwd")
+                            #$(file-append coreutils "/bin/pwd"))
+                           (("/bin/ls")
+                            #$(file-append coreutils "/bin/ls")))
+
+                         ;; Use `perl' on the store.
+                         (substitute* '("t/200-shell/nonshelltest.do")
+                           (("/usr/bin/env perl")
+                            #$(file-append perl "/bin/perl")))
+
+                         ;; Use `gcc' compiler, because Guix has no default `cc' compiler.
+                         (substitute* '("docs/cookbook/hello/hello.do"
+                                        "t/110-compile/LD.do"
+                                        "t/110-compile/CC.do"
+                                        "t/110-compile/yellow.o.do"
+                                        "t/111-example/CC.do"
+                                        "t/111-example/hello.do")
+                           (("^([ \t]*)cc " dummy starting-spaces)
+                            (string-append starting-spaces
+                                           #$(file-append gcc "/bin/gcc") " ")))
+
+                         (substitute* '("t/110-compile/all.do"
+                                        "t/111-example/all.do")
+                           ((" type cc ")
+                            " type gcc "))
+
+                         (substitute* '("docs/cookbook/c/flagtest.o.od")
+                           (("^CC=\"\\$CC\"")
+                            (string-append "CC=\""
+                                           #$(file-append gcc "/bin/gcc") "\""))))))))
+
+      (inputs (list coreutils bash python-wrapper))
+      (native-inputs (list ;Used from the building script,
+                           ;; for checking the existences of coreutils on the path.
+                           which
+
+                           ;; Required for generating the documentation
+                           python-markdown
+                           python-beautifulsoup4
+
+                           ;; TODO it cannot generate some part of the the documentation,
+                           ;; because the disabled package python-mkdocs requires
+                           ;; the missing PyPI plugin python-mkdocs-exclude
+                           
+                           ;; Required only for the tests.
+                           perl
+                           git
+                           gcc))
+
+      (synopsis
+       "Build tool where dependencies are parts of the building instructions")
+      (description
+       "@code{redo-apenwarr} is a build tool where each target file is produced by
+a normal shell script, but with additional commands for specifying
+its dependencies.  In tools like @code{make}, dependencies are specified
+upfront (i.e. bottom-up), while in @code{redo-apenwarr} they are
+generated dynamically during build script execution (i.e. top-down).
+Rebuilds are incremental, i.e. only target files with changed dependencies
+will be rebuilt.")
+      (home-page "https://github.com/apenwarr/redo")
+      (license license:asl2.0))))
+
 (define-public scons
   (package
     (name "scons")