Subject: [bug#59238] [PATCH 4/4] gnu: Add qt-creator.

From: Maxim Cournoyer <[email-masked]>
Date: Sun, 13 Nov 2022 00:37:09 -0500

* gnu/packages/qt.scm (qt-creator): New variable.
---
 gnu/packages/qt.scm | 97 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 7ae02e2a63..2adbc12ea7 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -59,17 +59,21 @@ (define-module (gnu packages qt)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bison)
+  #:use-module (gnu packages check)
   #:use-module (gnu packages cmake)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages cups)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages databases)
   #:use-module (gnu packages documentation)
+  #:use-module (gnu packages elf)
   #:use-module (gnu packages enchant)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages flex)
   #:use-module (gnu packages freedesktop)
   #:use-module (gnu packages gcc)
+  #:use-module (gnu packages gdb)
   #:use-module (gnu packages ghostscript)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
@@ -4361,6 +4365,99 @@ (define-public clazy
 including @i{fix-its} for automatic refactoring.")
     (license license:lgpl2.0+)))
 
+(define-public qt-creator
+  (package
+    (name "qt-creator")
+    (version "8.0.2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://download.qt.io/official_releases/qtcreator/"
+                    (version-major+minor version) "/" version
+                    "/qt-creator-opensource-src-" version ".tar.gz"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (for-each
+                           delete-file-recursively
+                           ;; Remove bundled libraries, where supported.
+                           ;; TODO: package and unbundle litehtml
+                           '("src/libs/3rdparty/yaml-cpp"
+                             "src/shared/qbs/src/shared/qtscript/src/3rdparty"
+                             "tests/unit/unittest/3rdparty"
+                             ;; Marketplace recommends nonfree extensions;
+                             ;; remove it.
+                             "src/plugins/marketplace"))
+                          (substitute* "src/plugins/CMakeLists.txt"
+                            (("add_subdirectory\\(marketplace).*") ""))
+                          (substitute* "src/plugins/plugins.qbs"
+                            ((".*marketplace/marketplace.qbs.*") ""))))
+              (sha256
+               (base32
+                "04q1xbff3k5dfk5bdll4fih0sx7sz0hclpnhwn181r7yysfppbba"))))
+    (build-system qt-build-system)
+    (arguments
+     (list
+      #:qtbase qtbase
+      ;; The test suite fails to build (see:
+      ;; https://bugreports.qt.io/browse/QTCREATORBUG-28434).
+      #:tests? #f
+      #:configure-flags
+      #~(list "-DWITH_DOCS=ON"
+              "-DBUILD_DEVELOPER_DOCS=ON"
+              ;; Extend the RUNPATH with lib/qtcreator, which contains
+              ;; multiple shared objects.
+              (string-append "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,-rpath="
+                             #$output "/lib/qtcreator"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'build 'build-doc
+            (lambda _
+              (invoke "cmake" "--build" "." "--target=docs" "-v")))
+          (add-after 'build-doc 'install-doc
+            (lambda _
+              (invoke "cmake" "--install" "." "--prefix" #$output
+                      "--component=qch_docs")
+              (invoke "cmake" "--install" "." "--prefix" #$output
+                      "--component=html_docs")))
+          (add-after 'qt-wrap 'wrap-bin
+            ;; Make a few well-integrated tools readily available.
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (wrap-program (search-input-file outputs "bin/qtcreator")
+                `("PATH" suffix ,(map (lambda (c)
+                                        (dirname (search-input-file inputs c)))
+                                      '("bin/clang-tidy"
+                                        "bin/clazy-standalone"
+                                        "bin/gdb"
+                                        "bin/valgrind")))))))))
+    (native-inputs
+     (list pkg-config
+           python
+           qttools
+           qttranslations
+           vulkan-headers
+           xvfb-run))
+    (inputs
+     (list clang
+           clazy
+           elfutils
+           gdb
+           libxkbcommon
+           llvm
+           qt5compat
+           qtdeclarative
+           qtshadertools
+           qtsvg
+           yaml-cpp
+           valgrind
+           vulkan-loader
+           `(,zstd "lib")))
+    (home-page "https://www.qt.io/")
+    (synopsis "Integrated development environment (IDE) for Qt")
+    (description "Qt Creator is an IDE tailored to the needs of Qt developers.
+It includes features such as an advanced code editor, a visual debugger and a
+@acronym{GUI, Graphical User Interface} designer.")
+    (license license:gpl3+)))           ;with the Qt Company GPL Exception 1.0
+
 ;;;
 ;;; Avoid adding new packages to the end of this file. To reduce the chances
 ;;; of a merge conflict, place them above by existing packages with similar
-- 
2.38.1