summary refs log tree commit diff
path: root/pkgs/applications/emulators/rpcs3
diff options
context:
space:
mode:
authorAndersonTorres <torres.anderson.85@protonmail.com>2022-02-15 23:28:16 -0300
committerAndersonTorres <torres.anderson.85@protonmail.com>2022-02-16 01:38:20 -0300
commit8d65e832f0a18f60e2040940c80d96373ac8b88c (patch)
tree3d6ade66b2a81403e3852b80b9e7c660699b6ed6 /pkgs/applications/emulators/rpcs3
parent19574af0af3ffaf7c9e359744ed32556f34536bd (diff)
downloadnixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.gz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.bz2
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.lz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.xz
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.tar.zst
nixpkgs-8d65e832f0a18f60e2040940c80d96373ac8b88c.zip
Move misc/emulators to applications/emulators - part 1
Emulators form a class by themselves. So, they should be moved to applications/.
Diffstat (limited to 'pkgs/applications/emulators/rpcs3')
-rw-r--r--pkgs/applications/emulators/rpcs3/0001-llvm-ExecutionEngine-IntelJITEvents-only-use-ITTAPI_.patch62
-rw-r--r--pkgs/applications/emulators/rpcs3/default.nix80
-rwxr-xr-xpkgs/applications/emulators/rpcs3/update.sh59
3 files changed, 201 insertions, 0 deletions
diff --git a/pkgs/applications/emulators/rpcs3/0001-llvm-ExecutionEngine-IntelJITEvents-only-use-ITTAPI_.patch b/pkgs/applications/emulators/rpcs3/0001-llvm-ExecutionEngine-IntelJITEvents-only-use-ITTAPI_.patch
new file mode 100644
index 00000000000..dccf06fc078
--- /dev/null
+++ b/pkgs/applications/emulators/rpcs3/0001-llvm-ExecutionEngine-IntelJITEvents-only-use-ITTAPI_.patch
@@ -0,0 +1,62 @@
+From 9866ce8f538e1ab1f0902408b7575013b768f365 Mon Sep 17 00:00:00 2001
+From: Zane van Iperen <zane@zanevaniperen.com>
+Date: Wed, 2 Feb 2022 23:41:59 +1000
+Subject: [PATCH] llvm/ExecutionEngine/IntelJITEvents: only use
+ ITTAPI_SOURCE_DIR
+
+---
+ .../IntelJITEvents/CMakeLists.txt             | 32 ++-----------------
+ 1 file changed, 2 insertions(+), 30 deletions(-)
+
+diff --git a/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt b/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
+index 0c5017c3..d20c35f3 100644
+--- a/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
++++ b/llvm/lib/ExecutionEngine/IntelJITEvents/CMakeLists.txt
+@@ -1,34 +1,6 @@
+ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+ 
+-if(NOT DEFINED ITTAPI_GIT_REPOSITORY)
+-    set(ITTAPI_GIT_REPOSITORY https://github.com/intel/ittapi.git)
+-endif()
+-
+-if(NOT DEFINED ITTAPI_GIT_TAG)
+-    set(ITTAPI_GIT_TAG v3.18.12)
+-endif()
+-
+-if(NOT DEFINED ITTAPI_SOURCE_DIR)
+-    set(ITTAPI_SOURCE_DIR ${PROJECT_BINARY_DIR})
+-endif()
+-
+-if(NOT EXISTS ${ITTAPI_SOURCE_DIR}/ittapi)
+-    execute_process(COMMAND ${GIT_EXECUTABLE} clone ${ITTAPI_GIT_REPOSITORY}
+-                    WORKING_DIRECTORY ${ITTAPI_SOURCE_DIR}
+-                    RESULT_VARIABLE GIT_CLONE_RESULT)
+-    if(NOT GIT_CLONE_RESULT EQUAL "0")
+-        message(FATAL_ERROR "git clone ${ITTAPI_GIT_REPOSITORY} failed with ${GIT_CLONE_RESULT}, please clone ${ITTAPI_GIT_REPOSITORY}")
+-    endif()
+-endif()
+-
+-execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${ITTAPI_GIT_TAG}
+-                WORKING_DIRECTORY ${ITTAPI_SOURCE_DIR}/ittapi
+-                RESULT_VARIABLE GIT_CHECKOUT_RESULT)
+-if(NOT GIT_CHECKOUT_RESULT EQUAL "0")
+-    message(FATAL_ERROR "git checkout ${ITTAPI_GIT_TAG} failed with ${GIT_CHECKOUT_RESULT}, please checkout ${ITTAPI_GIT_TAG} at ${ITTAPI_SOURCE_DIR}/ittapi")
+-endif()
+-
+-include_directories( ${ITTAPI_SOURCE_DIR}/ittapi/include/ )
++include_directories( ${ITTAPI_SOURCE_DIR}/include/ )
+ 
+ if( HAVE_LIBDL )
+     set(LLVM_INTEL_JIT_LIBS ${CMAKE_DL_LIBS})
+@@ -40,7 +12,7 @@ set(LLVM_INTEL_JIT_LIBS ${LLVM_PTHREAD_LIB} ${LLVM_INTEL_JIT_LIBS})
+ add_llvm_component_library(LLVMIntelJITEvents
+   IntelJITEventListener.cpp
+   jitprofiling.c
+-  ${ITTAPI_SOURCE_DIR}/ittapi/src/ittnotify/ittnotify_static.c
++  ${ITTAPI_SOURCE_DIR}/src/ittnotify/ittnotify_static.c
+ 
+   LINK_LIBS ${LLVM_INTEL_JIT_LIBS}
+ 
+-- 
+2.34.1
+
diff --git a/pkgs/applications/emulators/rpcs3/default.nix b/pkgs/applications/emulators/rpcs3/default.nix
new file mode 100644
index 00000000000..0ea56d3a72d
--- /dev/null
+++ b/pkgs/applications/emulators/rpcs3/default.nix
@@ -0,0 +1,80 @@
+{ gcc11Stdenv, lib, fetchFromGitHub, wrapQtAppsHook, cmake, pkg-config, git
+, qtbase, qtquickcontrols, qtmultimedia, openal, glew, vulkan-headers, vulkan-loader, libpng
+, ffmpeg, libevdev, libusb1, zlib, curl, wolfssl, python3, pugixml, faudio, flatbuffers
+, sdl2Support ? true, SDL2
+, pulseaudioSupport ? true, libpulseaudio
+, waylandSupport ? true, wayland
+, alsaSupport ? true, alsa-lib
+}:
+
+let
+  # Keep these separate so the update script can regex them
+  rpcs3GitVersion = "13222-8c2fd5095";
+  rpcs3Version = "0.0.20-13222-8c2fd5095";
+  rpcs3Revision = "8c2fd50957be3af05c04a9bb782dce8505fb6400";
+  rpcs3Sha256 = "1cf62vpqdc9i4masgv9zz24h7zdc7gcymx6n1hbh7wp5gg1dw4qi";
+
+  ittapi = fetchFromGitHub {
+    owner = "intel";
+    repo = "ittapi";
+    rev = "v3.18.12";
+    sha256 = "0c3g30rj1y8fbd2q4kwlpg1jdy02z4w5ryhj3yr9051pdnf4kndz";
+  };
+in
+gcc11Stdenv.mkDerivation {
+  pname = "rpcs3";
+  version = rpcs3Version;
+
+  src = fetchFromGitHub {
+    owner = "RPCS3";
+    repo = "rpcs3";
+    rev = rpcs3Revision;
+    fetchSubmodules = true;
+    sha256 = rpcs3Sha256;
+  };
+
+  patches = [ ./0001-llvm-ExecutionEngine-IntelJITEvents-only-use-ITTAPI_.patch ];
+
+  passthru.updateScript = ./update.sh;
+
+  preConfigure = ''
+    cat > ./rpcs3/git-version.h <<EOF
+    #define RPCS3_GIT_VERSION "${rpcs3GitVersion}"
+    #define RPCS3_GIT_FULL_BRANCH "RPCS3/rpcs3/master"
+    #define RPCS3_GIT_BRANCH "HEAD"
+    #define RPCS3_GIT_VERSION_NO_UPDATE 1
+    EOF
+  '';
+
+  cmakeFlags = [
+    "-DUSE_SYSTEM_ZLIB=ON"
+    "-DUSE_SYSTEM_LIBUSB=ON"
+    "-DUSE_SYSTEM_LIBPNG=ON"
+    "-DUSE_SYSTEM_FFMPEG=ON"
+    "-DUSE_SYSTEM_CURL=ON"
+    "-DUSE_SYSTEM_WOLFSSL=ON"
+    "-DUSE_SYSTEM_FAUDIO=ON"
+    "-DUSE_SYSTEM_PUGIXML=ON"
+    "-DUSE_SYSTEM_FLATBUFFERS=ON"
+    "-DUSE_NATIVE_INSTRUCTIONS=OFF"
+    "-DITTAPI_SOURCE_DIR=${ittapi}"
+  ];
+
+  nativeBuildInputs = [ cmake pkg-config git wrapQtAppsHook ];
+
+  buildInputs = [
+    qtbase qtquickcontrols qtmultimedia openal glew vulkan-headers vulkan-loader libpng ffmpeg
+    libevdev zlib libusb1 curl wolfssl python3 pugixml faudio flatbuffers
+  ] ++ lib.optional sdl2Support SDL2
+    ++ lib.optional pulseaudioSupport libpulseaudio
+    ++ lib.optional alsaSupport alsa-lib
+    ++ lib.optional waylandSupport wayland;
+
+  meta = with lib; {
+    description = "PS3 emulator/debugger";
+    homepage = "https://rpcs3.net/";
+    maintainers = with maintainers; [ abbradar neonfuz ilian zane ];
+    license = licenses.gpl2Only;
+    platforms = [ "x86_64-linux" ];
+  };
+}
diff --git a/pkgs/applications/emulators/rpcs3/update.sh b/pkgs/applications/emulators/rpcs3/update.sh
new file mode 100755
index 00000000000..0c8477c5282
--- /dev/null
+++ b/pkgs/applications/emulators/rpcs3/update.sh
@@ -0,0 +1,59 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash --pure --keep GITHUB_TOKEN -p gnused jq nix-prefetch-git curl cacert
+
+set -eou pipefail
+
+ROOT="$(dirname "$(readlink -f "$0")")"
+if [[ ! "$(basename $ROOT)" == "rpcs3" || ! -f "$ROOT/default.nix" ]]; then
+    echo "ERROR: Not in the rpcs3 folder"
+    exit 1
+fi
+
+if [[ ! -v GITHUB_TOKEN ]]; then
+    echo "ERROR: \$GITHUB_TOKEN not set"
+    exit 1
+fi
+
+payload=$(jq -cn --rawfile query /dev/stdin '{"query": $query}' <<EOF | curl -s -H "Authorization: bearer $GITHUB_TOKEN" -d '@-' https://api.github.com/graphql
+{
+  repository(owner: "RPCS3", name: "rpcs3") {
+    branch: ref(qualifiedName: "refs/heads/master") {
+      target {
+        oid
+        ... on Commit {
+          history {
+            totalCount
+          }
+        }
+      }
+    }
+
+    tag: refs(refPrefix: "refs/tags/", first: 1, orderBy: {field: TAG_COMMIT_DATE, direction: DESC}) {
+      nodes {
+        name
+      }
+    }
+  }
+}
+EOF
+)
+
+commit_sha=$(jq -r .data.repository.branch.target.oid <<< "$payload")
+major_ver=$(jq -r .data.repository.tag.nodes[0].name <<< "$payload" | sed 's/^v//g')
+commit_count=$(jq -r .data.repository.branch.target.history.totalCount <<< "$payload")
+git_ver="$commit_count-${commit_sha::9}"
+final_ver="$major_ver-$git_ver"
+
+
+echo "INFO: Latest commit is $commit_sha"
+echo "INFO: Latest version is $final_ver"
+
+nix_sha256=$(nix-prefetch-git --quiet --fetch-submodules https://github.com/RPCS3/rpcs3.git "$commit_sha" | jq -r .sha256)
+echo "INFO: SHA256 is $nix_sha256"
+
+sed -i -E \
+    -e "s/rpcs3GitVersion\s*=\s*\"[\.a-z0-9-]+\";$/rpcs3GitVersion = \"${git_ver}\";/g" \
+    -e "s/rpcs3Version\s*=\s*\"[\.a-z0-9-]+\";$/rpcs3Version = \"${final_ver}\";/g" \
+    -e "s/rpcs3Revision\s*=\s*\"[a-z0-9]+\";$/rpcs3Revision = \"${commit_sha}\";/g" \
+    -e "s/rpcs3Sha256\s*=\s*\"[a-z0-9]+\";$/rpcs3Sha256 = \"${nix_sha256}\";/g" \
+    "$ROOT/default.nix"