From f35397cf8d907e4c14b31458806a8beb08c926d4 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 4 Jul 2024 14:02:31 +1000 Subject: [PATCH] Deps: Build discord-rpc --- scripts/build-dependencies-linux.sh | 14 +++++++++- scripts/build-dependencies-mac.sh | 19 +++++++++++-- scripts/build-dependencies-windows-arm64.bat | 11 ++++++++ scripts/build-dependencies-windows-x64.bat | 11 ++++++++ scripts/flatpak/modules/25-discord-rpc.json | 28 +++++++++++++++++++ .../flatpak/org.duckstation.DuckStation.json | 1 + 6 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 scripts/flatpak/modules/25-discord-rpc.json diff --git a/scripts/build-dependencies-linux.sh b/scripts/build-dependencies-linux.sh index 08a1d9852..68f073c88 100755 --- a/scripts/build-dependencies-linux.sh +++ b/scripts/build-dependencies-linux.sh @@ -28,6 +28,7 @@ SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4 SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7 SPIRV_CROSS=vulkan-sdk-1.3.283.0 CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9 +DISCORD_RPC=842c15192041f8e71c512851834f4dadb1a554fb mkdir -p deps-build cd deps-build @@ -51,6 +52,7 @@ aa27e4454ce631c5a17924ce0624eac736da19fc6f5a2ab15a6c58da7b36950f shaderc-glslan 03ee1a2c06f3b61008478f4abe9423454e53e580b9488b47c8071547c6a9db47 shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz 3376a58abe186a695a50ff12697d210ce27673cea5de1a5090cb2b092b261414 SPIRV-Cross-$SPIRV_CROSS.tar.gz 74a8d9ae0b8b45b39d35708c873320de227bbfe01a46e4d2a91818b8877f4137 cpuinfo-$CPUINFO.tar.gz +acb111ebdb4f1459899b9c594be81ed284de23ac0f5376e5963aad16df98584f discord-rpc-$DISCORD_RPC.tar.gz EOF curl -C - -L \ @@ -71,7 +73,8 @@ curl -C - -L \ -o "shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Headers/archive/$SHADERC_SPIRVHEADERS.tar.gz" \ -o "shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Tools/archive/$SHADERC_SPIRVTOOLS.tar.gz" \ -o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz" \ - -o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz" + -o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz" \ + -o "discord-rpc-$DISCORD_RPC.tar.gz" "https://github.com/stenzek/discord-rpc/archive/$DISCORD_RPC.tar.gz" shasum -a 256 --check SHASUMS @@ -266,6 +269,15 @@ cmake --build build --parallel ninja -C build install cd .. +echo "Building discord-rpc" +rm -fr "discord-rpc-$DISCORD_RPC" +tar xf "discord-rpc-$DISCORD_RPC.tar.gz" +cd "discord-rpc-$DISCORD_RPC" +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$INSTALLDIR" -DCMAKE_INSTALL_PREFIX="$INSTALLDIR" -DBUILD_SHARED_LIBS=ON -B build -G Ninja +cmake --build build --parallel +ninja -C build install +cd .. + echo "Cleaning up..." cd .. rm -r deps-build diff --git a/scripts/build-dependencies-mac.sh b/scripts/build-dependencies-mac.sh index c7d0f34f2..1ab62b248 100755 --- a/scripts/build-dependencies-mac.sh +++ b/scripts/build-dependencies-mac.sh @@ -50,6 +50,7 @@ SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4 SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7 SPIRV_CROSS=vulkan-sdk-1.3.283.0 CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9 +DISCORD_RPC=842c15192041f8e71c512851834f4dadb1a554fb mkdir -p deps-build cd deps-build @@ -89,6 +90,8 @@ aa27e4454ce631c5a17924ce0624eac736da19fc6f5a2ab15a6c58da7b36950f shaderc-glslan 03ee1a2c06f3b61008478f4abe9423454e53e580b9488b47c8071547c6a9db47 shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz 3376a58abe186a695a50ff12697d210ce27673cea5de1a5090cb2b092b261414 SPIRV-Cross-$SPIRV_CROSS.tar.gz 74a8d9ae0b8b45b39d35708c873320de227bbfe01a46e4d2a91818b8877f4137 cpuinfo-$CPUINFO.tar.gz +acb111ebdb4f1459899b9c594be81ed284de23ac0f5376e5963aad16df98584f discord-rpc-$DISCORD_RPC.tar.gz + EOF curl -L \ @@ -110,7 +113,8 @@ curl -L \ -o "shaderc-spirv-headers-$SHADERC_SPIRVHEADERS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Headers/archive/$SHADERC_SPIRVHEADERS.tar.gz" \ -o "shaderc-spirv-tools-$SHADERC_SPIRVTOOLS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Tools/archive/$SHADERC_SPIRVTOOLS.tar.gz" \ -o "SPIRV-Cross-$SPIRV_CROSS.tar.gz" "https://github.com/KhronosGroup/SPIRV-Cross/archive/refs/tags/$SPIRV_CROSS.tar.gz" \ - -o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz" + -o "cpuinfo-$CPUINFO.tar.gz" "https://github.com/pytorch/cpuinfo/archive/$CPUINFO.tar.gz" \ + -o "discord-rpc-$DISCORD_RPC.tar.gz" "https://github.com/stenzek/discord-rpc/archive/$DISCORD_RPC.tar.gz" shasum -a 256 --check SHASUMS @@ -313,7 +317,7 @@ make -C build "-j$NPROCS" make -C build install cd .. -echo "Building SPIRV-Cross" +echo "Building SPIRV-Cross..." rm -fr "SPIRV-Cross-$SPIRV_CROSS" tar xf "SPIRV-Cross-$SPIRV_CROSS.tar.gz" cd "SPIRV-Cross-$SPIRV_CROSS" @@ -323,7 +327,7 @@ cmake --build build --parallel cmake --install build cd .. -echo "Building cpuinfo" +echo "Building cpuinfo..." rm -fr "cpuinfo-$CPUINFO" tar xf "cpuinfo-$CPUINFO.tar.gz" cd "cpuinfo-$CPUINFO" @@ -336,6 +340,15 @@ merge_binaries $(realpath build) $(realpath build-arm64) make -C build install cd .. +echo "Building discord-rpc..." +rm -fr "discord-rpc-$DISCORD_RPC" +tar xf "discord-rpc-$DISCORD_RPC.tar.gz" +cd "discord-rpc-$DISCORD_RPC" +cmake "${CMAKE_COMMON[@]}" "$CMAKE_ARCH_UNIVERSAL" -DBUILD_SHARED_LIBS=ON -B build +cmake --build build --parallel +cmake --install build +cd .. + echo "Cleaning up..." cd .. rm -rf deps-build diff --git a/scripts/build-dependencies-windows-arm64.bat b/scripts/build-dependencies-windows-arm64.bat index f32c1ff99..c17a55c42 100644 --- a/scripts/build-dependencies-windows-arm64.bat +++ b/scripts/build-dependencies-windows-arm64.bat @@ -60,6 +60,7 @@ set SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4 set SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7 set SPIRV_CROSS=vulkan-sdk-1.3.283.0 set CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9 +set DISCORD_RPC=842c15192041f8e71c512851834f4dadb1a554fb call :downloadfile "freetype-%FREETYPE%.tar.gz" https://download.savannah.gnu.org/releases/freetype/freetype-%FREETYPE%.tar.gz 1ac27e16c134a7f2ccea177faba19801131116fd682efc1f5737037c5db224b5 || goto error call :downloadfile "harfbuzz-%HARFBUZZ%.zip" https://github.com/harfbuzz/harfbuzz/archive/refs/tags/%HARFBUZZ%.zip b2bc56184ae37324bc4829fde7d3f9e6916866ad711ee85792e457547c9fd127 || goto error @@ -77,6 +78,7 @@ call :downloadfile "zstd-%ZSTD%.zip" "https://github.com/facebook/zstd/archive/r call :downloadfile "zstd-fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch" https://github.com/facebook/zstd/commit/fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch 675f144b11f8ab2424b64bed8ccdca5d3f35b9326046fa7a883925dd180f0651 || goto error call :downloadfile "cpuinfo-%CPUINFO%.zip" "https://github.com/pytorch/cpuinfo/archive/%CPUINFO%.zip" d4a3e252d04b55b1a3bec800fcf2eee36746a2f54405280a9c8355306e09ebe4 || goto error +call :downloadfile "discord-rpc-%DISCORD_RPC%.zip" "https://github.com/stenzek/discord-rpc/archive/%DISCORD_RPC%.zip" 2a32201439fc2ddfc9c0ea4f4f7cfce40706983b9abac22cdba4ce750bcb55a1 || goto error call :downloadfile "shaderc-%SHADERC%.zip" "https://github.com/google/shaderc/archive/refs/tags/v%SHADERC%.zip" 6c9f42ed6bf42750f5369b089909abfdcf0101488b4a1f41116d5159d00af8e7 || goto error call :downloadfile "shaderc-glslang-%SHADERC_GLSLANG%.zip" "https://github.com/KhronosGroup/glslang/archive/%SHADERC_GLSLANG%.zip" 03ad8a6fa987af4653d0cfe6bdaed41bcf617f1366a151fb1574da75950cd3e8 || goto error call :downloadfile "shaderc-spirv-headers-%SHADERC_SPIRVHEADERS%.zip" "https://github.com/KhronosGroup/SPIRV-Headers/archive/%SHADERC_SPIRVHEADERS%.zip" fa59a54334feaba5702b9c25724c3f4746123865769b36dd5a28d9ef5e9d39ab || goto error @@ -276,6 +278,15 @@ cmake --build build --parallel || goto error ninja -C build install || goto error cd .. || goto error +echo Building discord-rpc... +rmdir /S /Q "discord-rpc-%DISCORD_RPC%" +%SEVENZIP% x "discord-rpc-%DISCORD_RPC%.zip" || goto error +cd "discord-rpc-%DISCORD_RPC%" || goto error +cmake %ARM64TOOLCHAIN% -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -B build -G Ninja +cmake --build build --parallel || goto error +ninja -C build install || goto error +cd .. || goto error + echo Cleaning up... cd .. rd /S /Q deps-build diff --git a/scripts/build-dependencies-windows-x64.bat b/scripts/build-dependencies-windows-x64.bat index d843900fe..6b72d265b 100644 --- a/scripts/build-dependencies-windows-x64.bat +++ b/scripts/build-dependencies-windows-x64.bat @@ -58,6 +58,7 @@ set SHADERC_SPIRVHEADERS=5e3ad389ee56fca27c9705d093ae5387ce404df4 set SHADERC_SPIRVTOOLS=dd4b663e13c07fea4fbb3f70c1c91c86731099f7 set SPIRV_CROSS=vulkan-sdk-1.3.283.0 set CPUINFO=05332fd802d9109a2a151ec32154b107c1e5caf9 +set DISCORD_RPC=842c15192041f8e71c512851834f4dadb1a554fb call :downloadfile "freetype-%FREETYPE%.tar.gz" https://download.savannah.gnu.org/releases/freetype/freetype-%FREETYPE%.tar.gz 1ac27e16c134a7f2ccea177faba19801131116fd682efc1f5737037c5db224b5 || goto error call :downloadfile "harfbuzz-%HARFBUZZ%.zip" https://github.com/harfbuzz/harfbuzz/archive/refs/tags/%HARFBUZZ%.zip b2bc56184ae37324bc4829fde7d3f9e6916866ad711ee85792e457547c9fd127 || goto error @@ -75,6 +76,7 @@ call :downloadfile "zstd-%ZSTD%.zip" "https://github.com/facebook/zstd/archive/r call :downloadfile "zstd-fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch" https://github.com/facebook/zstd/commit/fd5f8106a58601a963ee816e6a57aa7c61fafc53.patch 675f144b11f8ab2424b64bed8ccdca5d3f35b9326046fa7a883925dd180f0651 || goto error call :downloadfile "cpuinfo-%CPUINFO%.zip" "https://github.com/pytorch/cpuinfo/archive/%CPUINFO%.zip" d4a3e252d04b55b1a3bec800fcf2eee36746a2f54405280a9c8355306e09ebe4 || goto error +call :downloadfile "discord-rpc-%DISCORD_RPC%.zip" "https://github.com/stenzek/discord-rpc/archive/%DISCORD_RPC%.zip" 2a32201439fc2ddfc9c0ea4f4f7cfce40706983b9abac22cdba4ce750bcb55a1 || goto error call :downloadfile "shaderc-%SHADERC%.zip" "https://github.com/google/shaderc/archive/refs/tags/v%SHADERC%.zip" 6c9f42ed6bf42750f5369b089909abfdcf0101488b4a1f41116d5159d00af8e7 || goto error call :downloadfile "shaderc-glslang-%SHADERC_GLSLANG%.zip" "https://github.com/KhronosGroup/glslang/archive/%SHADERC_GLSLANG%.zip" 03ad8a6fa987af4653d0cfe6bdaed41bcf617f1366a151fb1574da75950cd3e8 || goto error call :downloadfile "shaderc-spirv-headers-%SHADERC_SPIRVHEADERS%.zip" "https://github.com/KhronosGroup/SPIRV-Headers/archive/%SHADERC_SPIRVHEADERS%.zip" fa59a54334feaba5702b9c25724c3f4746123865769b36dd5a28d9ef5e9d39ab || goto error @@ -273,6 +275,15 @@ cmake --build build --parallel || goto error ninja -C build install || goto error cd .. || goto error +echo Building discord-rpc... +rmdir /S /Q "discord-rpc-%DISCORD_RPC%" +%SEVENZIP% x "discord-rpc-%DISCORD_RPC%.zip" || goto error +cd "discord-rpc-%DISCORD_RPC%" || goto error +cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="%INSTALLDIR%" -DCMAKE_INSTALL_PREFIX="%INSTALLDIR%" -DBUILD_SHARED_LIBS=ON -B build -G Ninja +cmake --build build --parallel || goto error +ninja -C build install || goto error +cd .. || goto error + echo Cleaning up... cd .. rd /S /Q deps-build diff --git a/scripts/flatpak/modules/25-discord-rpc.json b/scripts/flatpak/modules/25-discord-rpc.json new file mode 100644 index 000000000..08c15f222 --- /dev/null +++ b/scripts/flatpak/modules/25-discord-rpc.json @@ -0,0 +1,28 @@ +{ + "name": "discord-rpc", + "buildsystem": "cmake-ninja", + "builddir": true, + "config-opts": [ + "-DCMAKE_BUILD_TYPE=Release", + "-DBUILD_SHARED_LIBS=ON" + ], + "build-options": { + "strip": true + }, + "sources": [ + { + "type": "git", + "url": "https://github.com/stenzek/discord-rpc.git", + "commit": "842c15192041f8e71c512851834f4dadb1a554fb" + } + ], + "cleanup": [ + "/bin", + "/include", + "/lib/*.a", + "/lib/*.la", + "/lib/cmake", + "/lib/pkgconfig", + "/share" + ] +} diff --git a/scripts/flatpak/org.duckstation.DuckStation.json b/scripts/flatpak/org.duckstation.DuckStation.json index 14bacf9c5..bc35420d4 100644 --- a/scripts/flatpak/org.duckstation.DuckStation.json +++ b/scripts/flatpak/org.duckstation.DuckStation.json @@ -23,6 +23,7 @@ "modules/22-shaderc.json", "modules/23-spirv-cross.json", "modules/24-cpuinfo.json", + "modules/25-discord-rpc.json", { "name": "duckstation", "buildsystem": "cmake-ninja",