diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a4255b53d84..8ae67395ac7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -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 @@ -557,7 +557,7 @@ jobs: path: homebrew/ - name: Validate Homebrew Formula - uses: LizardByte/homebrew-release-action@v2024.609.4731 + uses: LizardByte/homebrew-release-action@fix(action)-print-output-in-realtime with: formula_file: ${{ github.workspace }}/homebrew/sunshine.rb git_email: ${{ secrets.GH_BOT_EMAIL }} diff --git a/cmake/compile_definitions/linux.cmake b/cmake/compile_definitions/linux.cmake index b323eb82e84..d2fcf3a9e88 100644 --- a/cmake/compile_definitions/linux.cmake +++ b/cmake/compile_definitions/linux.cmake @@ -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 /configure --prefix= + 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") diff --git a/cmake/prep/options.cmake b/cmake/prep/options.cmake index 1555036eeb0..b6780deca00 100644 --- a/cmake/prep/options.cmake +++ b/cmake/prep/options.cmake @@ -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 diff --git a/cmake/prep/special_package_configuration.cmake b/cmake/prep/special_package_configuration.cmake index 17e724c90d0..e69b720a29c 100644 --- a/cmake/prep/special_package_configuration.cmake +++ b/cmake/prep/special_package_configuration.cmake @@ -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) diff --git a/cmake/targets/common.cmake b/cmake/targets/common.cmake index 941ef0b7330..baa1bce1c03 100644 --- a/cmake/targets/common.cmake +++ b/cmake/targets/common.cmake @@ -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) diff --git a/packaging/macos/sunshine.rb b/packaging/sunshine.rb similarity index 59% rename from packaging/macos/sunshine.rb rename to packaging/sunshine.rb index e119d1df1a7..bf55098135b 100644 --- a/packaging/macos/sunshine.rb +++ b/packaging/sunshine.rb @@ -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,27 @@ 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 "systemd" + depends_on "wayland" + end + def install ENV["BRANCH"] = "@GITHUB_BRANCH@" ENV["BUILD_VERSION"] = "@BUILD_VERSION@" @@ -26,9 +59,11 @@ def install 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 @@ -36,6 +71,7 @@ def install cd "build" do system "make", "-j" system "make", "install" + bin.install "tests/test_sunshine" end end @@ -45,17 +81,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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eeb6a810596..a4e981b6d05 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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}