11# Edit on github: https://github.com/LizardByte/Sunshine/blob/master/packaging/linux/Arch/PKGBUILD
22# Reference: https://wiki.archlinux.org/title/PKGBUILD
33
4+ # # options
5+ : " ${_run_unit_tests:= false} " # if set to true; unit tests will be executed post build; useful in CI
6+ : " ${_use_cuda:= detect} " # nvenc
7+ : " ${_cuda_gcc_version:= $(LC_ALL=C pacman -Si cuda | grep -Pom1 ' ^Depends On\s*:.*\bgcc\K[0-9]+\b' )} "
8+ : " ${_support_headless_testing:= false} "
9+
10+ : " ${_commit:=@ GITHUB_COMMIT@ } "
11+
412pkgname=' sunshine'
513pkgver=@PROJECT_VERSION@@SUNSHINE_SUB_VERSION@
614pkgrel=1
@@ -39,9 +47,9 @@ depends=(
3947makedepends=(
4048 ' appstream'
4149 ' appstream-glib'
50+ ' boost'
4251 ' cmake'
4352 ' desktop-file-utils'
44- ' cuda'
4553 " gcc${_gcc_version} "
4654 ' git'
4755 ' make'
@@ -50,17 +58,54 @@ makedepends=(
5058)
5159
5260optdepends=(
53- ' cuda: Nvidia GPU encoding support'
5461 ' libva-mesa-driver: AMD GPU encoding support'
55- ' xorg-server-xvfb: Virtual X server for headless testing'
5662)
5763
5864provides=()
5965conflicts=()
6066
61- source=(" $pkgname ::git+@GITHUB_CLONE_URL@#commit=@GITHUB_COMMIT@ " )
67+ source=(" $pkgname ::git+@GITHUB_CLONE_URL@#commit=${_commit} " )
6268sha256sums=(' SKIP' )
6369
70+ # Options Handling
71+ if [[ " ${_use_cuda:: 1} " == " d" ]] && (pacman -Qi cuda & > /dev/null || pacman -Qi nvidia-utils & > /dev/null); then
72+ _use_cuda=true
73+ fi
74+
75+ if [[ " ${_use_cuda:: 1} " == " t" ]]; then
76+ makedepends+=(' cuda' )
77+ checkdepends+=(' nvidia-utils' )
78+ optdepends+=(
79+ ' cuda: Nvidia GPU encoding support'
80+ ' nvidia-utils: Nvidia GPU encoding support'
81+ )
82+ fi
83+
84+ if [[ " ${_support_headless_testing:: 1} " == " t" ]]; then
85+ optdepends+=(
86+ ' xorg-server-xvfb: Virtual X server for headless testing'
87+ )
88+ fi
89+
90+ # Ensure makedepends, checkdepends, optdepends are sorted
91+ if [ -n " ${makedepends+x} " ]; then
92+ mapfile -t tmp_array < <( printf ' %s\n' " ${makedepends[@]} " | sort)
93+ makedepends=(" ${tmp_array[@]} " )
94+ unset tmp_array
95+ fi
96+
97+ if [ -n " ${checkdepends+x} " ]; then
98+ mapfile -t tmp_array < <( printf ' %s\n' " ${checkdepends[@]} " | sort)
99+ checkdepends=(" ${tmp_array[@]} " )
100+ unset tmp_array
101+ fi
102+
103+ if [ -n " ${optdepends+x} " ]; then
104+ mapfile -t tmp_array < <( printf ' %s\n' " ${optdepends[@]} " | sort)
105+ optdepends=(" ${tmp_array[@]} " )
106+ unset tmp_array
107+ fi
108+
64109prepare () {
65110 cd " $pkgname "
66111 git submodule update --recursive --init
@@ -69,43 +114,74 @@ prepare() {
69114build () {
70115 export BRANCH=" @GITHUB_BRANCH@"
71116 export BUILD_VERSION=" @BUILD_VERSION@"
72- export COMMIT=" @GITHUB_COMMIT@ "
117+ export COMMIT=" ${_commit} "
73118
74119 export CC=" gcc-${_gcc_version} "
75120 export CXX=" g++-${_gcc_version} "
76121
77122 export CFLAGS=" ${CFLAGS/ -Werror=format-security/ } "
78123 export CXXFLAGS=" ${CXXFLAGS/ -Werror=format-security/ } "
79124
80- cmake \
81- -S " $pkgname " \
82- -B build \
83- -Wno-dev \
84- -D BUILD_DOCS=OFF \
85- -D BUILD_WERROR=ON \
86- -D CMAKE_INSTALL_PREFIX=/usr \
87- -D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
88- -D SUNSHINE_ASSETS_DIR=" share/sunshine" \
89- -D SUNSHINE_PUBLISHER_NAME=' LizardByte' \
90- -D SUNSHINE_PUBLISHER_WEBSITE=' https://app.lizardbyte.dev' \
91- -D SUNSHINE_PUBLISHER_ISSUE_URL=' https://app.lizardbyte.dev/support'
125+ export CUDA_PATH=/opt/cuda
126+ export NVCC_CCBIN=" /usr/bin/g++-$_cuda_gcc_version "
127+
128+ export MAKEFLAGS=" -j$( nproc) "
129+
130+ local _cmake_options=(
131+ -S " $pkgname "
132+ -B build
133+ -Wno-dev
134+ -D BUILD_DOCS=OFF
135+ -D BUILD_WERROR=ON
136+ -D CMAKE_INSTALL_PREFIX=/usr
137+ -D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine
138+ -D SUNSHINE_ASSETS_DIR=" share/sunshine"
139+ -D SUNSHINE_PUBLISHER_NAME=' LizardByte'
140+ -D SUNSHINE_PUBLISHER_WEBSITE=' https://app.lizardbyte.dev'
141+ -D SUNSHINE_PUBLISHER_ISSUE_URL=' https://app.lizardbyte.dev/support'
142+ -D SUNSHINE_ENABLE_CUDA=ON
143+ -D SUNSHINE_ENABLE_DRM=ON
144+ -D SUNSHINE_ENABLE_TRAY=ON
145+ -D SUNSHINE_ENABLE_VAAPI=ON
146+ -D SUNSHINE_ENABLE_WAYLAND=ON
147+ -D SUNSHINE_ENABLE_X11=ON
148+ )
149+
150+ if [[ " ${_use_cuda:: 1} " == " t" ]]; then
151+ _cmake_options+=(-DCUDA_FAIL_ON_MISSING=ON)
152+ else
153+ _cmake_options+=(-DCUDA_FAIL_ON_MISSING=OFF)
154+ fi
155+
156+ if [[ " ${_run_unit_tests:: 1} " == " t" ]]; then
157+ _cmake_options+=(-DBUILD_TESTS=ON)
158+ else
159+ _cmake_options+=(-DBUILD_TESTS=OFF)
160+ fi
161+
162+ cmake " ${_cmake_options[@]} "
92163
93164 appstreamcli validate " build/dev.lizardbyte.app.Sunshine.metainfo.xml"
94165 appstream-util validate " build/dev.lizardbyte.app.Sunshine.metainfo.xml"
95166 desktop-file-validate " build/dev.lizardbyte.app.Sunshine.desktop"
96167 desktop-file-validate " build/dev.lizardbyte.app.Sunshine.terminal.desktop"
97168
98- make -C build
169+ make " ${MAKEFLAGS} " -C build
99170}
100171
101172check () {
102173 export CC=" gcc-${_gcc_version} "
103174 export CXX=" g++-${_gcc_version} "
104175
105- cd " ${srcdir} /build/tests"
106- ./test_sunshine --gtest_color=yes
176+ if [[ " ${_run_unit_tests:: 1} " == " t" ]]; then
177+ cd " ${srcdir} /build/tests"
178+ ./test_sunshine --gtest_color=yes
179+ else
180+ cd " ${srcdir} /build"
181+ ./sunshine --version
182+ fi
107183}
108184
109185package () {
110- make -C build install DESTDIR=" $pkgdir "
186+ make " -j $( nproc ) " -C build install DESTDIR=" $pkgdir "
111187}
0 commit comments