Subject: [bug#57337] [v2 2/2] gnu: Add docxbox.

From: Ludovic Courtès <[email-masked]>
Date: Wed, 25 Jan 2023 23:21:05 +0100

Wiktor Żelazny <[email-masked]> skribis:

> * gnu/packages/textutils.scm (docxbox): New variable.

[...]

> +                (snippet '(begin
> +                            (for-each delete-file-recursively
> +                                      '("bin" "vendor/json" "vendor/miniz-cpp"
> +                                        "vendor/tinyxml2"))))))

No need for ‘begin’.

> +      (build-system cmake-build-system)
> +      ;; (native-inputs (list bats)) ; Enable after fixing tests, use bash module
> +      (inputs `(("json-modern-cxx" ,json-modern-cxx)
> +                ("miniz-cpp" ,miniz-cpp)
> +                ("tinyxml2-source" ,(package-source tinyxml2))))

You can write:

  (inputs (list json-modern-cxx miniz-cpp))

and…

> +      (arguments
> +       `(#:phases (modify-phases %standard-phases
> +                    (add-after 'unpack 'unvendor
> +                      (lambda* (#:key inputs #:allow-other-keys)
> +                        (substitute* "CMakeLists.txt"
> +                          (("vendor/miniz-cpp/zip_file.hpp")
> +                           ""))
> +                        (with-directory-excursion "docxbox"
> +                          (substitute* (find-files "." "\\.(cc|h)$")
> +                            (("#include <vendor/json/single_include/")
> +                             "#include <"))
> +                          (substitute* (find-files "." "\\.hpp$")
> +                            (("#include <vendor/miniz-cpp/")
> +                             "#include <")))))
> +                    (add-after 'unpack 'unpack-tinyxml2
> +                      (lambda* (#:key inputs #:allow-other-keys)
> +                        (mkdir-p "vendor/tinyxml2")
> +                        (copy-recursively (assoc-ref inputs "tinyxml2-source")
> +                                          "vendor/tinyxml2")))

… this:

  (arguments
    (list #:phases
          #~(modify-phases …
               (copy-recursively #$(package-source tinyxml2) …)
               …)))

It would be best if it could depend on TinyXML2 directly, rather than
rebuilding it as part of the build process, but I supposed that’s
trickier so we can leave that for later.

Could you send an updated patch, together with the miniz-cpp one?

Thanks in advance!

Ludo’.