Skip to content

Commit cfea7ff

Browse files
ReenigneArcherKuleRucket
authored andcommitted
build(linux): add homebrew support (LizardByte#2667)
1 parent 77229ae commit cfea7ff

File tree

10 files changed

+147
-35
lines changed

10 files changed

+147
-35
lines changed

.github/ISSUE_TEMPLATE/bug-report.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,18 @@ body:
9595
- Linux - deb
9696
- Linux - Docker
9797
- Linux - flatpak
98+
- Linux - Homebrew
9899
- Linux - nixpkgs (Third Party)
99100
- Linux - PKGBUILD
100101
- Linux - pkg.tar.zst
101102
- Linux - rpm
102-
- Linux - solus (Third Party)
103-
- macOS - dmg
103+
- macOS - Homebrew
104104
- macOS - Portfile
105105
- Windows - Chocolatey (Third Party)
106106
- Windows - installer
107107
- Windows - portable
108108
- Windows - Scoop (Third Party)
109-
- Windows - Winget (Third Party)
109+
- Windows - Winget
110110
- other (not listed)
111111
- other (self built)
112112
- other (fork of this repo)

.github/workflows/CI.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ jobs:
482482
tag: ${{ needs.setup_release.outputs.release_tag }}
483483
token: ${{ secrets.GH_BOT_TOKEN }}
484484

485-
build_mac_brew:
485+
build_homebrew:
486486
needs: [setup_release]
487487
strategy:
488488
fail-fast: false # false to test all, true to fail entire job if any fail
@@ -491,21 +491,21 @@ jobs:
491491
# 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
492492
# while GitHub has larger macOS runners, they are not available for our repos :(
493493
- os_version: "12"
494-
release: true
494+
os_name: "macos"
495495
- os_version: "13"
496+
os_name: "macos"
496497
- os_version: "14"
497-
name: Homebrew (macOS-${{ matrix.os_version }})
498-
runs-on: macos-${{ matrix.os_version }}
498+
os_name: "macos"
499+
- os_version: "latest"
500+
os_name: "ubuntu"
501+
release: true
502+
name: Homebrew (${{ matrix.os_name }}-${{ matrix.os_version }})
503+
runs-on: ${{ matrix.os_name }}-${{ matrix.os_version }}
499504

500505
steps:
501506
- name: Checkout
502507
uses: actions/checkout@v4
503508

504-
- name: Setup Dependencies Homebrew
505-
run: |
506-
# install dependencies using homebrew
507-
brew install cmake
508-
509509
- name: Configure formula
510510
run: |
511511
# variables for formula
@@ -556,8 +556,20 @@ jobs:
556556
name: sunshine-homebrew
557557
path: homebrew/
558558

559+
- name: Setup Xvfb
560+
if: ${{ runner.os == 'Linux' }}
561+
run: |
562+
sudo apt-get update -y
563+
sudo apt-get install -y \
564+
xvfb
565+
566+
export DISPLAY=:1
567+
Xvfb ${DISPLAY} -screen 0 1024x768x24 &
568+
569+
echo "DISPLAY=${DISPLAY}" >> $GITHUB_ENV
570+
559571
- name: Validate Homebrew Formula
560-
uses: LizardByte/homebrew-release-action@v2024.609.4731
572+
uses: LizardByte/homebrew-release-action@v2024.612.21058
561573
with:
562574
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
563575
git_email: ${{ secrets.GH_BOT_EMAIL }}

cmake/compile_definitions/linux.cmake

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,42 @@ elseif(NOT LIBDRM_FOUND)
117117
endif()
118118

119119
# evdev
120-
pkg_check_modules(PC_EVDEV libevdev REQUIRED)
121-
find_path(EVDEV_INCLUDE_DIR libevdev/libevdev.h
122-
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR})
123-
find_library(EVDEV_LIBRARY
124-
NAMES evdev libevdev)
120+
pkg_check_modules(PC_EVDEV libevdev)
121+
if(PC_EVDEV_FOUND)
122+
find_path(EVDEV_INCLUDE_DIR libevdev/libevdev.h
123+
HINTS ${PC_EVDEV_INCLUDE_DIRS} ${PC_EVDEV_INCLUDEDIR})
124+
find_library(EVDEV_LIBRARY
125+
NAMES evdev libevdev)
126+
else()
127+
include(ExternalProject)
128+
129+
set(LIBEVDEV_VERSION libevdev-1.13.2)
130+
131+
ExternalProject_Add(libevdev
132+
URL http://www.freedesktop.org/software/libevdev/${LIBEVDEV_VERSION}.tar.xz
133+
PREFIX ${LIBEVDEV_VERSION}
134+
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
135+
BUILD_COMMAND "make"
136+
INSTALL_COMMAND ""
137+
)
138+
139+
ExternalProject_Get_Property(libevdev SOURCE_DIR)
140+
message(STATUS "libevdev source dir: ${SOURCE_DIR}")
141+
set(EVDEV_INCLUDE_DIR "${SOURCE_DIR}")
142+
143+
ExternalProject_Get_Property(libevdev BINARY_DIR)
144+
message(STATUS "libevdev binary dir: ${BINARY_DIR}")
145+
set(EVDEV_LIBRARY "${BINARY_DIR}/libevdev/.libs/libevdev.a")
146+
147+
# compile libevdev before sunshine
148+
set(SUNSHINE_TARGET_DEPENDENCIES ${SUNSHINE_TARGET_DEPENDENCIES} libevdev)
149+
endif()
150+
125151
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
126152
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
127153
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
154+
else()
155+
message(FATAL_ERROR "Couldn't find or fetch libevdev")
128156
endif()
129157

