mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-08-07 10:20:46 +00:00
build(linux): generate glad sources at compile time (#4798)
Co-authored-by: Conn O'Griofa <connogriofa@gmail.com>
This commit is contained in:
@@ -63,6 +63,8 @@ makedepends=(
|
||||
'make'
|
||||
'nodejs'
|
||||
'npm'
|
||||
'python-jinja' # required by the glad OpenGL/EGL loader generator
|
||||
'python-setuptools' # required for glad OpenGL/EGL loader generated, v2.0.0
|
||||
)
|
||||
|
||||
checkdepends=(
|
||||
|
||||
@@ -67,6 +67,8 @@ BuildRequires: nodejs-npm
|
||||
BuildRequires: numactl-devel
|
||||
BuildRequires: opus-devel
|
||||
BuildRequires: pulseaudio-libs-devel
|
||||
BuildRequires: python3-jinja2
|
||||
BuildRequires: python3-setuptools
|
||||
BuildRequires: systemd-udev
|
||||
%{?sysusers_requires_compat}
|
||||
# for unit tests
|
||||
@@ -86,6 +88,9 @@ BuildRequires: libnuma-devel
|
||||
BuildRequires: libopus-devel
|
||||
BuildRequires: libpulse-devel
|
||||
BuildRequires: npm
|
||||
BuildRequires: python311
|
||||
BuildRequires: python311-Jinja2
|
||||
BuildRequires: python311-setuptools
|
||||
BuildRequires: udev
|
||||
# for unit tests
|
||||
BuildRequires: xvfb-run
|
||||
@@ -117,9 +122,9 @@ BuildRequires: gcc15-c++
|
||||
%if 0%{?suse_version}
|
||||
%if 0%{?suse_version} <= 1699
|
||||
# OpenSUSE Leap 15.x
|
||||
BuildRequires: gcc13
|
||||
BuildRequires: gcc13-c++
|
||||
%global gcc_version 13
|
||||
BuildRequires: gcc14
|
||||
BuildRequires: gcc14-c++
|
||||
%global gcc_version 14
|
||||
%global cuda_version 12.9.1
|
||||
%global cuda_build 575.57.08
|
||||
%else
|
||||
|
||||
@@ -50,6 +50,11 @@ modules:
|
||||
# FFmpeg prebuilt binaries
|
||||
- "modules/ffmpeg.json"
|
||||
|
||||
# Python PyPI build-time dependencies (e.g. jinja2 for glad generator).
|
||||
# glad-dependencies.json is generated at CI time by flatpak-pip-generator and
|
||||
# placed alongside the manifest in the build directory.
|
||||
- "glad-dependencies.json"
|
||||
|
||||
- name: sunshine
|
||||
builddir: true
|
||||
build-options:
|
||||
@@ -71,6 +76,7 @@ modules:
|
||||
- -DCMAKE_BUILD_TYPE=Release
|
||||
- -DCMAKE_CUDA_COMPILER=/app/cuda/bin/nvcc
|
||||
- -DFFMPEG_PREPARED_BINARIES=/app/ffmpeg
|
||||
- -DGLAD_SKIP_PIP_INSTALL=ON
|
||||
- -DSUNSHINE_ASSETS_DIR=share/sunshine
|
||||
- -DSUNSHINE_BUILD_FLATPAK=ON
|
||||
- -DSUNSHINE_EXECUTABLE_PATH=/app/bin/sunshine
|
||||
|
||||
+44
-1
@@ -1,6 +1,8 @@
|
||||
require "language/node"
|
||||
|
||||
class Sunshine < Formula
|
||||
include Language::Python::Virtualenv
|
||||
|
||||
CUDA_VERSION = "13.1".freeze
|
||||
CUDA_FORMULA = "cuda@#{CUDA_VERSION}".freeze
|
||||
GCC_VERSION = "14".freeze
|
||||
@@ -61,6 +63,7 @@ class Sunshine < Formula
|
||||
on_linux do
|
||||
depends_on GCC_FORMULA => [:build, :test]
|
||||
depends_on "lizardbyte/homebrew/#{CUDA_FORMULA}" => :build if build.with? "cuda"
|
||||
depends_on "python3" => :build
|
||||
depends_on "at-spi2-core"
|
||||
depends_on "avahi"
|
||||
depends_on "ayatana-ido"
|
||||
@@ -95,9 +98,29 @@ class Sunshine < Formula
|
||||
depends_on "pulseaudio"
|
||||
depends_on "systemd"
|
||||
depends_on "wayland"
|
||||
|
||||
# Jinja2 is required at build time by the glad OpenGL/EGL loader generator (Linux only).
|
||||
# Declared as resources per https://docs.brew.sh/Formula-Cookbook#python-dependencies
|
||||
resource "markupsafe" do
|
||||
url "https://files.pythonhosted.org/packages/7e/99/7690b6d4034fffd95959cbe0c02de8deb3098cc577c67bb6a24fe5d7caa7/markupsafe-3.0.3.tar.gz"
|
||||
sha256 "722695808f4b6457b320fdc131280796bdceb04ab50fe1795cd540799ebe1698"
|
||||
end
|
||||
|
||||
resource "jinja2" do
|
||||
url "https://files.pythonhosted.org/packages/df/bf/f7da0350254c0ed7c72f3e33cef02e048281fec7ecec5f032d4aac52226b/jinja2-3.1.6.tar.gz"
|
||||
sha256 "0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d"
|
||||
end
|
||||
|
||||
# setuptools provides pkg_resources which glad's plugin.py imports at build time.
|
||||
# setuptools >= 81 removed pkg_resources; this is the last release that still ships it.
|
||||
resource "setuptools" do
|
||||
url "https://files.pythonhosted.org/packages/76/95/faf61eb8363f26aa7e1d762267a8d602a1b26d4f3a1e758e92cb3cb8b054/setuptools-80.10.2.tar.gz"
|
||||
sha256 "8b0e9d10c784bf7d262c4e5ec5d4ec94127ce206e8738f29a437945fbc219b70"
|
||||
end
|
||||
end
|
||||
|
||||
conflicts_with "sunshine-beta", because: "sunshine and sunshine-beta cannot be installed at the same time"
|
||||
|
||||
fails_with :clang do
|
||||
build 1400
|
||||
cause "Requires C++23 support"
|
||||
@@ -108,12 +131,28 @@ class Sunshine < Formula
|
||||
cause "Requires C++23 support"
|
||||
end
|
||||
|
||||
fails_with :gcc do
|
||||
version "13"
|
||||
cause "Array out of bounds error when compiling glad sources"
|
||||
end
|
||||
|
||||
def setup_build_environment
|
||||
ENV["BRANCH"] = "@GITHUB_BRANCH@"
|
||||
ENV["BUILD_VERSION"] = "@BUILD_VERSION@"
|
||||
ENV["COMMIT"] = "@GITHUB_COMMIT@"
|
||||
|
||||
setup_linux_gcc_environment if OS.linux?
|
||||
|
||||
return unless OS.linux?
|
||||
|
||||
# Install jinja2 (required by the glad OpenGL/EGL loader generator) into a
|
||||
# temporary virtualenv. We pass its Python path to cmake via Python_EXECUTABLE
|
||||
# so glad uses the venv Python that has jinja2, and set GLAD_SKIP_PIP_INSTALL=ON
|
||||
# to prevent cmake from trying to pip-install again.
|
||||
# Follows https://docs.brew.sh/Formula-Cookbook#python-dependencies
|
||||
venv = virtualenv_create(buildpath/"venv", "python3")
|
||||
venv.pip_install resources
|
||||
@glad_python = (buildpath/"venv/bin/python3").to_s
|
||||
end
|
||||
|
||||
def setup_linux_gcc_environment
|
||||
@@ -124,10 +163,11 @@ class Sunshine < Formula
|
||||
end
|
||||
|
||||
def base_cmake_args
|
||||
%W[
|
||||
args = %W[
|
||||
-DBUILD_WERROR=ON
|
||||
-DCMAKE_CXX_STANDARD=23
|
||||
-DCMAKE_INSTALL_PREFIX=#{prefix}
|
||||
-DGLAD_SKIP_PIP_INSTALL=ON
|
||||
-DHOMEBREW_ALLOW_FETCHCONTENT=ON
|
||||
-DOPENSSL_ROOT_DIR=#{Formula["openssl"].opt_prefix}
|
||||
-DSUNSHINE_ASSETS_DIR=sunshine/assets
|
||||
@@ -136,6 +176,9 @@ class Sunshine < Formula
|
||||
-DSUNSHINE_PUBLISHER_WEBSITE='https://app.lizardbyte.dev'
|
||||
-DSUNSHINE_PUBLISHER_ISSUE_URL='https://app.lizardbyte.dev/support'
|
||||
]
|
||||
# Point cmake at the venv Python that has jinja2 installed (set up in setup_build_environment)
|
||||
args << "-DPython_EXECUTABLE=#{@glad_python}" if @glad_python
|
||||
args
|
||||
end
|
||||
|
||||
def add_test_args(args)
|
||||
|
||||
Reference in New Issue
Block a user