[bug#75619,v2,02/10] gnu: dolphin-emu: Unbundle more libraries and enable tests.

Message ID d6cdead2734e6a8f2fe275a2f306d8c11f02c4b0.1737190254.git.maxim.cournoyer@gmail.com
State New
Headers
Series [bug#75619,v2,01/10] gnu: Add soundtouch-1/integer-samples. |

Commit Message

Maxim Cournoyer Jan. 18, 2025, 8:50 a.m. UTC
  * gnu/packages/emulators.scm (dolphin-emu)
[source] <snippet>: Delete bzip2, cubeb, enet, fmt, pugixml, soundtouch,
xxhash and zstd sources and de-register enet, soundtouch and xxhash from the
build system.
[arguments] <#:tests?>: Delete argument.
<#:phases>: Add remove-unittests-target-post-build-command and post-check
phases.
<#:configure-flags>: Specify CMAKE_CXX_FLAGS to locate soundtouch headers.
<#:test-target>: New argument.
[inputs]: Add bzip2, cubeb, enet, fmt-7, minizip-ng, xxhash and
zstd:lib.  Replace soundtouch with soundtouch-1/integer-samples.

Change-Id: Id996d992674f9efbbb2eb562286447a388716a82
---
 gnu/packages/emulators.scm | 142 ++++++++++++++++++++++++++-----------
 1 file changed, 100 insertions(+), 42 deletions(-)
  

Patch

diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index 9e2d6485dd..6f77329f27 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -15,7 +15,7 @@ 
 ;;; Copyright © 2020 Christopher Howard <christopher@librehacker.com>
 ;;; Copyright © 2021 Felipe Balbi <balbi@kernel.org>
 ;;; Copyright © 2021, 2024 Felix Gruber <felgru@posteo.net>
-;;; Copyright © 2021, 2024 Maxim Cournoyer <maxim.cournoyer@gmail.com>
+;;; Copyright © 2021, 2024, 2025 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Guillaume Le Vaillant <glv@posteo.net>
 ;;; Copyright © 2023 c4droid <c4droid@foxmail.com>
 ;;; Copyright © 2023 Yovan Naumovski <yovan@gorski.stream>
@@ -94,6 +94,7 @@  (define-module (gnu packages emulators)
   #:use-module (gnu packages ncurses)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages pretty-print)
   #:use-module (gnu packages pulseaudio)
   #:use-module (gnu packages python)
   #:use-module (gnu packages python-build)
@@ -294,58 +295,112 @@  (define-public dolphin-emu
              ;; Remove external stuff we don't need.
              (for-each (lambda (dir)
                          (delete-file-recursively
-                           (string-append "Externals/" dir)))
-                       '("LZO" "OpenAL" "Qt" "SFML" "curl" "ffmpeg"
-                         "gettext" "hidapi" "libpng" "libusb" "mbedtls"
-                         "miniupnpc" "MoltenVK" "zlib"))
+                          (string-append "Externals/" dir)))
+                       '("LZO" "OpenAL" "Qt" "SFML" "bzip2"
+                         ;; XXX: Attempting to use the vulkan-headers package
+                         ;; results in "error:
+                         ;; ‘VK_PRESENT_MODE_RANGE_SIZE_KHR’ was not declared
+                         ;; in this scope".
+                         ;;"Vulkan"
+                         "cubeb" "curl" "enet"
+                         "ffmpeg" "fmt" "gettext"
+                         ;; XXX: Attempting to use an unbundled glslang at the
+                         ;; exact commit used by Dolphin still results in
+                         ;; "error: ‘DefaultTBuiltInResource’ is not a member
+                         ;; of ‘glslang’".
+                         ;;"glslang"
+                         ;; XXX: Googletest cannot currently easily be
+                         ;; unbundled, as there are missing linking
+                         ;; directives.
+                         ;;"gtest"
+                         "hidapi" "libpng" "libusb" "mbedtls"
+                         "miniupnpc" "minizip" "MoltenVK" "pugixml"
+                         "soundtouch"
+                         "xxhash" "zlib" "zstd"))
              ;; Clean up source.
              (for-each delete-file
-                       (find-files "." ".*\\.(bin|dsy|exe|jar|rar)$"))))))
+                       (find-files "." ".*\\.(bin|dsy|exe|jar|rar)$"))
+             ;; Do not attempt to include now-missing directories.
+             (substitute* "CMakeLists.txt"
+               ((".*add_subdirectory.*Externals/enet.*") "")
+               ((".*add_subdirectory.*Externals/soundtouch.*") "")
+               ((".*add_subdirectory.*Externals/xxhash.*") ""))))))
       (build-system cmake-build-system)
       (arguments
-       '(#:tests? #f
-         #:phases
-         (modify-phases %standard-phases
-           (add-before 'configure 'generate-fonts&hardcore-libvulkan-path
-             (lambda* (#:key inputs outputs #:allow-other-keys)
-               (let ((fontfile
-                      (search-input-file inputs
-                                         "/share/fonts/truetype/wqy-microhei.ttc"))
-                     (libvulkan
-                      (search-input-file inputs "/lib/libvulkan.so")))
-                 (chdir "docs")
-                 (invoke "bash" "-c" "g++ -O2 $(freetype-config \
+       (list
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-before 'configure 'remove-unittests-target-post-build-command
+              (lambda _
+                ;; To skip a few problematic tests, CTest will be manually
+                ;; invoked in the post-check phase.
+                (with-directory-excursion "Source/UnitTests"
+                  (substitute* "CMakeLists.txt"
+                    (("add_custom_command\\(TARGET unittests POST_BUILD.*")
+                     "")))))
+            (add-before 'configure 'generate-fonts&hardcore-libvulkan-path
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((fontfile
+                       (search-input-file inputs
+                                          "/share/fonts/truetype/wqy-microhei.ttc"))
+                      (libvulkan
+                       (search-input-file inputs "/lib/libvulkan.so")))
+                  (chdir "docs")
+                  (invoke "bash" "-c" "g++ -O2 $(freetype-config \
 --cflags --libs) gc-font-tool.cpp -o gc-font-tool")
-                 (invoke "./gc-font-tool" "a" fontfile "font_western.bin")
-                 (invoke "./gc-font-tool" "s" fontfile "font_japanese.bin")
-                 (copy-file "font_japanese.bin" "../Data/Sys/GC/font_japanese.bin")
-                 (copy-file "font_western.bin" "../Data/Sys/GC/font_western.bin")
-                 (chdir "..")
-                 (substitute* "Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp"
-                   (("\"vulkan\", 1") (string-append "\"vulkan\""))
-                   (("\"vulkan\"") (string-append "\"" libvulkan "\""))
-                   (("Common::DynamicLibrary::GetVersionedFilename") ""))))))
-
-         ;; The FindGTK2 cmake script only checks hardcoded directories for
-         ;; glib/gtk headers.
-
-         #:configure-flags
-         (list (string-append "-DX11_INCLUDE_DIR="
-                              (assoc-ref %build-inputs "libx11")
-                              "/include")
-               (string-append "-DX11_LIBRARIES="
-                              (assoc-ref %build-inputs "libx11")
-                              "/lib/libX11.so")
-               "-DX11_FOUND=1")))
+                  (invoke "./gc-font-tool" "a" fontfile "font_western.bin")
+                  (invoke "./gc-font-tool" "s" fontfile "font_japanese.bin")
+                  (copy-file "font_japanese.bin" "../Data/Sys/GC/font_japanese.bin")
+                  (copy-file "font_western.bin" "../Data/Sys/GC/font_western.bin")
+                  (chdir "..")
+                  (substitute* "Source/Core/VideoBackends/Vulkan/VulkanLoader.cpp"
+                    (("\"vulkan\", 1") (string-append "\"vulkan\""))
+                    (("\"vulkan\"") (string-append "\"" libvulkan "\""))
+                    (("Common::DynamicLibrary::GetVersionedFilename") "")))))
+            (add-after 'check 'post-check
+              (lambda* (#:key tests? #:allow-other-keys)
+                (when tests?
+                  (with-directory-excursion "Source/UnitTests"
+                    (invoke "ctest" "-V" "--output-on-failure"
+                            ;; These tests fail due to libusb failing to
+                            ;; init inside the build container.
+                            "-E" (string-join
+                                  '("MMIOTest"
+                                    "PageFaultTest"
+                                    "CoreTimingTest"
+                                    "FileSystemTest"
+                                    "PowerPCTest"
+                                    "VertexLoaderTest")
+                                  "|")))))))
+        ;; The FindGTK2 cmake script only checks hardcoded directories for
+        ;; glib/gtk headers.  Also add some include directories via the CXX
+        ;; flags to let GCC find some headers not actively searched by the
+        ;; build system.
+        #:configure-flags
+        #~(list (string-append "-DCMAKE_CXX_FLAGS="
+                               "-I" (search-input-directory
+                                     %build-inputs "include/soundtouch"))
+                (string-append "-DX11_INCLUDE_DIR="
+                               #$(this-package-input "libx11")
+                               "/include")
+                (string-append "-DX11_LIBRARIES="
+                               (search-input-file %build-inputs
+                                                  "lib/libX11.so"))
+                "-DX11_FOUND=1")
+        #:test-target "unittests"))
       (native-inputs
        (list gettext-minimal pkg-config))
       (inputs
        (list alsa-lib
              ao
              bluez
+             bzip2
+             cubeb
              curl
+             enet
              eudev
              ffmpeg-4
+             fmt-7
              font-wqy-microhei
              freetype
              glew
@@ -363,6 +418,7 @@  (define-public dolphin-emu
              mbedtls-lts
              mesa
              miniupnpc
+             minizip-ng
              openal
              pugixml
              pulseaudio
@@ -370,9 +426,11 @@  (define-public dolphin-emu
              sdl2
              sfml
              soil
-             soundtouch
+             soundtouch-1/integer-samples
              vulkan-loader
-             zlib))
+             xxhash
+             zlib
+             `(,zstd "lib")))
       (home-page "https://dolphin-emu.org/")
       (synopsis "Nintendo Wii and GameCube emulator")
       (description
@@ -380,7 +438,7 @@  (define-public dolphin-emu
 GameCube and the Wii.  It provides compatibility with all PC controllers,
 turbo speed, networked multiplayer, and graphical enhancements.")
       (supported-systems '("x86_64-linux" "aarch64-linux"))
-      ; dolphin/Data/Sys/GC/font_*.bin: Licensed under ASL2.0.
+      ;; dolphin/Data/Sys/GC/font_*.bin: Licensed under ASL2.0.
       (license (list license:gpl2+ license:asl2.0 license:fdl1.2+)))))
 
 (define-public dosbox