Skip to content

Commit 46a76e4

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

File tree

5 files changed

+87
-30
lines changed

5 files changed

+87
-30
lines changed

.github/workflows/CI.yml

Lines changed: 9 additions & 9 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

cmake/compile_definitions/linux.cmake

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,30 @@ 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)
125-
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
126-
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
127-
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
120+
if(NOT SUNSHINE_HOMEBREW_BUILD)
121+
pkg_check_modules(PC_EVDEV libevdev REQUIRED)
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+
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
127+
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
128+
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
129+
endif()
130+
else()
131+
include(FetchContent)
132+
FetchContent_Declare(
133+
libevdev
134+
GIT_REPOSITORY https://gitlab.freedesktop.org/libevdev/libevdev.git
135+
GIT_TAG libevdev-1.13.2
136+
)
137+
138+
FetchContent_GetProperties(libevdev)
139+
if(NOT libevdev_POPULATED)
140+
FetchContent_Populate(libevdev)
141+
include_directories(SYSTEM ${libevdev_SOURCE_DIR})
142+
list(APPEND PLATFORM_LIBRARIES ${libevdev_BINARY_DIR})
143+
endif()
128144
endif()
129145

130146
# vaapi

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: 44 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,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 "mesa"
48+
depends_on "numactl"
49+
depends_on "pulseaudio"
50+
depends_on "wayland"
51+
end
52+
2153
def install
2254
ENV["BRANCH"] = "@GITHUB_BRANCH@"
2355
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
@@ -29,6 +61,7 @@ def install
2961
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
3062
-DSUNSHINE_ASSETS_DIR=sunshine/assets
3163
-DSUNSHINE_BUILD_HOMEBREW=ON
64+
-DSUNSHINE_ENABLE_TRAY=OFF
3265
-DTESTS_ENABLE_PYTHON_TESTS=OFF
3366
]
3467
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, *args
@@ -45,17 +78,23 @@ def install
4578
end
4679

4780
def caveats
48-
<<~EOS
81+
caveats_message = <<~EOS
4982
Thanks for installing @PROJECT_NAME@!
5083
5184
To get started, review the documentation at:
5285
https://docs.lizardbyte.dev/projects/sunshine/en/latest/
86+
EOS
5387

54-
Sunshine can only access microphones on macOS due to system limitations.
55-
To stream system audio use "Soundflower" or "BlackHole".
88+
if OS.mac?
89+
caveats_message += <<~EOS
90+
Sunshine can only access microphones on macOS due to system limitations.
91+
To stream system audio use "Soundflower" or "BlackHole".
5692
57-
Gamepads are not currently supported on macOS.
58-
EOS
93+
Gamepads are not currently supported on macOS.
94+
EOS
95+
end
96+
97+
caveats_message
5998
end
6099

61100
test do

0 commit comments

Comments
 (0)