Subject: [bug#66035] [PATCH] gnu: Add renderdoc.

From: dan <[email-masked]>
Date: Sun, 17 Sep 2023 00:01:08 +0800

* gnu/packages/graphics.scm (renderdoc): New variable.
---
 gnu/packages/graphics.scm | 90 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 89 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 9362666274..002d93f75b 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -32,7 +32,7 @@
 ;;; Copyright © 2022 Zheng Junjie <[email-masked]>
 ;;; Copyright © 2022 Tobias Kortkamp <[email-masked]>
 ;;; Copyright © 2022 Paul A. Patience <[email-masked]>
-;;; Copyright © 2022 dan <[email-masked]>
+;;; Copyright © 2022, 2023 dan <[email-masked]>
 ;;; Copyright © 2023 Sharlatan Hellseher <[email-masked]>
 ;;; Copyright © 2023 David Thompson <[email-masked]>
 ;;; Copyright © 2023 Eric Bavier <[email-masked]>
@@ -101,6 +101,7 @@ (define-module (gnu packages graphics)
   #:use-module (gnu packages multiprecision)
   #:use-module (gnu packages ninja)
   #:use-module (gnu packages pciutils)
+  #:use-module (gnu packages pcre)
   #:use-module (gnu packages pdf)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages photo)
@@ -2851,3 +2852,90 @@ (define-public gpaint
 It features cut-and-paste for irregular regions or polygons.")
     (home-page "https://www.gnu.org/software/gpaint/")
     (license license:gpl3+)))
+
+(define %swig-for-renderdoc-version
+  "renderdoc-modified-7")
+
+(define swig-for-renderdoc
+  (origin
+    (method url-fetch)
+    (uri (string-append "https://github.com/baldurk/swig/archive/refs/tags/"
+                        %swig-for-renderdoc-version ".tar.gz"))
+    (sha256 (base32
+             "19sb4vik8kgy9pxjfam8qc8i52iraj2971p1hrzh850fvl0nibg7"))))
+
+(define-public renderdoc
+  (package
+    (name "renderdoc")
+    (version "1.28")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "https://github.com/baldurk/renderdoc.git")
+                    (commit (string-append "v" version))))
+              (sha256
+               (base32
+                "1rny39s1b48bgv8x2871ylkzk1f9llvrskb809c6gcawnfazzivb"))))
+    (build-system cmake-build-system)
+    (arguments
+     (list #:tests? #f
+           #:configure-flags #~(list (string-append "-DVULKAN_LAYER_FOLDER="
+                                      #$output
+                                      "/share/vulkan/implicit_layer.d"))
+           #:phases #~(modify-phases %standard-phases
+                        (add-after 'unpack 'unpack-additional-sources
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            (let ((sh (search-input-file inputs "/bin/sh")))
+                              (invoke "tar" "xvf"
+                                      #$swig-for-renderdoc)
+                              (rename-file (string-append "swig-"
+                                            #$%swig-for-renderdoc-version)
+                                           "swig")
+                              (substitute* "qrenderdoc/CMakeLists.txt"
+                                (("URL \\$\\{RENDERDOC_SWIG_PACKAGE\\}")
+                                 "SOURCE_DIR ${CMAKE_SOURCE_DIR}/swig")
+                                (("CONFIGURE_COMMAND\\s.*")
+                                 "CONFIGURE_COMMAND \"\"\n")
+                                (("^\\s+COMMAND CC.*")
+                                 ""))
+                              (substitute* "swig/Makefile.in"
+                                (("/bin/sh")
+                                 sh))
+                              (chdir "swig")
+                              (invoke sh "autogen.sh")
+                              (chdir ".."))))
+                        (add-after 'configure 'configure-swig
+                          (lambda* (#:key inputs #:allow-other-keys)
+                            (let ((build-dir (getcwd))
+                                  (sh (search-input-file inputs "/bin/sh")))
+                              (chdir "../source/swig")
+                              (apply invoke sh "./configure"
+                                     (list "CC=gcc"
+                                           "CXX=g++"
+                                           "CFLAGS=-fPIC"
+                                           "CXXFLAGS=-fPIC"
+                                           (string-append "SHELL=" sh)
+                                           "--with-pcre=yes"
+                                           (string-append "--prefix="
+                                                          build-dir)))
+                              (chdir "../../build")))))))
+    (inputs (list libx11
+                  libxcb
+                  xcb-util-keysyms
+                  mesa
+                  qtbase-5
+                  qtsvg-5
+                  qtx11extras))
+    (native-inputs (list autoconf
+                         automake
+                         bison
+                         (list pcre "bin")
+                         pkg-config
+                         python))
+    (home-page "https://renderdoc.org")
+    (synopsis "Graphics debugging tool")
+    (description
+     "RenderDoc is a frame-capture based graphics debugger, currently
+available for Vulkan, D3D11, D3D12, OpenGL, and OpenGL ES development on
+Windows, Linux, Android, and Nintendo Switch™.")
+    (license license:expat)))

base-commit: 04fad62acdcffa50c18528ce71f015907b9eb558
-- 
2.41.0