Skip to content

Commit

Permalink
build(linux): add homebrew support
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenigneArcher committed Jun 10, 2024
1 parent e1f0ca8 commit 4324d43
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 30 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
32 changes: 24 additions & 8 deletions cmake/compile_definitions/linux.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,30 @@ 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)
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
if(NOT SUNSHINE_BUILD_HOMEBREW)
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)
if(EVDEV_INCLUDE_DIR AND EVDEV_LIBRARY)
include_directories(SYSTEM ${EVDEV_INCLUDE_DIR})
list(APPEND PLATFORM_LIBRARIES ${EVDEV_LIBRARY})
endif()
else()
include(FetchContent)
FetchContent_Declare(
libevdev
GIT_REPOSITORY https://gitlab.freedesktop.org/libevdev/libevdev.git
GIT_TAG libevdev-1.13.2
)

FetchContent_GetProperties(libevdev)
if(NOT libevdev_POPULATED)
FetchContent_Populate(libevdev)
include_directories(SYSTEM "${libevdev_SOURCE_DIR}/libevdev")
list(APPEND PLATFORM_LIBRARIES ${libevdev_BINARY_DIR})
endif()
endif()

# vaapi
Expand Down
5 changes: 2 additions & 3 deletions cmake/prep/options.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 macOS 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
Expand Down
13 changes: 8 additions & 5 deletions cmake/prep/special_package_configuration.cmake
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
49 changes: 44 additions & 5 deletions packaging/macos/sunshine.rb → packaging/sunshine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 "mesa"
depends_on "numactl"
depends_on "pulseaudio"
depends_on "wayland"
end

def install
ENV["BRANCH"] = "@GITHUB_BRANCH@"
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
Expand All @@ -29,6 +61,7 @@ def install
-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
Expand All @@ -45,17 +78,23 @@ def install
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/
EOS

Sunshine can only access microphones on macOS due to system limitations.
To stream system audio use "Soundflower" or "BlackHole".
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
Gamepads are not currently supported on macOS.
EOS
end

caveats_message
end

test do
Expand Down

0 comments on commit 4324d43

Please sign in to comment.