Subject: [PATCH] [PATCH] WIP: gnu: Add rpcs3.
From: Pierre Neidhardt <[email-masked]>
To: [email-masked]
Date: Mon, 17 Feb 2020 15:58:29 +0100
List-Id: <debbugs-submit.debbugs.gnu.org>

* gnu/packages/emulators.scm (rpcs3): New variable.

Package does not work at the moment.
cmake fails with:

--8<---------------cut here---------------start------------->8---
CMake Error at 3rdparty/CMakeLists.txt:417 (add_library):
  add_library cannot create ALIAS target "3rdparty::libusb" because target
  "usb-1.0-static" does not already exist.

CMake Error at 3rdparty/CMakeLists.txt:420 (add_library):
  add_library cannot create ALIAS target "3rdparty::pugixml" because target
  "pugixml" does not already exist.

CMake Error at 3rdparty/CMakeLists.txt:421 (add_library):
  add_library cannot create ALIAS target "3rdparty::yaml-cpp" because target
  "yaml-cpp" does not already exist.

CMake Error at 3rdparty/CMakeLists.txt:422 (add_library):
  add_library cannot create ALIAS target "3rdparty::xxhash" because target
  "xxhash" does not already exist.

CMake Error at 3rdparty/CMakeLists.txt:432 (add_library):
  add_library cannot create ALIAS target "3rdparty::faudio" because target
  "FAudio" does not already exist.

-- cotire 1.8.0 loaded.
-- Found Git: /gnu/store/khvcbw37r31xmfdalplw10xz9d4j6v8l-git-2.25.0/bin/git (found version "2.25.0")
CMake Warning at rpcs3/git-version.cmake:33 (message):
  git not found, unable to include version.
Call Stack (most recent call first):
  rpcs3/CMakeLists.txt:6 (include)

-- Performing Test HAS_NO_PIE
-- Performing Test HAS_NO_PIE - Success
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE
-- Performing Test COMPILER_SUPPORTS_MARCH_NATIVE - Success
-- Found X11: /gnu/store/b824dq3bccq0bhjli3li0fzi11lg1bh3-xorgproto-2019.1/include
-- Looking for XOpenDisplay in /gnu/store/06ybqkh3lb3g7c77b74izy32grglf45x-libx11-1.6.8/lib/libX11.so;/gnu/store/j01p4wjas358cvayyjqpl449hmpanra8-libxext-1.3.4/lib/libXext.so
-- Looking for XOpenDisplay in /gnu/store/06ybqkh3lb3g7c77b74izy32grglf45x-libx11-1.6.8/lib/libX11.so;/gnu/store/j01p4wjas358cvayyjqpl449hmpanra8-libxext-1.3.4/lib/libXext.so - found
-- Looking for gethostbyname
-- Looking for gethostbyname - found
-- Looking for connect
-- Looking for connect - found
-- Looking for remove
-- Looking for remove - found
-- Looking for shmat
-- Looking for shmat - found
-- Initializing RPCS3_SRC_DIR=/tmp/guix-build-rpcs3-0.0.8.drv-0/source/rpcs3
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- CXX target rpcs3_emu cotired without unity build excluding ../../Utilities/JIT.cpp, Cell/PPUTranslator.cpp.
-- RPCS3_GIT_VERSION: unknown
-- RPCS3_GIT_BRANCH: unknown
-- CXX target rpcs3 cotired without unity build.
-- Configuring incomplete, errors occurred!
See also "/tmp/guix-build-rpcs3-0.0.8.drv-0/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/guix-build-rpcs3-0.0.8.drv-0/build/CMakeFiles/CMakeError.log".
command "cmake" "../source" "-DCMAKE_BUILD_TYPE=RelWithDebInfo" "-DCMAKE_INSTALL_PREFIX=/gnu/store/0p9v13dy10abknx6j48yn9dwwx614x56-rpcs3-0.0.8" "-DCMAKE_INSTALL_LIBDIR=lib" "-DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" "-DCMAKE_INSTALL_RPATH=/gnu/store/0p9v13dy10abknx6j48yn9dwwx614x56-rpcs3-0.0.8/lib" "-DCMAKE_VERBOSE_MAKEFILE=ON" "-DUSE_SYSTEM_LIBPNG=ON" "-DUSE_SYSTEM_FFMPEG=ON" "-DBUILD_LLVM_SUBMODULE=OFF" "-DWITH_LLVM=OFF" "-DUSE_NATIVE_INSTRUCTIONS=OFF" failed with status 1
--8<---------------cut here---------------end--------------->8---
---
 gnu/packages/emulators.scm | 85 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 84 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm
index b9c854ca25..650c80e4dc 100644
--- a/gnu/packages/emulators.scm
+++ b/gnu/packages/emulators.scm
@@ -9,7 +9,7 @@
 ;;; Copyright © 2017, 2018, 2019, 2020 Nicolas Goaziou <[email-masked]>
 ;;; Copyright © 2017, 2020 Tobias Geerinckx-Rice <[email-masked]>
 ;;; Copyright © 2017, 2018, 2019 Rutger Helling <[email-masked]>
