diff mbox series

[bug#38687,1/2] gnu: Add lodepng.

Message ID 20200206201713.8535-1-goodoldpaul@autistici.org
State Accepted
Headers show
Series [bug#38687,1/2] gnu: Add lodepng. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Giacomo Leidi Feb. 6, 2020, 8:17 p.m. UTC
* gnu/packages/image.scm (lodepng): New variable.
---
 gnu/packages/image.scm | 58 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

Comments

Marius Bakke Feb. 10, 2020, 9:14 p.m. UTC | #1
Giacomo Leidi <goodoldpaul@autistici.org> writes:

> * gnu/packages/image.scm (lodepng): New variable.

[...]

> +(define-public lodepng
> +  ;; The project doesn't seem to use any
> +  ;; kind of meaningful versioning scheme.
> +  (let ((commit "5a0dba103893e6b8084be13945a826663917d00a")
> +        (revision "1")
> +        (version "0.0.0"))

There is a LODEPNG_VERSION_STRING in lodepng.cpp, can you set the
"version" variable here to that?

> +    (package
> +      (name "lodepng")
> +      (version (git-version version revision commit))
> +      (source (origin
> +                (method git-fetch)
> +                (uri (git-reference
> +                      (url "https://github.com/lvandeve/lodepng")
> +                      (commit commit)))
> +                (sha256
> +                 (base32
> +                  "0nvlba82mf4n7xfc3rz2g9wwgnrxpjw64p5dsjmj2r06g5m4l38a"))
> +                (file-name (git-file-name name version))))
> +      (build-system gnu-build-system)
> +      (arguments
> +       '(#:phases
> +         (modify-phases %standard-phases
> +           (delete 'configure)
> +           (replace 'build
> +             (lambda _
> +               (setenv "CXXFLAGS" "-fPIC")
> +               (invoke "make" "lodepng.o")
> +               (invoke "make" "lodepng_util.o")
> +               (invoke "ar" "rv" "liblodepng.a" "lodepng.o" "lodepng_util.o")
> +               (invoke "g++" "-fPIC" "-O3"
> +                       "-o" "liblodepng.so"
> +                       "-shared" "lodepng.o" "lodepng_util.o")
> +               #t))
> +           (replace 'check
> +             (lambda _
> +               (invoke "make" "unittest")
> +               (invoke "./unittest")
> +               #t))
> +           (replace 'install
> +             (lambda* (#:key outputs #:allow-other-keys)
> +               (let* ((out (assoc-ref outputs "out"))
> +                      (doc (string-append out "/share/doc"))
> +                      (lib (string-append out "/lib"))
> +                      (include (string-append out "/include")))
> +                 (install-file "lodepng.h" include)
> +                 (install-file "lodepng_util.h" include)
> +                 (install-file "liblodepng.a" lib)

We try to avoid static libraries in Guix, so no need to install this
file.

Otherwise LGTM.
diff mbox series

Patch

diff --git a/gnu/packages/image.scm b/gnu/packages/image.scm
index 45055858b4..18a51a8773 100644
--- a/gnu/packages/image.scm
+++ b/gnu/packages/image.scm
@@ -23,6 +23,7 @@ 
 ;;; Copyright © 2018 Pierre-Antoine Rouby <contact@parouby.fr>
 ;;; Copyright © 2018 Alex Vong <alexvong1995@gmail.com>
 ;;; Copyright © 2018 Rutger Helling <rhelling@mykolab.com>
+;;; Copyright © 2020 Giacomo Leidi <goodoldpaul@autistici.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1841,3 +1842,60 @@  using only text tools.
 SNG is implemented by a compiler/decompiler called sng that
 losslessly translates between SNG and PNG.")
     (license license:zlib)))
+
+(define-public lodepng
+  ;; The project doesn't seem to use any
+  ;; kind of meaningful versioning scheme.
+  (let ((commit "5a0dba103893e6b8084be13945a826663917d00a")
+        (revision "1")
+        (version "0.0.0"))
+    (package
+      (name "lodepng")
+      (version (git-version version revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/lvandeve/lodepng")
+                      (commit commit)))
+                (sha256
+                 (base32
+                  "0nvlba82mf4n7xfc3rz2g9wwgnrxpjw64p5dsjmj2r06g5m4l38a"))
+                (file-name (git-file-name name version))))
+      (build-system gnu-build-system)
+      (arguments
+       '(#:phases
+         (modify-phases %standard-phases
+           (delete 'configure)
+           (replace 'build
+             (lambda _
+               (setenv "CXXFLAGS" "-fPIC")
+               (invoke "make" "lodepng.o")
+               (invoke "make" "lodepng_util.o")
+               (invoke "ar" "rv" "liblodepng.a" "lodepng.o" "lodepng_util.o")
+               (invoke "g++" "-fPIC" "-O3"
+                       "-o" "liblodepng.so"
+                       "-shared" "lodepng.o" "lodepng_util.o")
+               #t))
+           (replace 'check
+             (lambda _
+               (invoke "make" "unittest")
+               (invoke "./unittest")
+               #t))
+           (replace 'install
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (doc (string-append out "/share/doc"))
+                      (lib (string-append out "/lib"))
+                      (include (string-append out "/include")))
+                 (install-file "lodepng.h" include)
+                 (install-file "lodepng_util.h" include)
+                 (install-file "liblodepng.a" lib)
+                 (install-file "liblodepng.so" lib)
+                 (install-file "README.md" doc)
+                 #t))))))
+      (home-page "https://lodev.org/lodepng/")
+      (synopsis "PNG encoder and decoder in C and C++, without dependencies")
+      (description "LodePNG is a PNG image decoder and encoder, all in one,
+no dependency or linkage required.  It's made for C (ISO C90), and has a C++
+wrapper with a more convenient interface on top.")
+      (license license:zlib))))