[bug#70319,1/2] gnu: Add tinygltf.

Message ID 769daf7ae2277aecea26723b2a8e3165aa92e146.1712707652.git.monego@posteo.net
State New
Headers
Series Add Draco (3d graphics compression). |

Commit Message

Vinicius Monego April 10, 2024, 12:12 a.m. UTC
* gnu/packages/graphics.scm (tinygltf): New variable.

Change-Id: I749ced85142b8dd2ebbe916533f27bf6d167bbff
---
 gnu/packages/graphics.scm | 45 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
  

Comments

Nicolas Graves May 14, 2024, 12:33 p.m. UTC | #1
On 2024-04-10 00:12, Vinicius Monego wrote:

> * gnu/packages/graphics.scm (tinygltf): New variable.
>
> Change-Id: I749ced85142b8dd2ebbe916533f27bf6d167bbff
> ---
>  gnu/packages/graphics.scm | 45 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 45 insertions(+)
>
> diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
> index a63629823a..d04fcbfd6d 100644
> --- a/gnu/packages/graphics.scm
> +++ b/gnu/packages/graphics.scm
> @@ -2367,6 +2367,51 @@ (define-public openxr
>      ;; Dual licensed.  Either license applies.
>      (license (list license:asl2.0 license:expat))))
>  
> +(define-public tinygltf
> +  (package
> +    (name "tinygltf")
> +    (version "2.8.21")
> +    (source
> +     (origin
> +       (method git-fetch)
> +       (uri (git-reference
> +             (url "https://github.com/syoyo/tinygltf")
> +             (commit (string-append "v" version))))
> +       (file-name (git-file-name name version))
> +       (sha256
> +        (base32 "14712lndwlk4y001jxf2rxhwrw0w5gbc2hyh9kpik1galdzg41ii"))))
> +    (build-system cmake-build-system)
> +    (arguments
> +     (list
> +      #:tests? #f ; tests are not managed by CMake
> +      #:phases
> +      #~(modify-phases %standard-phases
> +          (add-after 'unpack 'use-our-packages
> +            ;; tinygltf ships json.hpp, stb_image.h and stb_image_write.h
> +            ;; into the repo as common files.  Delete those, and use the
> +            ;; files from our packages instead.
> +            (lambda* (#:key inputs #:allow-other-keys)
> +              (for-each delete-file
> +                        (list "json.hpp"
> +                              "stb_image.h"
> +                              "stb_image_write.h"))

These are pretty big files. It would be more adapated to remove them in
a snippet from origin. This is because it avoids them in the nar archive
in Guix substitute servers.

Plus, it seems that we can possibly also remove catch, which is packaged
in Guix.

> +              (symlink (search-input-file inputs "json.hpp")
> +                       "json.hpp")
> +              (symlink (search-input-file inputs "stb_image.h")
> +                       "stb_image.h")
> +              (symlink (search-input-file inputs "stb_image_write.h")
> +                       "stb_image_write.h")))
> +          (add-after 'install 'delete-static-lib
> +            (lambda _
> +              (delete-file (string-append #$output
> +                                          "/lib/libtinygltf.a")))))))
> +    (inputs (list nlohmann-json stb-image stb-image-write))
> +    (home-page "https://github.com/syoyo/tinygltf")
> +    (synopsis "Header only C++11 tiny glTF 2.0 library")
> +    (description "TinyGLTF is a header only C++11 tiny
> +@url{https://github.com/KhronosGroup/glTF, glTF} 2.0 library.")



> +    (license license:expat)))

If we can't remove catch, we should add a Boost license : 
https://github.com/syoyo/tinygltf/tree/v2.8.21?tab=readme-ov-file#third-party-licenses

> +
>  (define-public monado
>    (package
>      (name "monado")
  

Patch

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index a63629823a..d04fcbfd6d 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -2367,6 +2367,51 @@  (define-public openxr
     ;; Dual licensed.  Either license applies.
     (license (list license:asl2.0 license:expat))))
 
+(define-public tinygltf
+  (package
+    (name "tinygltf")
+    (version "2.8.21")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/syoyo/tinygltf")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "14712lndwlk4y001jxf2rxhwrw0w5gbc2hyh9kpik1galdzg41ii"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list
+      #:tests? #f ; tests are not managed by CMake
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'unpack 'use-our-packages
+            ;; tinygltf ships json.hpp, stb_image.h and stb_image_write.h
+            ;; into the repo as common files.  Delete those, and use the
+            ;; files from our packages instead.
+            (lambda* (#:key inputs #:allow-other-keys)
+              (for-each delete-file
+                        (list "json.hpp"
+                              "stb_image.h"
+                              "stb_image_write.h"))
+              (symlink (search-input-file inputs "json.hpp")
+                       "json.hpp")
+              (symlink (search-input-file inputs "stb_image.h")
+                       "stb_image.h")
+              (symlink (search-input-file inputs "stb_image_write.h")
+                       "stb_image_write.h")))
+          (add-after 'install 'delete-static-lib
+            (lambda _
+              (delete-file (string-append #$output
+                                          "/lib/libtinygltf.a")))))))
+    (inputs (list nlohmann-json stb-image stb-image-write))
+    (home-page "https://github.com/syoyo/tinygltf")
+    (synopsis "Header only C++11 tiny glTF 2.0 library")
+    (description "TinyGLTF is a header only C++11 tiny
+@url{https://github.com/KhronosGroup/glTF, glTF} 2.0 library.")
+    (license license:expat)))
+
 (define-public monado
   (package
     (name "monado")