Skip to content

Commit f090b50

Browse files
build(linux): add homebrew support
1 parent e1f0ca8 commit f090b50

File tree

5 files changed

+97
-30
lines changed

5 files changed

+97
-30
lines changed

.github/workflows/CI.yml

Lines changed: 10 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
@@ -557,7 +557,7 @@ jobs:
557557
path: homebrew/
558558

559559
- name: Validate Homebrew Formula
560-
uses: LizardByte/homebrew-release-action@v2024.609.4731
560+
uses: LizardByte/homebrew-release-action@fix(action)-print-output-in-realtime
561561
with:
562562
formula_file: ${{ github.workspace }}/homebrew/sunshine.rb
563563
git_email: ${{ secrets.GH_BOT_EMAIL }}

cmake/compile_definitions/linux.cmake

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,39 @@ 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+
endif()
147+
125148
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
126149
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
127150
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
151+
else()
152+
message(FATAL_ERROR "Couldn't find or fetch libevdev")
128153
endif()
129154

130155
# vaapi
@@ -226,7 +251,7 @@ else()
226251
message(STATUS "Tray icon disabled")
227252
endif()
228253

229-
if (${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
254+
if(${SUNSHINE_ENABLE_TRAY} AND ${SUNSHINE_TRAY} EQUAL 0 AND SUNSHINE_REQUIRE_TRAY)
230255
message(FATAL_ERROR "Tray icon is required")
231256
endif()
232257

@@ -253,5 +278,4 @@ list(APPEND PLATFORM_LIBRARIES
253278

254279
include_directories(
255280
SYSTEM
256-
"${CMAKE_SOURCE_DIR}/third-party/nv-codec-headers/include"
257281
"${CMAKE_SOURCE_DIR}/third-party/glad/include")

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 macOS 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)

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

Lines changed: 46 additions & 5 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,27 @@ 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 "mesa"
48+
depends_on "numactl"
49+
depends_on "pulseaudio"
50+
depends_on "systemd"
51+
depends_on "wayland"
52+
end
53+
2154
def install
2255
ENV["BRANCH"] = "@GITHUB_BRANCH@"
2356
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
@@ -26,9 +59,11 @@ def install
2659
args = %W[
2760
-DBUILD_WERROR=ON
2861
-DCMAKE_INSTALL_PREFIX=#{prefix}
62+
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
2963
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
3064
-DSUNSHINE_ASSETS_DIR=sunshine/assets
3165
-DSUNSHINE_BUILD_HOMEBREW=ON
66+
-DSUNSHINE_ENABLE_TRAY=OFF
3267
-DTESTS_ENABLE_PYTHON_TESTS=OFF
3368
]
3469
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
@@ -45,17 +80,23 @@ def install
4580
end
4681

4782
def caveats
48-
<<~EOS
83+
caveats_message = <<~EOS
4984
Thanks for installing @PROJECT_NAME@!
5085
5186
To get started, review the documentation at:
5287
https://docs.lizardbyte.dev/projects/sunshine/en/latest/
88+
EOS
5389

54-
Sunshine can only access microphones on macOS due to system limitations.
55-
To stream system audio use "Soundflower" or "BlackHole".
90+
if OS.mac?
91+
caveats_message += <<~EOS
92+
Sunshine can only access microphones on macOS due to system limitations.
93+
To stream system audio use "Soundflower" or "BlackHole".
5694
57-
Gamepads are not currently supported on macOS.
58-
EOS
95+
Gamepads are not currently supported on macOS.
96+
EOS
97+
end
98+
99+
caveats_message
59100
end
60101

61102
test do

0 commit comments

Comments
 (0)