-;;; Copyright © 2019 Pierre Neidhardt <[email-masked]>
+;;; Copyright © 2019, 2020 Pierre Neidhardt <[email-masked]>
 ;;; Copyright © 2019 David Wilson <[email-masked]>
 ;;; Copyright © 2020 Jakub Kądziołka <[email-masked]>
 ;;;
@@ -46,6 +46,7 @@
   #:use-module (gnu packages cdrom)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages curl)
+  #:use-module (gnu packages digest)
   #:use-module (gnu packages elf)
   #:use-module (gnu packages fonts)
   #:use-module (gnu packages fontutils)
@@ -61,6 +62,7 @@
   #:use-module (gnu packages libedit)
   #:use-module (gnu packages libusb)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages maths)
   #:use-module (gnu packages mp3)
@@ -72,12 +74,14 @@
   #:use-module (gnu packages python)
   #:use-module (gnu packages qt)
   #:use-module (gnu packages sdl)
+  #:use-module (gnu packages serialization)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages textutils)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages upnp)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages video)
   #:use-module (gnu packages vulkan)
   #:use-module (gnu packages wxwidgets)
@@ -1563,3 +1567,82 @@ derived from Gens.  Project goals include clean source code, combined features
 from various forks of Gens, and improved platform portability.")
     (supported-systems '("i686-linux" "x86_64-linux"))
     (license license:gpl2+)))
+
+(define-public rpcs3
+  ;; git-version is `$(git rev-list HEAD --count)-$(git rev-parse --short HEAD)`.
+  (let ((git-version "9605-7a7ac625c"))
+    (package
+      (name "rpcs3")
+      (version "0.0.8")
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/RPCS3/rpcs3")
+               (commit (string-append "v" version))))
+         (sha256
+          (base32
+           "1219lzr18f7jfgval5scmw7xllgqs43sxg659f37rx8vy9f9r3s8"))))
+      (build-system cmake-build-system)
+      (arguments
+       `(;; #:parallel-build? #f
+         #:configure-flags '("-DUSE_SYSTEM_LIBPNG=ON"
+                             "-DUSE_SYSTEM_FFMPEG=ON"
+                             ;; "-DXXHASH_BUNDLED_MODE=OFF"
+                             ;; "-DYAML_CPP_BUILD_TOOLS=OFF"
+                             ;; "-DYAML_CPP_BUILD_CONTRIB=OFF"
+                             ;; "-DSKIP_GLSLANG_INSTALL=ON"
+                             "-DBUILD_LLVM_SUBMODULE=OFF"
+                             "-DWITH_LLVM=OFF"
+                             "-DUSE_NATIVE_INSTRUCTIONS=OFF")
+         #:phases
+         (modify-phases %standard-phases
+           (add-before 'configure 'fix-git-version
+             (lambda* _
+               ;; Version must be set manually since the build system would use
+               ;; .git otherwise.
+               (with-output-to-file  "rpcs3/git-version.h"
+                 (lambda ()
+                   (display
+                    (string-append
+                     "#define RPCS3_GIT_VERSION \"" ,git-version "\"\n"
+                     "#define RPCS3_GIT_BRANCH \"HEAD\"\n"
+                     "#define RPCS3_GIT_VERSION_NO_UPDATE 1\n"))))
+               #t)))))
+      (native-inputs
+       `(("gcc" ,gcc-9)
+         ;; ("llvm" ,llvm)
+         ("pkg-config" ,pkg-config)
+         ;; ("git" ,git)
+         ))
+      (inputs
+       `(("mesa" ,mesa)
+         ("glslang" ,glslang)
+         ("glew" ,glew)
+         ("openal" ,openal)
+         ("sdl2" ,sdl2)
+         ("vulkan-headers" ,vulkan-headers)
+         ("vulkan-loader" ,vulkan-loader)
+         ("libpng" ,libpng)
+         ("ffmpeg" ,ffmpeg)
+         ("faudio" ,faudio)
+         ("libevdev" ,libevdev)
+         ("xxhash" ,xxhash)
+         ("yaml-cpp" ,yaml-cpp)
+         ("libusb" ,libusb)
+         ("hidapi" ,hidapi)
+         ("pugixml" ,pugixml)
+         ("python" ,python)
+         ("alsa-lib" ,alsa-lib)
+         ("wayland" ,wayland)
+         ("pulseaudio" ,pulseaudio)
+         ("qtbase" ,qtbase)
+         ("qtquickcontrols" ,qtquickcontrols)
+         ("qtdeclarative" ,qtdeclarative)))
+      (home-page "https://rpcs3.net/")
+      (synopsis "PlayStation 3 emulator and debugger")
+      (description
+       "RPCS3 is a multi-platform Sony PlayStation 3 emulator and debugger
+written in C++.")
+      (supported-systems '("x86_64-linux"))
+      (license license:gpl2+))))
-- 
2.25.0