130158
# vaapi
@@ -226,7 +254,7 @@ else()
226254
message(STATUS "Tray icon disabled")
227255
endif()
228256

229-
if (${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
257+
if(${SUNSHINE_ENABLE_TRAY} AND ${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
230258
message(FATAL_ERROR "Tray icon is required")
231259
endif()
232260

@@ -253,5 +281,4 @@ list(APPEND PLATFORM_LIBRARIES
253281

254282
include_directories(
255283
SYSTEM
256-
"${CMAKE_SOURCE_DIR}/third-party/nv-codec-headers/include"
257284
"${CMAKE_SOURCE_DIR}/third-party/glad/include")

cmake/dependencies/common.cmake

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ if(NOT DEFINED FFMPEG_PREPARED_BINARIES)
2525
set(FFMPEG_PLATFORM_LIBRARIES mfplat ole32 strmiids mfuuid vpl)
2626
elseif(UNIX AND NOT APPLE)
2727
set(FFMPEG_PLATFORM_LIBRARIES numa va va-drm va-x11 vdpau X11)
28-
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
28+
# TODO: remove mfx, it's not used and deprecated
29+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT SUNSHINE_BUILD_HOMEBREW)
2930
list(APPEND FFMPEG_PLATFORM_LIBRARIES mfx)
3031
set(CPACK_DEB_PLATFORM_PACKAGE_DEPENDS "libmfx1,")
3132
set(CPACK_RPM_PLATFORM_PACKAGE_REQUIRES "intel-mediasdk >= 22.3.0,")

cmake/prep/options.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,13 @@ option(CUDA_INHERIT_COMPILE_OPTIONS
2020
your IDE throws errors about unknown flags after running cmake." ON)
2121

2222
if(UNIX)
23-
# technically, the homebrew build could be on linux as well... no idea if it would actually work
2423
option(SUNSHINE_BUILD_HOMEBREW
2524
"Enable a Homebrew build." OFF)
25+
option(SUNSHINE_CONFIGURE_HOMEBREW
26+
"Configure Homebrew formula. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
2627
endif ()
2728

2829
if(APPLE)
29-
option(SUNSHINE_CONFIGURE_HOMEBREW
30-
"Configure macOS Homebrew formula. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
3130
option(SUNSHINE_CONFIGURE_PORTFILE
3231
"Configure macOS Portfile. Recommended to use with SUNSHINE_CONFIGURE_ONLY" OFF)
3332
option(SUNSHINE_PACKAGE_MACOS

cmake/prep/special_package_configuration.cmake

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
if (APPLE)
1+
if(UNIX)
2+
if(${SUNSHINE_CONFIGURE_HOMEBREW})
3+
configure_file(packaging/sunshine.rb sunshine.rb @ONLY)
4+
endif()
5+
endif()
6+
7+
if(APPLE)
28
if(${SUNSHINE_CONFIGURE_PORTFILE})
39
configure_file(packaging/macos/Portfile Portfile @ONLY)
410
endif()
5-
if(${SUNSHINE_CONFIGURE_HOMEBREW})
6-
configure_file(packaging/macos/sunshine.rb sunshine.rb @ONLY)
7-
endif()
8-
elseif (UNIX)
11+
elseif(UNIX)
912
# configure the .desktop file
1013
if(${SUNSHINE_BUILD_APPIMAGE})
1114
configure_file(packaging/linux/AppImage/sunshine.desktop sunshine.desktop @ONLY)

cmake/targets/common.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
# this file will also load platform specific macros
33

44
add_executable(sunshine ${SUNSHINE_TARGET_FILES})
5+
foreach(dep ${SUNSHINE_TARGET_DEPENDENCIES})
6+
add_dependencies(sunshine ${dep}) # compile these before sunshine
7+
endforeach()
58

69
# platform specific target definitions
710
if(WIN32)

docs/source/about/setup.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,18 @@ Install
168168
flatpak run --command=remove-additional-install.sh dev.lizardbyte.sunshine
169169
flatpak uninstall --delete-data dev.lizardbyte.sunshine
170170
171+
.. tab:: Homebrew
172+
173+
.. important:: The Homebrew package is experimental.
174+
175+
#. Install `Homebrew <https://docs.brew.sh/Installation>`__
176+
#. Update the Homebrew sources and install Sunshine.
177+
178+
.. code-block:: bash
179+
180+
brew tap LizardByte/homebrew
181+
brew install sunshine
182+
171183
.. tab:: RPM Package
172184

173185
#. Add `rpmfusion` repositories by running the following code.

packaging/macos/sunshine.rb renamed to packaging/sunshine.rb

Lines changed: 56 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ class @PROJECT_NAME@ < Formula
99
license all_of: ["GPL-3.0-only"]
1010
head "@GITHUB_CLONE_URL@", branch: "@GITHUB_DEFAULT_BRANCH@"
1111

12+
# https://docs.brew.sh/Brew-Livecheck#githublatest-strategy-block
13+
livecheck do
14+
url :stable
15+
regex(/^v?(\d+\.\d+\.\d+)$/i)
16+
strategy :github_latest do |json, regex|
17+
match = json["tag_name"]&.match(regex)
18+
next if match.blank?
19+
20+
match[1]
21+
end
22+
end
23+
1224
depends_on "boost" => :build
1325
depends_on "cmake" => :build
1426
depends_on "node" => :build
@@ -18,6 +30,26 @@ class @PROJECT_NAME@ < Formula
1830
depends_on "openssl"
1931
depends_on "opus"
2032

33+
on_linux do
34+
depends_on "libcap"
35+
depends_on "libdrm"
36+
depends_on "libnotify"
37+
depends_on "libva"
38+
depends_on "libvdpau"
39+
depends_on "libx11"
40+
depends_on "libxcb"
41+
depends_on "libxcursor"
42+
depends_on "libxfixes"
43+
depends_on "libxi"
44+
depends_on "libxinerama"
45+
depends_on "libxrandr"
46+
depends_on "libxtst"
47+
depends_on "numactl"
48+
depends_on "pulseaudio"
49+
depends_on "systemd"
50+
depends_on "wayland"
51+
end
52+
2153
def install
2254
ENV["BRANCH"] = "@GITHUB_BRANCH@"
2355
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
@@ -26,36 +58,54 @@ def install
2658
args = %W[
2759
-DBUILD_WERROR=ON
2860
-DCMAKE_INSTALL_PREFIX=#{prefix}
61+
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
2962
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
3063
-DSUNSHINE_ASSETS_DIR=sunshine/assets
3164
-DSUNSHINE_BUILD_HOMEBREW=ON
65+
-DSUNSHINE_ENABLE_TRAY=OFF
3266
-DTESTS_ENABLE_PYTHON_TESTS=OFF
3367
]
3468
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
3569

3670
cd "build" do
37-
system "make", "-j"
71+
system "make"
3872
system "make", "install"
73+
3974
bin.install "tests/test_sunshine"
4075
end
76+
77+
bin.install "src_assets/linux/misc/postinst" if OS.linux?
4178
end
4279

4380
service do
4481
run [opt_bin/"sunshine", "~/.config/sunshine/sunshine.conf"]
4582
end
4683

4784
def caveats
48-
<<~EOS
85+
caveats_message = <<~EOS
4986
Thanks for installing @PROJECT_NAME@!
5087
5188
To get started, review the documentation at:
5289
https://docs.lizardbyte.dev/projects/sunshine/en/latest/
90+
EOS
5391

54-
Sunshine can only access microphones on macOS due to system limitations.
55-
To stream system audio use "Soundflower" or "BlackHole".
92+
if OS.linux?
93+
caveats_message += <<~EOS
94+
ATTENTION: To complete installation, you must run the following command:
95+
`sudo #{bin}/postinst`
96+
EOS
97+
end
5698

57-
Gamepads are not currently supported on macOS.
58-
EOS
99+
if OS.mac?
100+
caveats_message += <<~EOS
101+
Sunshine can only access microphones on macOS due to system limitations.
102+
To stream system audio use "Soundflower" or "BlackHole".
103+
104+
Gamepads are not currently supported on macOS.
105+
EOS
106+
end
107+
108+
caveats_message
59109
end
60110

61111
test do

tests/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ list(REMOVE_ITEM SUNSHINE_SOURCES ${CMAKE_SOURCE_DIR}/src/main.cpp)
107107
add_executable(${PROJECT_NAME}
108108
${TEST_SOURCES}
109109
${SUNSHINE_SOURCES})
110+
111+
foreach(dep ${SUNSHINE_TARGET_DEPENDENCIES})
112+
add_dependencies(${PROJECT_NAME} ${dep}) # compile these before sunshine
113+
endforeach()
114+
110115
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 20)
111116
target_link_libraries(${PROJECT_NAME}
112117
${SUNSHINE_EXTERNAL_LIBRARIES}

0 commit comments

Comments
 (0)