diff options
Diffstat (limited to 'net-misc')
-rw-r--r-- | net-misc/sunshine/Manifest | 11 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-0.21.0-no-x11.patch | 36 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-0.21.0-system-deps.patch | 341 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-0.21.0-vaapi.patch | 26 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-custom-ffmpeg.patch | 163 | ||||
-rw-r--r-- | net-misc/sunshine/files/sunshine-system-json.patch | 56 | ||||
-rw-r--r-- | net-misc/sunshine/metadata.xml | 20 | ||||
-rw-r--r-- | net-misc/sunshine/sunshine-0.21.0.ebuild | 374 | ||||
-rw-r--r-- | net-misc/sunshine/sunshine-9999.ebuild | 377 |
9 files changed, 1404 insertions, 0 deletions
diff --git a/net-misc/sunshine/Manifest b/net-misc/sunshine/Manifest new file mode 100644 index 000000000000..a7940bffef95 --- /dev/null +++ b/net-misc/sunshine/Manifest @@ -0,0 +1,11 @@ +DIST LizardByte-build-deps-2aafe061cd52a944cb3b5f86d1f25e9ad2a19bec.tar.gz 24171 BLAKE2B bcc8f1829eae4ba85a9cbdaca7876a4a52c979f3b8ef0f0a56876fcb171025544bd1997455c2b8fff59564deca433366ae03f14cbb0929f78c87f991b269156f SHA512 892184ec0ff321b2b7e2000dc605d1162955cb04ff259f6032f124f1ff50a1fe485e2cf2c0b735788f8615c9aba87ca040205599cb4b91881daa462a53340bd7 +DIST LizardByte-tray-e08bdbe5aa7de0ad9c0ce36257016e07c7e6e2c0.tar.gz 1066914 BLAKE2B 814e4aeace655cb06d50cbe26847f107b4141cec40fc812b924e87e4e14c7cddf8ee6dce0f54f76bf1f5c8dd355a8d7e32485759caa2c91aa24b1c594f1a879d SHA512 04df675d3fa8676b08a566bbbfb90af80b1efdd5ffc264f9aced3116ad1a3ad14c80a486a84f1ed800fd2ea2c2046e36f2919a2bb48cecdfca3baa3b650d3c48 +DIST Simple-Web-Server-27b41f5ee154cca0fce4fe2955dd886d04e3a4ed.tar.bz2 63258 BLAKE2B e80a6cd92825038ca75b973281b676584f9e488b45b1f9c6ed526236c0a7188b97ae2bba9d7b5557893452dd1ba8778faff2ade840cc169d20b4cf0e51fc8394 SHA512 2eba1d8bd53bb3e29e51a72000918b44730f73b4df26824f25cb6a4860dd21f8aaa7f77124fb500ffe9601ebeca66d1c21a06cad239ed27481e9cae088afbd44 +DIST ffmpeg-6.1.1.tar.xz 10458600 BLAKE2B 77827ff92b47c773ed82e7b7793dbb135c370fe23501169cb1eab08ff5ede77cfd5b397e8fb1d38756812cc82277898fd5c74b7d8495842556570c0c5570daeb SHA512 fca3f8635f29182e3ae0fe843a8a53614e4b47e22c11508df3ff7cdbafbb4b5ee0d82d9b3332871f7c1032033b1cad2f67557d7c5f7f7d85e2adadca122965d5 +DIST moonlight-common-c-6e9ed871bc3e013386c775b2ee7d31deb1151068.tar.gz 143942 BLAKE2B d8e98cffc683cc7ef6ad9e58c0a154a60e4bf5742fba8c4bce270b84c2af6ff455a6f7e2920e3b83db052c2a1632e787f9a444b381a8a7476ab79fa4f79560ad SHA512 a9024ba400e6804c0b26db57fa16ddbcd080982f852d26fd1ca8ae84f969bacd883c4adc83105bd18e1af4d34e831dc241d0278f88549b46497eb62c72f39bf2 +DIST moonlight-enet-c6bb0e50118d08252eee308de8412751218442d6.tar.gz 85497 BLAKE2B 484cf25d37ed230946edc7417ca20ea4c16828f2a099fd6a88dca08dc78a5314e837c96d9a7536ace3e45c55d0edd8698568af8d5087adc7429bc4d3966cfbae SHA512 1e7f93639139ec3d02c5b442dd2d49e2ab8e729b7c4ee51d9b2da4061f8e3794e7984858cfb87d279b85939a9fed6d0c4a3b9994c30597791461e612a64843e2 +DIST nanors-e9e242e98e27037830490b2a752895ca68f75f8b.tar.gz 194694 BLAKE2B 1effd7c0884ffd38b63d61a7872337797529ef2012f9de0950088a5004cb32a2fb2c14bcab2ec6719968864e5e6b9a67e96afa39466e2071bf4a0cd752ae4b29 SHA512 548be25650619a6c31944cd7a745fd40d5bc5008f2d7f91e0207a10b923764cb88fd2ddcb71eaed7c4863ec89b34d61011b666e292da071ac3b4429e4d7dd027 +DIST nv-codec-headers-22441b505d9d9afc1e3002290820909846c24bdc.tar.gz 77625 BLAKE2B 5b80efdf8a8290e5e1620779f92a874deff561fb66e6ad8c6c84ce7161c7540521a0c60b93ecdd6702e668b113bc12c56e4f02583ffffa72b0cc892d41db1966 SHA512 3fa66cc36a982db24b3f57925dd4cef99ead58f5e01ad2764638d16749b35c41f1ae5ad0cf7c73e4e62ad5391065ba2345e309ebf339b274532560d2c4820153 +DIST sunshine-0.21.0.tar.gz 24066116 BLAKE2B cc7ecf20ea69ed9c35c97194ca803f5a329234d1857b8f9dcee070c08ccc36de4481acc4f493c4d5f9b7fce5f5bf6986630d26233e7fc0495a688d7f2fea4696 SHA512 96e71ca6e36f7944b5f96005e2cab4287cba0fd0d2e561e6eeea7fa1cbf047576ca6debc786d34d7543dab361841fbf59cbb950e0d3413be8ba8dfb81342056e +DIST sunshine-node-modules-0.21.0.tar.xz 2171156 BLAKE2B aa592d7041d08ff3dc795bf7afb5197e849afc7479df3c2e66e03b279f91cfb083e2e9f51ef594756b83b87b89214f48192be76b2efc7574a6aaf28d77ca7b37 SHA512 0a1cd9017b079a63f58f7fb4f2aaff8e2449788b213ddb6fa1da6bebf8a1d259ecc5900bb4ceaa15ca7bdca817792aeeff31e205d48593c3a55261c9f99d8f04 +DIST wlr-protocols-4264185db3b7e961e7f157e1cc4fd0ab75137568.tar.bz2 19574 BLAKE2B 65666095f186857e3c5274b23d5c40b40b0ba5d945c7b34331a06320128cb69a36a76baf2381b635858736ca6ed438c2ed67c03fac1c20e1ec4d71de27037e42 SHA512 0e6afde055d9b76bcb8c717433b78814f2cf9338ead451d3119f62463198ef272029767898e8f7d32896f2732be3aaa2a0373c671d8196e745d62f6116cd1583 diff --git a/net-misc/sunshine/files/sunshine-0.21.0-no-x11.patch b/net-misc/sunshine/files/sunshine-0.21.0-no-x11.patch new file mode 100644 index 000000000000..a013be390095 --- /dev/null +++ b/net-misc/sunshine/files/sunshine-0.21.0-no-x11.patch @@ -0,0 +1,36 @@ +From 34ca4390bbae4dadf451af7dd4ec920a263558be Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Sun, 31 Dec 2023 20:57:45 +0000 +Subject: [PATCH 2/2] Fix grabbing code when DRM is enabled and X11 is disabled + (#1956) + +--- + src/platform/linux/x11grab.h | 5 +---- + 1 file changed, 1 insertion(+), 4 deletions(-) + +diff --git a/src/platform/linux/x11grab.h b/src/platform/linux/x11grab.h +index 24e96f6..4c2f347 100644 +--- a/src/platform/linux/x11grab.h ++++ b/src/platform/linux/x11grab.h +@@ -51,9 +51,6 @@ namespace platf::x11 { + xdisplay_t + make_display(); + #else +- // It's never something different from nullptr +- util::safe_ptr<_XDisplay, std::default_delete<_XDisplay>>; +- + class cursor_t { + public: + static std::optional<cursor_t> +@@ -65,7 +62,7 @@ namespace platf::x11 { + blend(img_t &, int, int) {} + }; + +- xdisplay_t ++ void * + make_display() { return nullptr; } + #endif + } // namespace platf::x11 +-- +2.43.0 + diff --git a/net-misc/sunshine/files/sunshine-0.21.0-system-deps.patch b/net-misc/sunshine/files/sunshine-0.21.0-system-deps.patch new file mode 100644 index 000000000000..bfb5d41aba15 --- /dev/null +++ b/net-misc/sunshine/files/sunshine-0.21.0-system-deps.patch @@ -0,0 +1,341 @@ +From 9ac47f2b21391758065cc32df2d54e59a56425b8 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 01:04:04 +0000 +Subject: [PATCH 1/4] Optionally allow the system installation of MiniUPnP to + be used (#1959) + +--- + cmake/compile_definitions/common.cmake | 2 +- + cmake/dependencies/common.cmake | 38 ++++++++++++++++++-------- + cmake/prep/options.cmake | 2 ++ + 3 files changed, 29 insertions(+), 13 deletions(-) + +diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake +index f10b200..c096920 100644 +--- a/cmake/compile_definitions/common.cmake ++++ b/cmake/compile_definitions/common.cmake +@@ -118,7 +118,7 @@ else() + endif() + + list(APPEND SUNSHINE_EXTERNAL_LIBRARIES +- libminiupnpc-static ++ ${MINIUPNP_LIBRARIES} + ${CMAKE_THREAD_LIBS_INIT} + enet + opus +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index 9bc7c56..b26b12a 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -9,13 +9,33 @@ add_subdirectory(third-party/moonlight-common-c/enet) + # web server + add_subdirectory(third-party/Simple-Web-Server) + ++# common dependencies ++find_package(OpenSSL REQUIRED) ++find_package(PkgConfig REQUIRED) ++find_package(Threads REQUIRED) ++pkg_check_modules(CURL REQUIRED libcurl) ++ + # miniupnp +-set(UPNPC_BUILD_SHARED OFF CACHE BOOL "No shared libraries") +-set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc") +-set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc") +-set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc") +-add_subdirectory(third-party/miniupnp/miniupnpc) +-include_directories(SYSTEM third-party/miniupnp/miniupnpc/include) ++if(SUNSHINE_SYSTEM_MINIUPNP) ++ pkg_check_modules(MINIUPNP miniupnpc REQUIRED) ++ ++ # Use includedir pkg-config variable rather than MINIUPNP_INCLUDE_DIRS ++ # defined above. The latter may be blank, as pkg-config sometimes omits -I ++ # flags for directories that are searched by default (e.g. /usr/include), ++ # but we need a value to append /miniupnpc to. Normally source files would ++ # prefix their #include directives with miniupnpc/, but this does not align ++ # with the directory structure of the git submodule used below. ++ pkg_get_variable(MINIUPNP_INCLUDE_DIR miniupnpc includedir) ++ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIR}/miniupnpc) ++else() ++ set(UPNPC_BUILD_SHARED OFF CACHE BOOL "No shared libraries") ++ set(UPNPC_BUILD_TESTS OFF CACHE BOOL "Don't build tests for miniupnpc") ++ set(UPNPC_BUILD_SAMPLE OFF CACHE BOOL "Don't build samples for miniupnpc") ++ set(UPNPC_NO_INSTALL ON CACHE BOOL "Don't install any libraries build for miniupnpc") ++ set(MINIUPNP_LIBRARIES libminiupnpc-static) ++ add_subdirectory(third-party/miniupnp/miniupnpc) ++ include_directories(SYSTEM third-party/miniupnp/miniupnpc/include) ++endif() + + # ffmpeg pre-compiled binaries + if(WIN32) +@@ -66,12 +86,6 @@ set(FFMPEG_LIBRARIES + ${HDR10_PLUS_LIBRARY} + ${FFMPEG_PLATFORM_LIBRARIES}) + +-# common dependencies +-find_package(OpenSSL REQUIRED) +-find_package(PkgConfig REQUIRED) +-find_package(Threads REQUIRED) +-pkg_check_modules(CURL REQUIRED libcurl) +- + # platform specific dependencies + if(WIN32) + include(${CMAKE_MODULE_PATH}/dependencies/windows.cmake) +diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake +index 1a216d2..cb26461 100644 +--- a/cmake/prep/options.cmake ++++ b/cmake/prep/options.cmake +@@ -4,6 +4,8 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF) + option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON) + option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON) + ++option(SUNSHINE_SYSTEM_MINIUPNP "Use system installation of MiniUPnP rather than the submodule." OFF) ++ + if(APPLE) + option(SUNSHINE_CONFIGURE_PORTFILE + "Configure macOS Portfile. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF) +-- +2.43.0 + + +From 2056874748872e820c343556fc6ede4449e376f8 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 16:49:00 +0000 +Subject: [PATCH 2/4] Optionally allow the system installation of + wayland-protocols to be used (#1966) + +--- + cmake/compile_definitions/linux.cmake | 11 +++++++++-- + cmake/macros/linux.cmake | 8 ++++---- + cmake/prep/options.cmake | 1 + + 3 files changed, 14 insertions(+), 6 deletions(-) + +diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake +index f28152e..a13a823 100644 +--- a/cmake/compile_definitions/linux.cmake ++++ b/cmake/compile_definitions/linux.cmake +@@ -127,8 +127,15 @@ endif() + if(WAYLAND_FOUND) + add_compile_definitions(SUNSHINE_BUILD_WAYLAND) + +- GEN_WAYLAND("wayland-protocols" "unstable/xdg-output" xdg-output-unstable-v1) +- GEN_WAYLAND("wlr-protocols" "unstable" wlr-export-dmabuf-unstable-v1) ++ if(NOT SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS) ++ set(WAYLAND_PROTOCOLS_DIR "${CMAKE_SOURCE_DIR}/third-party/wayland-protocols") ++ else() ++ pkg_get_variable(WAYLAND_PROTOCOLS_DIR wayland-protocols pkgdatadir) ++ pkg_check_modules(WAYLAND_PROTOCOLS wayland-protocols REQUIRED) ++ endif() ++ ++ GEN_WAYLAND("${WAYLAND_PROTOCOLS_DIR}" "unstable/xdg-output" xdg-output-unstable-v1) ++ GEN_WAYLAND("${CMAKE_SOURCE_DIR}/third-party/wlr-protocols" "unstable" wlr-export-dmabuf-unstable-v1) + + include_directories( + SYSTEM +diff --git a/cmake/macros/linux.cmake b/cmake/macros/linux.cmake +index d84d045..0bb5e04 100644 +--- a/cmake/macros/linux.cmake ++++ b/cmake/macros/linux.cmake +@@ -5,17 +5,17 @@ macro(GEN_WAYLAND wayland_directory subdirectory filename) + file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/generated-src) + + message("wayland-scanner private-code \ +-${CMAKE_SOURCE_DIR}/third-party/${wayland_directory}/${subdirectory}/${filename}.xml \ ++${wayland_directory}/${subdirectory}/${filename}.xml \ + ${CMAKE_BINARY_DIR}/generated-src/${filename}.c") + message("wayland-scanner client-header \ +-${CMAKE_SOURCE_DIR}/third-party/${wayland_directory}/${subdirectory}/${filename}.xml \ ++${wayland_directory}/${subdirectory}/${filename}.xml \ + ${CMAKE_BINARY_DIR}/generated-src/${filename}.h") + execute_process( + COMMAND wayland-scanner private-code +- ${CMAKE_SOURCE_DIR}/third-party/${wayland_directory}/${subdirectory}/${filename}.xml ++ ${wayland_directory}/${subdirectory}/${filename}.xml + ${CMAKE_BINARY_DIR}/generated-src/${filename}.c + COMMAND wayland-scanner client-header +- ${CMAKE_SOURCE_DIR}/third-party/${wayland_directory}/${subdirectory}/${filename}.xml ++ ${wayland_directory}/${subdirectory}/${filename}.xml + ${CMAKE_BINARY_DIR}/generated-src/${filename}.h + + RESULT_VARIABLE EXIT_INT +diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake +index cb26461..dc6b5f6 100644 +--- a/cmake/prep/options.cmake ++++ b/cmake/prep/options.cmake +@@ -5,6 +5,7 @@ option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignore + option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON) + + option(SUNSHINE_SYSTEM_MINIUPNP "Use system installation of MiniUPnP rather than the submodule." OFF) ++option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) + + if(APPLE) + option(SUNSHINE_CONFIGURE_PORTFILE +-- +2.43.0 + + +From a0a6d322c292efa67a59df7b4c71beeb17b322ce Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 11:17:08 +0000 +Subject: [PATCH 3/4] Allow a custom FFmpeg build to be provided using CMake + options + +--- + cmake/dependencies/common.cmake | 96 ++++++++++++++++++--------------- + 1 file changed, 53 insertions(+), 43 deletions(-) + +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index b26b12a..30069d3 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -38,53 +38,63 @@ else() + endif() + + # ffmpeg pre-compiled binaries +-if(WIN32) +- if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) +- endif() +- set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl) +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-windows-x86_64") +-elseif(APPLE) +- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-x86_64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-aarch64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc") +- message(FATAL_ERROR "PowerPC is not supported on macOS") +- else() +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++if(NOT DEFINED FFMPEG_PREPARED_BINARIES) ++ if(WIN32) ++ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() ++ set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl) ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-windows-x86_64") ++ elseif(APPLE) ++ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-x86_64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-macos-aarch64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc") ++ message(FATAL_ERROR "PowerPC is not supported on macOS") ++ else() ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() ++ elseif(UNIX) ++ set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) ++ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ++ list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-x86_64") ++ set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,") ++ set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-aarch64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-powerpc64le") ++ else() ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() + endif() +-elseif(UNIX) +- set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) +- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +- list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-x86_64") +- set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,") +- set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-aarch64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-powerpc64le") +- else() +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ if(EXISTS ${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a) ++ set(HDR10_PLUS_LIBRARY ++ ${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a) + endif() ++ set(FFMPEG_LIBRARIES ++ ${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libSvtAv1Enc.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libx264.a ++ ${FFMPEG_PREPARED_BINARIES}/lib/libx265.a ++ ${HDR10_PLUS_LIBRARY} ++ ${FFMPEG_PLATFORM_LIBRARIES}) ++else() ++ set(FFMPEG_LIBRARIES ++ "${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a" ++ ${FFMPEG_PLATFORM_LIBRARIES}) + endif() ++ + set(FFMPEG_INCLUDE_DIRS +- ${FFMPEG_PREPARED_BINARIES}/include) +-if(EXISTS ${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a) +- set(HDR10_PLUS_LIBRARY +- ${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a) +-endif() +-set(FFMPEG_LIBRARIES +- ${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libSvtAv1Enc.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libx264.a +- ${FFMPEG_PREPARED_BINARIES}/lib/libx265.a +- ${HDR10_PLUS_LIBRARY} +- ${FFMPEG_PLATFORM_LIBRARIES}) ++ "${FFMPEG_PREPARED_BINARIES}/include") + + # platform specific dependencies + if(WIN32) +-- +2.43.0 + + +From c871ffc1606f148e55f80415a289317f74820ddf Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 13:34:20 +0000 +Subject: [PATCH 4/4] Move numa from general PLATFORM_LIBRARIES to + FFMPEG_PLATFORM_LIBRARIES + +It's only needed if libx265 was built with NUMA support. This support +may be disabled in a custom FFmpeg build. +--- + cmake/compile_definitions/linux.cmake | 1 - + cmake/dependencies/common.cmake | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake +index a13a823..a2baa9c 100644 +--- a/cmake/compile_definitions/linux.cmake ++++ b/cmake/compile_definitions/linux.cmake +@@ -223,7 +223,6 @@ list(APPEND PLATFORM_LIBRARIES + Boost::dynamic_linking + dl + evdev +- numa + pulse + pulse-simple) + +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index 30069d3..fc86ab7 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -56,7 +56,7 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES) + message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) + endif() + elseif(UNIX) +- set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) ++ set(FFMPEG_PLATFORM_LIBRARIES numa va va-drm va-x11 vdpau X11) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) + set(FFMPEG_PREPARED_BINARIES "${CMAKE_CURRENT_SOURCE_DIR}/third-party/ffmpeg-linux-x86_64") +-- +2.43.0 + diff --git a/net-misc/sunshine/files/sunshine-0.21.0-vaapi.patch b/net-misc/sunshine/files/sunshine-0.21.0-vaapi.patch new file mode 100644 index 000000000000..3db5e47d44d9 --- /dev/null +++ b/net-misc/sunshine/files/sunshine-0.21.0-vaapi.patch @@ -0,0 +1,26 @@ +From dac48e21278339e72c9b3efb5dab63d9c10b5975 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@aura-online.co.uk> +Date: Sun, 31 Dec 2023 20:10:48 +0000 +Subject: [PATCH 1/2] Use dl handle for libva's vaTerminate rather than actual + function (#1955) + +--- + src/platform/linux/vaapi.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/platform/linux/vaapi.cpp b/src/platform/linux/vaapi.cpp +index 18b0dff..77daeab 100644 +--- a/src/platform/linux/vaapi.cpp ++++ b/src/platform/linux/vaapi.cpp +@@ -520,7 +520,7 @@ namespace va { + auto hwctx = (AVVAAPIDeviceContext *) ctx->hwctx; + auto priv = (VAAPIDevicePriv *) ctx->user_opaque; + +- vaTerminate(hwctx->display); ++ terminate(hwctx->display); + close(priv->drm_fd); + av_freep(&priv); + } +-- +2.43.0 + diff --git a/net-misc/sunshine/files/sunshine-custom-ffmpeg.patch b/net-misc/sunshine/files/sunshine-custom-ffmpeg.patch new file mode 100644 index 000000000000..94febe187c1f --- /dev/null +++ b/net-misc/sunshine/files/sunshine-custom-ffmpeg.patch @@ -0,0 +1,163 @@ +From 64783df9d7ed22916894387a8ff1f73a97dbb760 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 11:17:08 +0000 +Subject: [PATCH 1/2] Allow a custom FFmpeg build to be provided using CMake + options + +--- + cmake/dependencies/common.cmake | 90 ++++++++++++++++++--------------- + 1 file changed, 50 insertions(+), 40 deletions(-) + +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index a1f3512..d921c1b 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -23,53 +23,63 @@ include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS}) + add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json") + + # ffmpeg pre-compiled binaries +-if(WIN32) +- if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++if(NOT DEFINED FFMPEG_PREPARED_BINARIES) ++ if(WIN32) ++ if(NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "AMD64") ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() ++ set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl) ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/windows-x86_64") ++ elseif(APPLE) ++ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/macos-x86_64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/macos-aarch64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc") ++ message(FATAL_ERROR "PowerPC is not supported on macOS") ++ else() ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() ++ elseif(UNIX) ++ set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) ++ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") ++ list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-x86_64") ++ set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,") ++ set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-aarch64") ++ elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") ++ set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-powerpc64le") ++ else() ++ message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ endif() + endif() +- set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl) +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/windows-x86_64") +-elseif(APPLE) +- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/macos-x86_64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/macos-aarch64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "powerpc") +- message(FATAL_ERROR "PowerPC is not supported on macOS") +- else() +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) ++ if(EXISTS "${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a") ++ set(HDR10_PLUS_LIBRARY ++ "${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a") + endif() +-elseif(UNIX) +- set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) +- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") +- list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-x86_64") +- set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,") +- set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-aarch64") +- elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64le" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "ppc64") +- set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-powerpc64le") +- else() +- message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) +- endif() +-endif() +-set(FFMPEG_INCLUDE_DIRS +- "${FFMPEG_PREPARED_BINARIES}/include") +-if(EXISTS "${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a") +- set(HDR10_PLUS_LIBRARY +- "${FFMPEG_PREPARED_BINARIES}/lib/libhdr10plus.a") +-endif() +-set(FFMPEG_LIBRARIES ++ set(FFMPEG_LIBRARIES ++ "${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libSvtAv1Enc.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libx264.a" ++ "${FFMPEG_PREPARED_BINARIES}/lib/libx265.a" ++ ${HDR10_PLUS_LIBRARY} ++ ${FFMPEG_PLATFORM_LIBRARIES}) ++else() ++ set(FFMPEG_LIBRARIES + "${FFMPEG_PREPARED_BINARIES}/lib/libavcodec.a" + "${FFMPEG_PREPARED_BINARIES}/lib/libavutil.a" + "${FFMPEG_PREPARED_BINARIES}/lib/libcbs.a" +- "${FFMPEG_PREPARED_BINARIES}/lib/libSvtAv1Enc.a" + "${FFMPEG_PREPARED_BINARIES}/lib/libswscale.a" +- "${FFMPEG_PREPARED_BINARIES}/lib/libx264.a" +- "${FFMPEG_PREPARED_BINARIES}/lib/libx265.a" +- ${HDR10_PLUS_LIBRARY} + ${FFMPEG_PLATFORM_LIBRARIES}) ++endif() ++ ++set(FFMPEG_INCLUDE_DIRS ++ "${FFMPEG_PREPARED_BINARIES}/include") + + # platform specific dependencies + if(WIN32) +-- +2.43.0 + + +From b7a479b15216900fdc4cbc5587d8fd90e366f5a5 Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Mon, 1 Jan 2024 13:34:20 +0000 +Subject: [PATCH 2/2] Move numa from general PLATFORM_LIBRARIES to + FFMPEG_PLATFORM_LIBRARIES + +It's only needed if libx265 was built with NUMA support. This support +may be disabled in a custom FFmpeg build. +--- + cmake/compile_definitions/linux.cmake | 1 - + cmake/dependencies/common.cmake | 2 +- + 2 files changed, 1 insertion(+), 2 deletions(-) + +diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake +index 613a090..e1fda2c 100644 +--- a/cmake/compile_definitions/linux.cmake ++++ b/cmake/compile_definitions/linux.cmake +@@ -242,7 +242,6 @@ list(APPEND PLATFORM_LIBRARIES + Boost::dynamic_linking + dl + evdev +- numa + pulse + pulse-simple) + +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index d921c1b..23695e3 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -41,7 +41,7 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES) + message(FATAL_ERROR "Unsupported system processor:" ${CMAKE_SYSTEM_PROCESSOR}) + endif() + elseif(UNIX) +- set(FFMPEG_PLATFORM_LIBRARIES va va-drm va-x11 vdpau X11) ++ set(FFMPEG_PLATFORM_LIBRARIES numa va va-drm va-x11 vdpau X11) + if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx) + set(FFMPEG_PREPARED_BINARIES "${CMAKE_SOURCE_DIR}/third-party/build-deps/ffmpeg/linux-x86_64") +-- +2.43.0 + diff --git a/net-misc/sunshine/files/sunshine-system-json.patch b/net-misc/sunshine/files/sunshine-system-json.patch new file mode 100644 index 000000000000..62e405e8546f --- /dev/null +++ b/net-misc/sunshine/files/sunshine-system-json.patch @@ -0,0 +1,56 @@ +From ec7c960954bba6a3aab03ff74fdbd3bc89948d4c Mon Sep 17 00:00:00 2001 +From: James Le Cuirot <chewi@gentoo.org> +Date: Sat, 17 Feb 2024 17:02:45 +0000 +Subject: [PATCH] Optionally allow the system installation of nlohmann_json to + be used + +--- + cmake/compile_definitions/common.cmake | 2 +- + cmake/dependencies/common.cmake | 8 +++++++- + cmake/prep/options.cmake | 1 + + 3 files changed, 9 insertions(+), 2 deletions(-) + +diff --git a/cmake/compile_definitions/common.cmake b/cmake/compile_definitions/common.cmake +index 94f1ac5..c65930c 100644 +--- a/cmake/compile_definitions/common.cmake ++++ b/cmake/compile_definitions/common.cmake +@@ -135,4 +135,4 @@ list(APPEND SUNSHINE_EXTERNAL_LIBRARIES + ${OPENSSL_LIBRARIES} + ${CURL_LIBRARIES} + ${PLATFORM_LIBRARIES} +- nlohmann_json::nlohmann_json) ++ ${JSON_LIBRARIES}) +diff --git a/cmake/dependencies/common.cmake b/cmake/dependencies/common.cmake +index a1f3512..849afe7 100644 +--- a/cmake/dependencies/common.cmake ++++ b/cmake/dependencies/common.cmake +@@ -20,7 +20,13 @@ pkg_check_modules(MINIUPNP miniupnpc REQUIRED) + include_directories(SYSTEM ${MINIUPNP_INCLUDE_DIRS}) + + # nlohmann_json +-add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json") ++if(NOT SUNSHINE_SYSTEM_NLOHMANN_JSON) ++ add_subdirectory("${CMAKE_SOURCE_DIR}/third-party/nlohmann_json") ++ set(JSON_LIBRARIES nlohmann_json::nlohmann_json) ++else() ++ pkg_check_modules(NLOHMANN_JSON nlohmann_json REQUIRED IMPORTED_TARGET) ++ set(JSON_LIBRARIES PkgConfig::NLOHMANN_JSON) ++endif() + + # ffmpeg pre-compiled binaries + if(WIN32) +diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake +index 7a8d728..8a7c2f6 100644 +--- a/cmake/prep/options.cmake ++++ b/cmake/prep/options.cmake +@@ -4,6 +4,7 @@ option(SUNSHINE_CONFIGURE_ONLY "Configure special files only, then exit." OFF) + option(SUNSHINE_ENABLE_TRAY "Enable system tray icon. This option will be ignored on macOS." ON) + option(SUNSHINE_REQUIRE_TRAY "Require system tray icon. Fail the build if tray requirements are not met." ON) + ++option(SUNSHINE_SYSTEM_NLOHMANN_JSON "Use system installation of nlohmann_json rather than the submodule." OFF) + option(SUNSHINE_SYSTEM_WAYLAND_PROTOCOLS "Use system installation of wayland-protocols rather than the submodule." OFF) + + if(APPLE) +-- +2.43.0 + diff --git a/net-misc/sunshine/metadata.xml b/net-misc/sunshine/metadata.xml new file mode 100644 index 000000000000..11dc749f56cf --- /dev/null +++ b/net-misc/sunshine/metadata.xml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE pkgmetadata SYSTEM "https://www.gentoo.org/dtd/metadata.dtd"> +<pkgmetadata> + <maintainer type="person"> + <email>chewi@gentoo.org</email> + <name>James Le Cuirot</name> + </maintainer> + <upstream> + <remote-id type="github">LizardByte/Sunshine</remote-id> + <bugs-to>https://bugs.gentoo.org</bugs-to> + </upstream> + <use> + <flag name="cuda">Enable accelerated video encoding on NVIDIA hardware</flag> + <flag name="libdrm">Enable video encoding via <pkg>x11-libs/libdrm</pkg></flag> + <flag name="svt-av1">Enables software AV1 encoding via <pkg>media-libs/svt-av1</pkg></flag> + <flag name="trayicon">Enable system tray icon</flag> + <flag name="x264">Enable software H.264 encoding via <pkg>media-libs/x264</pkg></flag> + <flag name="x265">Enable software HEVC encoding via <pkg>media-libs/x265</pkg></flag> + </use> +</pkgmetadata> diff --git a/net-misc/sunshine/sunshine-0.21.0.ebuild b/net-misc/sunshine/sunshine-0.21.0.ebuild new file mode 100644 index 000000000000..f7a4308dec1f --- /dev/null +++ b/net-misc/sunshine/sunshine-0.21.0.ebuild @@ -0,0 +1,374 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# These don't necessarily have to align with the upstream release. +# We do have nv-codec-headers packaged, but Sunshine is very picky here. +BUILD_DEPS_COMMIT="2aafe061cd52a944cb3b5f86d1f25e9ad2a19bec" +ENET_COMMIT="c6bb0e50118d08252eee308de8412751218442d6" +MOONLIGHT_COMMIT="6e9ed871bc3e013386c775b2ee7d31deb1151068" +NANORS_COMMIT="e9e242e98e27037830490b2a752895ca68f75f8b" +NV_CODEC_COMMIT="22441b505d9d9afc1e3002290820909846c24bdc" +TRAY_COMMIT="e08bdbe5aa7de0ad9c0ce36257016e07c7e6e2c0" +SWS_COMMIT="27b41f5ee154cca0fce4fe2955dd886d04e3a4ed" +WLRP_COMMIT="4264185db3b7e961e7f157e1cc4fd0ab75137568" +FFMPEG_VERSION="6.1.1" + +# To make the node-modules tarball: +# PV= +# git fetch +# git checkout v$PV +# rm -rf node_modules +# npm install +# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-node-modules-$PV.tar.xz node_modules + +if [[ ${PV} = 9999* ]]; then + inherit git-r3 +else + SRC_URI=" + https://github.com/LizardByte/Sunshine/archive/refs/tags/v${PV}.tar.gz + -> ${P}.tar.gz + https://github.com/LizardByte/build-deps/archive/${BUILD_DEPS_COMMIT}.tar.gz + -> LizardByte-build-deps-${BUILD_DEPS_COMMIT}.tar.gz + https://github.com/cgutman/enet/archive/${ENET_COMMIT}.tar.gz + -> moonlight-enet-${ENET_COMMIT}.tar.gz + https://github.com/moonlight-stream/moonlight-common-c/archive/${MOONLIGHT_COMMIT}.tar.gz + -> moonlight-common-c-${MOONLIGHT_COMMIT}.tar.gz + https://github.com/sleepybishop/nanors/archive/${NANORS_COMMIT}.tar.gz + -> nanors-${NANORS_COMMIT}.tar.gz + https://github.com/FFmpeg/nv-codec-headers/archive/${NV_CODEC_COMMIT}.tar.gz + -> nv-codec-headers-${NV_CODEC_COMMIT}.tar.gz + https://github.com/LizardByte/tray/archive/${TRAY_COMMIT}.tar.gz + -> LizardByte-tray-${TRAY_COMMIT}.tar.gz + https://gitlab.com/eidheim/Simple-Web-Server/-/archive/${SWS_COMMIT}/Simple-Web-Server-${SWS_COMMIT}.tar.bz2 + https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/archive/${WLRP_COMMIT}/wlr-protocols-${WLRP_COMMIT}.tar.bz2 + https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz + https://dev.gentoo.org/~chewi/distfiles/${PN}-node-modules-${PV}.tar.xz + " + KEYWORDS="~amd64 ~arm64" + S="${WORKDIR}/Sunshine-${PV}" +fi + +inherit cmake fcaps flag-o-matic toolchain-funcs udev xdg + +DESCRIPTION="Self-hosted game stream host for Moonlight" +HOMEPAGE="https://github.com/LizardByte/Sunshine" +LICENSE="GPL-3" +SLOT="0" +IUSE="cuda debug libdrm svt-av1 trayicon vaapi wayland X x264 x265" + +# Strings for CPU features in the useflag[:configure_option] form +# if :configure_option isn't set, it will use 'useflag' as configure option +ARM_CPU_FEATURES=( + cpu_flags_arm_thumb:armv5te + cpu_flags_arm_v6:armv6 + cpu_flags_arm_thumb2:armv6t2 + cpu_flags_arm_neon:neon + cpu_flags_arm_vfp:vfp + cpu_flags_arm_vfpv3:vfpv3 + cpu_flags_arm_v8:armv8 +) +ARM_CPU_REQUIRED_USE=" + arm64? ( cpu_flags_arm_v8 ) + cpu_flags_arm_v8? ( cpu_flags_arm_vfpv3 cpu_flags_arm_neon ) + cpu_flags_arm_neon? ( + cpu_flags_arm_vfp + arm? ( cpu_flags_arm_thumb2 ) + ) + cpu_flags_arm_vfpv3? ( cpu_flags_arm_vfp ) + cpu_flags_arm_thumb2? ( cpu_flags_arm_v6 ) + cpu_flags_arm_v6? ( + arm? ( cpu_flags_arm_thumb ) + ) +" +PPC_CPU_FEATURES=( cpu_flags_ppc_altivec:altivec cpu_flags_ppc_vsx:vsx cpu_flags_ppc_vsx2:power8 ) +PPC_CPU_REQUIRED_USE=" + cpu_flags_ppc_vsx? ( cpu_flags_ppc_altivec ) + cpu_flags_ppc_vsx2? ( cpu_flags_ppc_vsx ) +" +X86_CPU_FEATURES_RAW=( 3dnow:amd3dnow 3dnowext:amd3dnowext aes:aesni avx:avx avx2:avx2 fma3:fma3 fma4:fma4 mmx:mmx + mmxext:mmxext sse:sse sse2:sse2 sse3:sse3 ssse3:ssse3 sse4_1:sse4 sse4_2:sse42 xop:xop ) +X86_CPU_FEATURES=( ${X86_CPU_FEATURES_RAW[@]/#/cpu_flags_x86_} ) +X86_CPU_REQUIRED_USE=" + cpu_flags_x86_avx2? ( cpu_flags_x86_avx ) + cpu_flags_x86_fma4? ( cpu_flags_x86_avx ) + cpu_flags_x86_fma3? ( cpu_flags_x86_avx ) + cpu_flags_x86_xop? ( cpu_flags_x86_avx ) + cpu_flags_x86_avx? ( cpu_flags_x86_sse4_2 ) + cpu_flags_x86_aes? ( cpu_flags_x86_sse4_2 ) + cpu_flags_x86_sse4_2? ( cpu_flags_x86_sse4_1 ) + cpu_flags_x86_sse4_1? ( cpu_flags_x86_ssse3 ) + cpu_flags_x86_ssse3? ( cpu_flags_x86_sse3 ) + cpu_flags_x86_sse3? ( cpu_flags_x86_sse2 ) + cpu_flags_x86_sse2? ( cpu_flags_x86_sse ) + cpu_flags_x86_sse? ( cpu_flags_x86_mmxext ) + cpu_flags_x86_mmxext? ( cpu_flags_x86_mmx ) + cpu_flags_x86_3dnowext? ( cpu_flags_x86_3dnow ) + cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx ) +" + +CPU_FEATURES_MAP=( + ${ARM_CPU_FEATURES[@]} + ${PPC_CPU_FEATURES[@]} + ${X86_CPU_FEATURES[@]} +) +IUSE="${IUSE} + ${CPU_FEATURES_MAP[@]%:*}" + +CPU_REQUIRED_USE=" + ${ARM_CPU_REQUIRED_USE} + ${PPC_CPU_REQUIRED_USE} + ${X86_CPU_REQUIRED_USE} +" + +REQUIRED_USE=" + ${CPU_REQUIRED_USE} + || ( cuda libdrm wayland X ) +" + +CDEPEND=" + dev-libs/boost:=[nls] + dev-libs/libevdev + dev-libs/openssl:= + media-libs/libpulse + media-libs/opus + net-libs/miniupnpc:= + net-misc/curl + libdrm? ( + sys-libs/libcap + x11-libs/libdrm + ) + svt-av1? ( media-libs/svt-av1 ) + trayicon? ( + dev-libs/libayatana-appindicator + x11-libs/libnotify + ) + vaapi? ( media-libs/libva:=[wayland?,X?] ) + wayland? ( dev-libs/wayland ) + X? ( x11-libs/libX11 ) + x264? ( media-libs/x264:= ) + x265? ( media-libs/x265:= ) +" + +RDEPEND=" + ${CDEPEND} + media-libs/mesa[vaapi?] + X? ( + x11-libs/libxcb + x11-libs/libXfixes + x11-libs/libXrandr + x11-libs/libXtst + ) +" + +DEPEND=" + ${CDEPEND} + media-libs/amf-headers + wayland? ( dev-libs/wayland-protocols ) +" + +BDEPEND=" + net-libs/nodejs[npm] + virtual/pkgconfig + cpu_flags_x86_mmx? ( || ( >=dev-lang/nasm-2.13 >=dev-lang/yasm-1.3 ) ) + cuda? ( dev-util/nvidia-cuda-toolkit ) + wayland? ( dev-util/wayland-scanner ) +" + +PATCHES=( + "${FILESDIR}"/${P}-vaapi.patch + "${FILESDIR}"/${P}-no-x11.patch + "${FILESDIR}"/${P}-system-deps.patch +) + +# Make this mess a bit simpler. +CMAKE_IN_SOURCE_BUILD=1 + +# Make npm behave. +export npm_config_audit=false +export npm_config_color=false +export npm_config_foreground_scripts=true +export npm_config_loglevel=verbose +export npm_config_progress=false +export npm_config_save=false + +src_unpack() { + if [[ ${PV} = 9999* ]]; then + local EGIT_REPO_URI="https://github.com/LizardByte/build-deps.git" + local EGIT_SUBMODULES=( '-*' ) + local EGIT_CHECKOUT_DIR=${WORKDIR}/build-deps + git-r3_src_unpack + + # Use upstream server like our ffmpeg package does, not GitHub. + local EGIT_REPO_URI="https://git.ffmpeg.org/ffmpeg.git" + local EGIT_SUBMODULES=( '-*' ) + local EGIT_CHECKOUT_DIR=${EGIT_CHECKOUT_DIR}/ffmpeg_sources/ffmpeg + local EGIT_COMMIT=$(git --git-dir=build-deps/.git rev-parse HEAD:ffmpeg_sources/ffmpeg) + local EGIT_BRANCH=release/$(ver_cut 1-2 ${FFMPEG_VERSION}) + git-r3_src_unpack + + local EGIT_REPO_URI="https://github.com/LizardByte/Sunshine.git" + local EGIT_SUBMODULES=( + third-party/{moonlight-common-c{,/enet},nanors,nv-codec-headers,tray,Simple-Web-Server,wlr-protocols} + ) + unset EGIT_CHECKOUT_DIR EGIT_COMMIT EGIT_BRANCH + git-r3_src_unpack + + # This downloads things so must go in src_unpack to avoid the sandbox. + cd "${S}" || die + npm install || die + else + default + ln -snf build-deps-${BUILD_DEPS_COMMIT} build-deps || die + find moonlight-common-c-${MOONLIGHT_COMMIT} "${S}"/third-party build-deps/ffmpeg_sources \ + -mindepth 1 -type d -empty -delete || die + ln -snf ../enet-${ENET_COMMIT} moonlight-common-c-${MOONLIGHT_COMMIT}/enet || die + ln -snf ../../moonlight-common-c-${MOONLIGHT_COMMIT} "${S}"/third-party/moonlight-common-c || die + ln -snf ../../nanors-${NANORS_COMMIT} "${S}"/third-party/nanors || die + ln -snf ../../nv-codec-headers-${NV_CODEC_COMMIT} "${S}"/third-party/nv-codec-headers || die + ln -snf ../../tray-${TRAY_COMMIT} "${S}"/third-party/tray || die + ln -snf ../../Simple-Web-Server-${SWS_COMMIT} "${S}"/third-party/Simple-Web-Server || die + ln -snf ../../wlr-protocols-${WLRP_COMMIT} "${S}"/third-party/wlr-protocols || die + ln -snf ../../ffmpeg-${FFMPEG_VERSION} build-deps/ffmpeg_sources/ffmpeg || die + fi +} + +src_prepare() { + # Apply general ffmpeg patches. + cd "${WORKDIR}"/build-deps/ffmpeg_sources/ffmpeg || die + eapply "${WORKDIR}"/build-deps/ffmpeg_patches/ffmpeg/*.patch + + # Copy ffmpeg sources because CBS build applies extra patches. + cp -a ./ "${WORKDIR}"/ffmpeg-build || die + + cd "${S}" || die + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_prepare + default_src_prepare() { :; } # Hack to avoid double patching! :( + CMAKE_USE_DIR="${S}" cmake_src_prepare +} + +src_configure() { + local myconf=( + --prefix="${S}"/third-party/ffmpeg + --cc="$(tc-getCC)" + --cxx="$(tc-getCXX)" + --ar="$(tc-getAR)" + --nm="$(tc-getNM)" + --strip="$(tc-getSTRIP)" + --ranlib="$(tc-getRANLIB)" + --pkg-config="$(tc-getPKG_CONFIG)" + --optflags="${CFLAGS}" + --disable-all + --disable-autodetect + --disable-error-resilience + --disable-everything + --disable-faan + --disable-iconv + --disable-network + --disable-optimizations + --disable-stripping + --enable-amf + --enable-avcodec + --enable-ffnvcodec + --enable-gpl + --enable-nvenc + --enable-static + --enable-swscale + --enable-v4l2_m2m + $(use_enable cuda) + $(use_enable cuda cuda_llvm) + $(use_enable svt-av1 libsvtav1) + $(use_enable vaapi) + $(use_enable x264 libx264) + $(use_enable x265 libx265) + $(usex svt-av1 --enable-encoder=libsvtav1 "") + $(usex vaapi --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi "") + $(usex x264 --enable-encoder=libx264 "") + $(usex x265 --enable-encoder=libx265 "") + --enable-encoder=h264_amf,hevc_amf,av1_amf + --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc + --enable-encoder=h264_v4l2m2m,hevc_v4l2m2m + ) + + # CPU features + for i in "${CPU_FEATURES_MAP[@]}" ; do + use ${i%:*} || myconf+=( --disable-${i#*:} ) + done + # Bug #917277, #917278 + myconf+=( --disable-dotprod --disable-i8mm ) + + # Try to get cpu type based on CFLAGS. + # Bug #172723 + # We need to do this so that features of that CPU will be better used + # If they contain an unknown CPU it will not hurt since ffmpeg's configure + # will just ignore it. + for i in $(get-flag mcpu) $(get-flag march) ; do + [[ ${i} = native ]] && i="host" # bug #273421 + myconf+=( --cpu=${i} ) + break + done + + # cross compile support + if tc-is-cross-compiler ; then + myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- --host-cc="$(tc-getBUILD_CC)" ) + case ${CHOST} in + *mingw32*) + myconf+=( --target-os=mingw32 ) + ;; + *linux*) + myconf+=( --target-os=linux ) + ;; + esac + fi + + cd "${WORKDIR}"/ffmpeg-build || die + echo ./configure "${myconf[@]}" + ./configure "${myconf[@]}" || die + + local mycmakeargs=( + -DBUILD_SHARED_LIBS=no + -DCMAKE_INSTALL_PREFIX="${S}"/third-party/ffmpeg + $(usex arm64 -DCROSS_COMPILE_ARM=yes "") + $(usex ppc64 -DCROSS_COMPILE_PPC=yes "") + ) + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_configure + + local mycmakeargs=( + -DCMAKE_DISABLE_FIND_PACKAGE_Git=yes + -DFFMPEG_PLATFORM_LIBRARIES="$(usex svt-av1 SvtAv1Enc '');$(usex vaapi 'va;va-drm' '');$(usev x264);$(usev x265)" + -DFFMPEG_PREPARED_BINARIES="${S}"/third-party/ffmpeg + -DSUNSHINE_ASSETS_DIR=share/${PN} + -DSUNSHINE_ENABLE_CUDA=$(usex cuda) + -DSUNSHINE_ENABLE_DRM=$(usex libdrm) + -DSUNSHINE_ENABLE_WAYLAND=$(usex wayland) + -DSUNSHINE_ENABLE_X11=$(usex X) + -DSUNSHINE_ENABLE_TRAY=$(usex trayicon) + -DSUNSHINE_REQUIRE_TRAY=$(usex trayicon) + -DSUNSHINE_SYSTEM_MINIUPNP=yes + -DSUNSHINE_SYSTEM_WAYLAND_PROTOCOLS=yes + ) + CMAKE_USE_DIR="${S}" cmake_src_configure +} + +src_compile() { + emake -C "${WORKDIR}"/ffmpeg-build V=1 + emake -C "${WORKDIR}"/ffmpeg-build V=1 install + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_compile + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_build install + CMAKE_USE_DIR="${S}" npm_config_offline=1 cmake_src_compile +} + +pkg_postinst() { + udev_reload + xdg_pkg_postinst + use libdrm && fcaps cap_sys_admin+p usr/bin/"$(readlink "${EROOT}"/usr/bin/${PN})" + + elog "At upstream's request, please report any issues to https://bugs.gentoo.org" + elog "rather than going directly to them." +} + +pkg_postrm() { + udev_reload + xdg_pkg_postrm +} diff --git a/net-misc/sunshine/sunshine-9999.ebuild b/net-misc/sunshine/sunshine-9999.ebuild new file mode 100644 index 000000000000..2a51de91c8f3 --- /dev/null +++ b/net-misc/sunshine/sunshine-9999.ebuild @@ -0,0 +1,377 @@ +# Copyright 1999-2024 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# These don't necessarily have to align with the upstream release. +# We do have nv-codec-headers packaged, but Sunshine is very picky here. +BUILD_DEPS_COMMIT="2aafe061cd52a944cb3b5f86d1f25e9ad2a19bec" +ENET_COMMIT="c6bb0e50118d08252eee308de8412751218442d6" +MOONLIGHT_COMMIT="6e9ed871bc3e013386c775b2ee7d31deb1151068" +NANORS_COMMIT="e9e242e98e27037830490b2a752895ca68f75f8b" +NV_CODEC_COMMIT="22441b505d9d9afc1e3002290820909846c24bdc" +TRAY_COMMIT="e08bdbe5aa7de0ad9c0ce36257016e07c7e6e2c0" +SWS_COMMIT="27b41f5ee154cca0fce4fe2955dd886d04e3a4ed" +WLRP_COMMIT="4264185db3b7e961e7f157e1cc4fd0ab75137568" +FFMPEG_VERSION="6.1.1" + +# To make the node-modules tarball: +# PV= +# git fetch +# git checkout v$PV +# rm -rf node_modules +# npm install +# XZ_OPT=-9 tar --xform="s:^:Sunshine-$PV/:" -Jcf /var/cache/distfiles/sunshine-node-modules-$PV.tar.xz node_modules + +if [[ ${PV} = 9999* ]]; then + inherit git-r3 +else + SRC_URI=" + https://github.com/LizardByte/Sunshine/archive/refs/tags/v${PV}.tar.gz + -> ${P}.tar.gz + https://github.com/LizardByte/build-deps/archive/${BUILD_DEPS_COMMIT}.tar.gz + -> LizardByte-build-deps-${BUILD_DEPS_COMMIT}.tar.gz + https://github.com/cgutman/enet/archive/${ENET_COMMIT}.tar.gz + -> moonlight-enet-${ENET_COMMIT}.tar.gz + https://github.com/moonlight-stream/moonlight-common-c/archive/${MOONLIGHT_COMMIT}.tar.gz + -> moonlight-common-c-${MOONLIGHT_COMMIT}.tar.gz + https://github.com/sleepybishop/nanors/archive/${NANORS_COMMIT}.tar.gz + -> nanors-${NANORS_COMMIT}.tar.gz + https://github.com/FFmpeg/nv-codec-headers/archive/${NV_CODEC_COMMIT}.tar.gz + -> nv-codec-headers-${NV_CODEC_COMMIT}.tar.gz + https://github.com/LizardByte/tray/archive/${TRAY_COMMIT}.tar.gz + -> LizardByte-tray-${TRAY_COMMIT}.tar.gz + https://gitlab.com/eidheim/Simple-Web-Server/-/archive/${SWS_COMMIT}/Simple-Web-Server-${SWS_COMMIT}.tar.bz2 + https://gitlab.freedesktop.org/wlroots/wlr-protocols/-/archive/${WLRP_COMMIT}/wlr-protocols-${WLRP_COMMIT}.tar.bz2 + https://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.xz + https://dev.gentoo.org/~chewi/distfiles/${PN}-node-modules-${PV}.tar.xz + " + KEYWORDS="~amd64 ~arm64" + S="${WORKDIR}/Sunshine-${PV}" +fi + +inherit cmake fcaps flag-o-matic systemd toolchain-funcs udev xdg + +DESCRIPTION="Self-hosted game stream host for Moonlight" +HOMEPAGE="https://github.com/LizardByte/Sunshine" +LICENSE="GPL-3" +SLOT="0" +IUSE="cuda debug libdrm svt-av1 trayicon vaapi wayland X x264 x265" + +# Strings for CPU features in the useflag[:configure_option] form +# if :configure_option isn't set, it will use 'useflag' as configure option +ARM_CPU_FEATURES=( + cpu_flags_arm_thumb:armv5te + cpu_flags_arm_v6:armv6 + cpu_flags_arm_thumb2:armv6t2 + cpu_flags_arm_neon:neon + cpu_flags_arm_vfp:vfp + cpu_flags_arm_vfpv3:vfpv3 + cpu_flags_arm_v8:armv8 +) +ARM_CPU_REQUIRED_USE=" + arm64? ( cpu_flags_arm_v8 ) + cpu_flags_arm_v8? ( cpu_flags_arm_vfpv3 cpu_flags_arm_neon ) + cpu_flags_arm_neon? ( + cpu_flags_arm_vfp + arm? ( cpu_flags_arm_thumb2 ) + ) + cpu_flags_arm_vfpv3? ( cpu_flags_arm_vfp ) + cpu_flags_arm_thumb2? ( cpu_flags_arm_v6 ) + cpu_flags_arm_v6? ( + arm? ( cpu_flags_arm_thumb ) + ) +" +PPC_CPU_FEATURES=( cpu_flags_ppc_altivec:altivec cpu_flags_ppc_vsx:vsx cpu_flags_ppc_vsx2:power8 ) +PPC_CPU_REQUIRED_USE=" + cpu_flags_ppc_vsx? ( cpu_flags_ppc_altivec ) + cpu_flags_ppc_vsx2? ( cpu_flags_ppc_vsx ) +" +X86_CPU_FEATURES_RAW=( 3dnow:amd3dnow 3dnowext:amd3dnowext aes:aesni avx:avx avx2:avx2 fma3:fma3 fma4:fma4 mmx:mmx + mmxext:mmxext sse:sse sse2:sse2 sse3:sse3 ssse3:ssse3 sse4_1:sse4 sse4_2:sse42 xop:xop ) +X86_CPU_FEATURES=( ${X86_CPU_FEATURES_RAW[@]/#/cpu_flags_x86_} ) +X86_CPU_REQUIRED_USE=" + cpu_flags_x86_avx2? ( cpu_flags_x86_avx ) + cpu_flags_x86_fma4? ( cpu_flags_x86_avx ) + cpu_flags_x86_fma3? ( cpu_flags_x86_avx ) + cpu_flags_x86_xop? ( cpu_flags_x86_avx ) + cpu_flags_x86_avx? ( cpu_flags_x86_sse4_2 ) + cpu_flags_x86_aes? ( cpu_flags_x86_sse4_2 ) + cpu_flags_x86_sse4_2? ( cpu_flags_x86_sse4_1 ) + cpu_flags_x86_sse4_1? ( cpu_flags_x86_ssse3 ) + cpu_flags_x86_ssse3? ( cpu_flags_x86_sse3 ) + cpu_flags_x86_sse3? ( cpu_flags_x86_sse2 ) + cpu_flags_x86_sse2? ( cpu_flags_x86_sse ) + cpu_flags_x86_sse? ( cpu_flags_x86_mmxext ) + cpu_flags_x86_mmxext? ( cpu_flags_x86_mmx ) + cpu_flags_x86_3dnowext? ( cpu_flags_x86_3dnow ) + cpu_flags_x86_3dnow? ( cpu_flags_x86_mmx ) +" + +CPU_FEATURES_MAP=( + ${ARM_CPU_FEATURES[@]} + ${PPC_CPU_FEATURES[@]} + ${X86_CPU_FEATURES[@]} +) +IUSE="${IUSE} + ${CPU_FEATURES_MAP[@]%:*}" + +CPU_REQUIRED_USE=" + ${ARM_CPU_REQUIRED_USE} + ${PPC_CPU_REQUIRED_USE} + ${X86_CPU_REQUIRED_USE} +" + +REQUIRED_USE=" + ${CPU_REQUIRED_USE} + || ( cuda libdrm wayland X ) +" + +CDEPEND=" + dev-libs/boost:=[nls] + dev-libs/libevdev + dev-libs/openssl:= + media-libs/libpulse + media-libs/opus + net-libs/miniupnpc:= + net-misc/curl + libdrm? ( + sys-libs/libcap + x11-libs/libdrm + ) + svt-av1? ( media-libs/svt-av1 ) + trayicon? ( + dev-libs/libayatana-appindicator + x11-libs/libnotify + ) + vaapi? ( media-libs/libva:=[wayland?,X?] ) + wayland? ( dev-libs/wayland ) + X? ( x11-libs/libX11 ) + x264? ( media-libs/x264:= ) + x265? ( media-libs/x265:= ) +" + +RDEPEND=" + ${CDEPEND} + media-libs/mesa[vaapi?] + X? ( + x11-libs/libxcb + x11-libs/libXfixes + x11-libs/libXrandr + x11-libs/libXtst + ) +" + +DEPEND=" + ${CDEPEND} + dev-cpp/nlohmann_json + media-libs/amf-headers + wayland? ( dev-libs/wayland-protocols ) +" + +BDEPEND=" + net-libs/nodejs[npm] + virtual/pkgconfig + cpu_flags_x86_mmx? ( || ( >=dev-lang/nasm-2.13 >=dev-lang/yasm-1.3 ) ) + cuda? ( dev-util/nvidia-cuda-toolkit ) + wayland? ( dev-util/wayland-scanner ) +" + +PATCHES=( + "${FILESDIR}"/${PN}-custom-ffmpeg.patch + "${FILESDIR}"/${PN}-system-json.patch +) + +# Make this mess a bit simpler. +CMAKE_IN_SOURCE_BUILD=1 + +# Make npm behave. +export npm_config_audit=false +export npm_config_color=false +export npm_config_foreground_scripts=true +export npm_config_loglevel=verbose +export npm_config_progress=false +export npm_config_save=false + +src_unpack() { + if [[ ${PV} = 9999* ]]; then + local EGIT_REPO_URI="https://github.com/LizardByte/build-deps.git" + local EGIT_SUBMODULES=( '-*' ) + local EGIT_CHECKOUT_DIR=${WORKDIR}/build-deps + git-r3_src_unpack + + # Use upstream server like our ffmpeg package does, not GitHub. + local EGIT_REPO_URI="https://git.ffmpeg.org/ffmpeg.git" + local EGIT_SUBMODULES=( '-*' ) + local EGIT_CHECKOUT_DIR=${EGIT_CHECKOUT_DIR}/ffmpeg_sources/ffmpeg + local EGIT_COMMIT=$(git --git-dir=build-deps/.git rev-parse HEAD:ffmpeg_sources/ffmpeg) + local EGIT_BRANCH=release/$(ver_cut 1-2 ${FFMPEG_VERSION}) + git-r3_src_unpack + + local EGIT_REPO_URI="https://github.com/LizardByte/Sunshine.git" + local EGIT_SUBMODULES=( + third-party/{moonlight-common-c{,/enet},nanors,nv-codec-headers,tray,Simple-Web-Server,wlr-protocols} + ) + unset EGIT_CHECKOUT_DIR EGIT_COMMIT EGIT_BRANCH + git-r3_src_unpack + + # This downloads things so must go in src_unpack to avoid the sandbox. + cd "${S}" || die + npm install || die + else + default + ln -snf build-deps-${BUILD_DEPS_COMMIT} build-deps || die + find moonlight-common-c-${MOONLIGHT_COMMIT} "${S}"/third-party build-deps/ffmpeg_sources \ + -mindepth 1 -type d -empty -delete || die + ln -snf ../enet-${ENET_COMMIT} moonlight-common-c-${MOONLIGHT_COMMIT}/enet || die + ln -snf ../../moonlight-common-c-${MOONLIGHT_COMMIT} "${S}"/third-party/moonlight-common-c || die + ln -snf ../../nanors-${NANORS_COMMIT} "${S}"/third-party/nanors || die + ln -snf ../../nv-codec-headers-${NV_CODEC_COMMIT} "${S}"/third-party/nv-codec-headers || die + ln -snf ../../tray-${TRAY_COMMIT} "${S}"/third-party/tray || die + ln -snf ../../Simple-Web-Server-${SWS_COMMIT} "${S}"/third-party/Simple-Web-Server || die + ln -snf ../../wlr-protocols-${WLRP_COMMIT} "${S}"/third-party/wlr-protocols || die + ln -snf ../../ffmpeg-${FFMPEG_VERSION} build-deps/ffmpeg_sources/ffmpeg || die + fi +} + +src_prepare() { + # Apply general ffmpeg patches. + cd "${WORKDIR}"/build-deps/ffmpeg_sources/ffmpeg || die + eapply "${WORKDIR}"/build-deps/ffmpeg_patches/ffmpeg/*.patch + + # Copy ffmpeg sources because CBS build applies extra patches. + cp -a ./ "${WORKDIR}"/ffmpeg-build || die + + cd "${S}" || die + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_prepare + default_src_prepare() { :; } # Hack to avoid double patching! :( + CMAKE_USE_DIR="${S}" cmake_src_prepare +} + +src_configure() { + local myconf=( + --prefix="${S}"/third-party/ffmpeg + --cc="$(tc-getCC)" + --cxx="$(tc-getCXX)" + --ar="$(tc-getAR)" + --nm="$(tc-getNM)" + --strip="$(tc-getSTRIP)" + --ranlib="$(tc-getRANLIB)" + --pkg-config="$(tc-getPKG_CONFIG)" + --optflags="${CFLAGS}" + --disable-all + --disable-autodetect + --disable-error-resilience + --disable-everything + --disable-faan + --disable-iconv + --disable-network + --disable-optimizations + --disable-stripping + --enable-amf + --enable-avcodec + --enable-ffnvcodec + --enable-gpl + --enable-nvenc + --enable-static + --enable-swscale + --enable-v4l2_m2m + $(use_enable cuda) + $(use_enable cuda cuda_llvm) + $(use_enable svt-av1 libsvtav1) + $(use_enable vaapi) + $(use_enable x264 libx264) + $(use_enable x265 libx265) + $(usex svt-av1 --enable-encoder=libsvtav1 "") + $(usex vaapi --enable-encoder=h264_vaapi,hevc_vaapi,av1_vaapi "") + $(usex x264 --enable-encoder=libx264 "") + $(usex x265 --enable-encoder=libx265 "") + --enable-encoder=h264_amf,hevc_amf,av1_amf + --enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc + --enable-encoder=h264_v4l2m2m,hevc_v4l2m2m + ) + + # CPU features + for i in "${CPU_FEATURES_MAP[@]}" ; do + use ${i%:*} || myconf+=( --disable-${i#*:} ) + done + # Bug #917277, #917278 + myconf+=( --disable-dotprod --disable-i8mm ) + + # Try to get cpu type based on CFLAGS. + # Bug #172723 + # We need to do this so that features of that CPU will be better used + # If they contain an unknown CPU it will not hurt since ffmpeg's configure + # will just ignore it. + for i in $(get-flag mcpu) $(get-flag march) ; do + [[ ${i} = native ]] && i="host" # bug #273421 + myconf+=( --cpu=${i} ) + break + done + + # cross compile support + if tc-is-cross-compiler ; then + myconf+=( --enable-cross-compile --arch=$(tc-arch-kernel) --cross-prefix=${CHOST}- --host-cc="$(tc-getBUILD_CC)" ) + case ${CHOST} in + *mingw32*) + myconf+=( --target-os=mingw32 ) + ;; + *linux*) + myconf+=( --target-os=linux ) + ;; + esac + fi + + cd "${WORKDIR}"/ffmpeg-build || die + echo ./configure "${myconf[@]}" + ./configure "${myconf[@]}" || die + + local mycmakeargs=( + -DBUILD_SHARED_LIBS=no + -DCMAKE_INSTALL_PREFIX="${S}"/third-party/ffmpeg + $(usex arm64 -DCROSS_COMPILE_ARM=yes "") + $(usex ppc64 -DCROSS_COMPILE_PPC=yes "") + ) + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_configure + + local mycmakeargs=( + -DCMAKE_DISABLE_FIND_PACKAGE_Git=yes + -DFFMPEG_PLATFORM_LIBRARIES="$(usex svt-av1 SvtAv1Enc '');$(usex vaapi 'va;va-drm' '');$(usev x264);$(usev x265)" + -DFFMPEG_PREPARED_BINARIES="${S}"/third-party/ffmpeg + -DSUNSHINE_ASSETS_DIR=share/${PN} + -DSUNSHINE_ENABLE_CUDA=$(usex cuda) + -DSUNSHINE_ENABLE_DRM=$(usex libdrm) + -DSUNSHINE_ENABLE_VAAPI=$(usex vaapi) + -DSUNSHINE_ENABLE_WAYLAND=$(usex wayland) + -DSUNSHINE_ENABLE_X11=$(usex X) + -DSUNSHINE_ENABLE_TRAY=$(usex trayicon) + -DSUNSHINE_REQUIRE_TRAY=$(usex trayicon) + -DSUNSHINE_SYSTEM_NLOHMANN_JSON=yes + -DSUNSHINE_SYSTEM_WAYLAND_PROTOCOLS=yes + -DSYSTEMD_USER_UNIT_INSTALL_DIR=$(systemd_get_userunitdir) + -DUDEV_RULES_INSTALL_DIR=$(get_udevdir)/rules.d + ) + CMAKE_USE_DIR="${S}" cmake_src_configure +} + +src_compile() { + emake -C "${WORKDIR}"/ffmpeg-build V=1 + emake -C "${WORKDIR}"/ffmpeg-build V=1 install + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_src_compile + CMAKE_USE_DIR="${WORKDIR}/build-deps" cmake_build install + CMAKE_USE_DIR="${S}" npm_config_offline=1 cmake_src_compile +} + +pkg_postinst() { + udev_reload + xdg_pkg_postinst + use libdrm && fcaps cap_sys_admin+p usr/bin/"$(readlink "${EROOT}"/usr/bin/${PN})" + + elog "At upstream's request, please report any issues to https://bugs.gentoo.org" + elog "rather than going directly to them." +} + +pkg_postrm() { + udev_reload + xdg_pkg_postrm +} |