Subject: [bug#50054] [PATCH v2 2/3] gnu: Add bimg.

From: Andy Tai <[email-masked]>
Date: Mon, 22 Apr 2024 22:51:49 -0700

* gnu/packages/graphics.scm (bimg): New variable.

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

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index b64774af58..88e01b46bf 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -2951,6 +2951,72 @@ (define-public bx
 Bgfx graphics library.")
       (license license:bsd-2))))
 
+(define-public bimg
+  (let ((commit "e9fa0ceff2df3399011af136c82652c81655c1d3")
+        (revision "1"))
+    (package
+      (name "bimg")
+      (version (git-version "0.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/bkaradzic/bimg")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (modules '((guix build utils)))
+         (sha256
+          (base32 "0i80r5hwbnh94wfmv4dys6kmy7szvmpqynbb7bvvvhfjn13jh754"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:tests? #f ;there are no tests
+        #:phases #~(modify-phases %standard-phases
+                     (delete 'configure)
+
+                     (replace 'build
+                       (lambda _
+                         (for-each (lambda (target)
+                                     (invoke "make"
+                                             "-j"
+                                             (number->string (parallel-job-count))
+                                             target
+
+                                             (string-append "BX_DIR="
+                                                            #$(this-package-input
+                                                               "bx-sources"))
+                                             (string-append "NINJA="
+                                                            #$(this-package-native-input
+                                                               "ninja")
+                                                            "/bin/ninja")
+                                             (string-append "GENIE="
+                                                            #$(this-package-native-input
+                                                               "genie")
+                                                            "/bin/genie")))
+                                   (list "linux-release64" "tools"))))
+
+                     (replace 'install
+                       (lambda _
+                         (install-file
+                          ".build/linux64_gcc/obj/x64/Release/texturec/tools/texturec"
+                          (string-append #$output "/bin"))
+                         (for-each (lambda (f)
+                                     (install-file f
+                                                   (string-append #$output
+                                                                  "/lib")))
+                                   (find-files ".build/linux64_gcc" "\\.a$"))
+                         (copy-recursively "include/bimg"
+                                           (string-append #$output
+                                                          "/include/bimg")))))))
+      (native-inputs (list genie ninja))
+      (inputs `(("bx-sources" ,(package-source bx))))
+      (home-page "https://github.com/bkaradzic/bimg")
+      (synopsis "Image library")
+      (description
+       "Bimg is an imaging library that implements low level functions of the
+Bgfx graphics library.")
+      (license license:bsd-2))))
+
 (define-public gpaint
   (package
     (name "gpaint")
-- 
2.34.1