build(linux): add homebrew support (#2667)

This commit is contained in:
ReenigneArcher 2024-06-12 15:58:25 -04:00 committed by GitHub
parent e1f0ca829d
commit f68de7da93
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 148 additions and 36 deletions

View File

@ -95,18 +95,18 @@ body:
- Linux - deb
- Linux - Docker
- Linux - flatpak
- Linux - Homebrew
- Linux - nixpkgs (Third Party)
- Linux - PKGBUILD
- Linux - pkg.tar.zst
- Linux - rpm
- Linux - solus (Third Party)
- macOS - dmg
- macOS - Homebrew
- macOS - Portfile
- Windows - Chocolatey (Third Party)
- Windows - installer
- Windows - portable
- Windows - Scoop (Third Party)
- Windows - Winget (Third Party)
- Windows - Winget
- other (not listed)
- other (self built)
- other (fork of this repo)

View File

@ -482,7 +482,7 @@ jobs:
tag: ${{ needs.setup_release.outputs.release_tag }}
token: ${{ secrets.GH_BOT_TOKEN }}
build_mac_brew:
build_homebrew:
needs: [setup_release]
strategy:
fail-fast: false # false to test all, true to fail entire job if any fail
@ -491,21 +491,21 @@ jobs:
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
# while GitHub has larger macOS runners, they are not available for our repos :(
- os_version: "12"
release: true
os_name: "macos"
- os_version: "13"
os_name: "macos"
- os_version: "14"
name: Homebrew (macOS-${{ matrix.os_version }})
runs-on: macos-${{ matrix.os_version }}
os_name: "macos"
- os_version: "latest"
os_name: "ubuntu"
release: true
name: Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }})
runs-on: ${{ matrix.os_name }}-${{ matrix.os_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Dependencies Homebrew
run: |
# install dependencies using homebrew
brew install cmake
- name: Configure formula
run: |
# variables for formula
@ -556,8 +556,20 @@ jobs:
name: sunshine-homebrew
path: homebrew/
- name: Setup Xvfb
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update -y
sudo apt-get install -y \
xvfb
export DISPLAY=:1
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
echo "DISPLAY=${DISPLAY}" >> $GITHUB_ENV
- name: Validate Homebrew Formula
uses: LizardByte/homebrew-release-action@v2024.609.4731
uses: LizardByte/homebrew-release-action@v2024.612.21058
with:
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
git_email: ${{ secrets.GH_BOT_EMAIL }}

View File

@ -117,14 +117,42 @@ elseif(NOT LIBDRM_FOUND)
endif()
# evdev
pkg_check_modules(PC_EVDEV libevdev REQUIRED)
find_path(EVDEV_INCLUDE_DIR libevdev/libevdev.h
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR})
find_library(EVDEV_LIBRARY
NAMES evdev libevdev)
pkg_check_modules(PC_EVDEV libevdev)
if(PC_EVDEV_FOUND)
find_path(EVDEV_INCLUDE_DIR libevdev/libevdev.h
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR})
find_library(EVDEV_LIBRARY
NAMES evdev libevdev)
else()
include(ExternalProject)
set(LIBEVDEV_VERSION libevdev-1.13.2)
ExternalProject_Add(libevdev
URL http://www.freedesktop.org/software/libevdev/${LIBEVDEV_VERSION}.tar.xz
PREFIX ${LIBEVDEV_VERSION}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
BUILD_COMMAND "make"
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(libevdev SOURCE_DIR)
message(STATUS "libevdev source dir: ${SOURCE_DIR}")
set(EVDEV_INCLUDE_DIR "${SOURCE_DIR}")
ExternalProject_Get_Property(libevdev BINARY_DIR)
message(STATUS "libevdev binary dir: ${BINARY_DIR}")
set(EVDEV_LIBRARY "${BINARY_DIR}/libevdev/.libs/libevdev.a")
# compile libevdev before sunshine
set(SUNSHINE_TARGET_DEPENDENCIES ${SUNSHINE_TARGET_DEPENDENCIES} libevdev)
endif()
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
else()
message(FATAL_ERROR "Couldn't find or fetch libevdev")
endif()
# vaapi
@ -226,7 +254,7 @@ else()
message(STATUS "Tray icon disabled")
endif()
if (${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
if(${SUNSHINE_ENABLE_TRAY} AND ${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
message(FATAL_ERROR "Tray icon is required")
endif()
@ -253,5 +281,4 @@ list(APPEND PLATFORM_LIBRARIES
include_directories(
SYSTEM
"${CMAKE_SOURCE_DIR}/third-party/nv-codec-headers/include"
"${CMAKE_SOURCE_DIR}/third-party/glad/include")

View File

@ -25,7 +25,8 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES)
set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl)
elseif(UNIX AND NOT APPLE)
set(FFMPEG_PLATFORM_LIBRARIES numa va va-drm va-x11 vdpau X11)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
# TODO: remove mfx, it's not used and deprecated
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT SUNSHINE_BUILD_HOMEBREW)
list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx)
set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,")
set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,")

View File

@ -20,14 +20,13 @@ option(CUDA_INHERIT_COMPILE_OPTIONS
your IDE throws errors about unknown flags after running cmake." ON)
if(UNIX)
# technically, the homebrew build could be on linux as well... no idea if it would actually work
option(SUNSHINE_BUILD_HOMEBREW
"Enable a Homebrew build." OFF)
option(SUNSHINE_CONFIGURE_HOMEBREW
"Configure Homebrew formula. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
endif ()
if(APPLE)
option(SUNSHINE_CONFIGURE_HOMEBREW
"Configure macOS Homebrew formula. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
option(SUNSHINE_CONFIGURE_PORTFILE
"Configure macOS Portfile. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
option(SUNSHINE_PACKAGE_MACOS

View File

@ -1,11 +1,14 @@
if (APPLE)
if(UNIX)
if(${SUNSHINE_CONFIGURE_HOMEBREW})
configure_file(packaging/sunshine.rb sunshine.rb @ONLY)
endif()
endif()
if(APPLE)
if(${SUNSHINE_CONFIGURE_PORTFILE})
configure_file(packaging/macos/Portfile Portfile @ONLY)
endif()
if(${SUNSHINE_CONFIGURE_HOMEBREW})
configure_file(packaging/macos/sunshine.rb sunshine.rb @ONLY)
endif()
elseif (UNIX)
elseif(UNIX)
# configure the .desktop file
if(${SUNSHINE_BUILD_APPIMAGE})
configure_file(packaging/linux/AppImage/sunshine.desktop sunshine.desktop @ONLY)

View File

@ -2,6 +2,9 @@
# this file will also load platform specific macros
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
foreach(dep ${SUNSHINE_TARGET_DEPENDENCIES})
add_dependencies(sunshine ${dep}) # compile these before sunshine
endforeach()
# platform specific target definitions
if(WIN32)

View File

@ -168,6 +168,18 @@ Install
flatpak run --command=remove-additional-install.sh dev.lizardbyte.sunshine
flatpak uninstall --delete-data dev.lizardbyte.sunshine
.. tab:: Homebrew
.. important:: The Homebrew package is experimental.
#. Install `Homebrew <https://docs.brew.sh/Installation>`__
#. Update the Homebrew sources and install Sunshine.
.. code-block:: bash
brew tap LizardByte/homebrew
brew install sunshine
.. tab:: RPM Package
#. Add `rpmfusion` repositories by running the following code.

View File

@ -9,6 +9,18 @@ class @PROJECT_NAME@ < Formula
license all_of: ["GPL-3.0-only"]
head "@GITHUB_CLONE_URL@", branch: "@GITHUB_DEFAULT_BRANCH@"
# https://docs.brew.sh/Brew-Livecheck#githublatest-strategy-block
livecheck do
url :stable
regex(/^v?(\d+\.\d+\.\d+)$/i)
strategy :github_latest do |json, regex|
match = json["tag_name"]&.match(regex)
next if match.blank?
match[1]
end
end
depends_on "boost" => :build
depends_on "cmake" => :build
depends_on "node" => :build
@ -18,6 +30,26 @@ class @PROJECT_NAME@ < Formula
depends_on "openssl"
depends_on "opus"
on_linux do
depends_on "libcap"
depends_on "libdrm"
depends_on "libnotify"
depends_on "libva"
depends_on "libvdpau"
depends_on "libx11"
depends_on "libxcb"
depends_on "libxcursor"
depends_on "libxfixes"
depends_on "libxi"
depends_on "libxinerama"
depends_on "libxrandr"
depends_on "libxtst"
depends_on "numactl"
depends_on "pulseaudio"
depends_on "systemd"
depends_on "wayland"
end
def install
ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
@ -26,18 +58,23 @@ class @PROJECT_NAME@ < Formula
args = %W[
-DBUILD_WERROR=ON
-DCMAKE_INSTALL_PREFIX=#{prefix}
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
-DSUNSHINE_ASSETS_DIR=sunshine/assets
-DSUNSHINE_BUILD_HOMEBREW=ON
-DSUNSHINE_ENABLE_TRAY=OFF
-DTESTS_ENABLE_PYTHON_TESTS=OFF
]
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
cd "build" do
system "make", "-j"
system "make"
system "make", "install"
bin.install "tests/test_sunshine"
end
bin.install "src_assets/linux/misc/postinst" if OS.linux?
end
service do
@ -45,17 +82,30 @@ class @PROJECT_NAME@ < Formula
end
def caveats
<<~EOS
caveats_message = <<~EOS
Thanks for installing @PROJECT_NAME@!
To get started, review the documentation at:
https://docs.lizardbyte.dev/projects/sunshine/en/latest/
Sunshine can only access microphones on macOS due to system limitations.
To stream system audio use "Soundflower" or "BlackHole".
Gamepads are not currently supported on macOS.
EOS
if OS.linux?
caveats_message += <<~EOS
ATTENTION: To complete installation, you must run the following command:
`sudo #{bin}/postinst`
EOS
end
if OS.mac?
caveats_message += <<~EOS
Sunshine can only access microphones on macOS due to system limitations.
To stream system audio use "Soundflower" or "BlackHole".
Gamepads are not currently supported on macOS.
EOS
end
caveats_message
end
test do

View File

@ -107,6 +107,11 @@ list(REMOVE_ITEM SUNSHINE_SOURCES ${CMAKE_SOURCE_DIR}/src/main.cpp)
add_executable(${PROJECT_NAME}
${TEST_SOURCES}
${SUNSHINE_SOURCES})
foreach(dep ${SUNSHINE_TARGET_DEPENDENCIES})
add_dependencies(${PROJECT_NAME} ${dep}) # compile these before sunshine
endforeach()
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
target_link_libraries(${PROJECT_NAME}
${SUNSHINE_EXTERNAL_LIBRARIES}