From 8924691c12498f334be46c81392b16da9c554aa0 Mon Sep 17 00:00:00 2001
From: out <outline941@live.com>
Date: Fri, 1 Jan 2021 14:23:56 +0800
Subject: [PATCH] Add ppsspp-ffmpeg to module, rebuild for each arch

---
 org.ppsspp.PPSSPP.json | 46 ++++++++++++++++++++++++++++++++++++------
 rebuild_ffmpeg.sh      |  8 --------
 2 files changed, 40 insertions(+), 14 deletions(-)
 delete mode 100755 rebuild_ffmpeg.sh

diff --git a/org.ppsspp.PPSSPP.json b/org.ppsspp.PPSSPP.json
index 61c5751..57c98d1 100644
--- a/org.ppsspp.PPSSPP.json
+++ b/org.ppsspp.PPSSPP.json
@@ -15,6 +15,9 @@
     "--socket=x11",
     "--share=network"
   ],
+  "cleanup": [
+    "/ffmpeg"
+  ],
   "modules": [
     "shared-modules/glu/glu-9.json",
     "shared-modules/glew/glew.json",
@@ -36,13 +39,45 @@
         }
       ]
     },
+    {
+      "name": "ppsspp-ffmpeg",
+      "buildsystem": "simple",
+      "build-commands": [
+        "rm -r ./linux",
+        "./build.sh",
+        "mkdir -p /app/ffmpeg && cp -r ./linux /app/ffmpeg/"
+      ],
+      "sources": [
+        {
+          "type": "git",
+          "url": "https://github.com/hrydgard/ppsspp-ffmpeg.git",
+          "commit": "55147e5f33f5ae4904f75ec082af809267122b94"
+        },
+        {
+          "type": "script",
+          "dest-filename": "build.sh",
+          "only-arches": ["aarch64"],
+          "commands":[
+            "sed -i 's/GENERAL=/GENERAL_NO=/' linux_arm64.sh",
+            "./linux_arm64.sh"
+          ]
+        },
+        {
+          "type": "script",
+          "dest-filename": "build.sh",
+          "only-arches": ["x86_64"],
+          "commands":["./linux_x86-64.sh"]
+        }
+      ]
+    },
     {
       "name": "ppsspp",
       "buildsystem": "cmake-ninja",
       "no-make-install": true,
       "config-opts": [
         "-DCMAKE_BUILD_TYPE=RelWithDebInfo",
-        "-DOpenGL_GL_PREFERENCE=GLVND"
+        "-DOpenGL_GL_PREFERENCE=GLVND",
+	"-DUSING_GLES2=ON"
       ],
       "build-commands": [
         "mkdir -p /app/ppsspp /app/bin /app/share/applications",
@@ -59,13 +94,12 @@
           "url": "https://github.com/hrydgard/ppsspp.git",
           "commit": "087de849bdc74205dd00d8e6e11ba17a591213ab"
         },
-        {
-          "type": "file",
-          "path": "rebuild_ffmpeg.sh"
-        },
         {
           "type": "shell",
-          "commands": ["./rebuild_ffmpeg.sh"]
+          "commands": [
+            "rm -r ffmpeg/linux",
+            "ln -s /app/ffmpeg/linux ffmpeg/linux"
+          ]
         },
         {
           "type": "file",
diff --git a/rebuild_ffmpeg.sh b/rebuild_ffmpeg.sh
deleted file mode 100755
index 15ad105..0000000
--- a/rebuild_ffmpeg.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-if [ "$FLATPAK_ARCH" == "aarch64" ];then
-	cd ffmpeg
-	# GENERAL is used to set cross compile option, rename it to disable it.
-	sed "s/GENERAL=/GENERAL_NO=/;" linux_arm64.sh > linux_arm64_no_cross.sh
-	chmod +x linux_arm64_no_cross.sh
-	./linux_arm64_no_cross.sh
-fi