Skip to content

Commit 9053b6d

Browse files
committed
fix: building on Arch Linux
1 parent 25e1d41 commit 9053b6d

File tree

5 files changed

+190
-26
lines changed

5 files changed

+190
-26
lines changed

packaging/linux/Arch/PKGBUILD

Lines changed: 97 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
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+
412
pkgname='sunshine'
513
pkgver=@PROJECT_VERSION@@SUNSHINE_SUB_VERSION@
614
pkgrel=1
@@ -39,9 +47,9 @@ depends=(
3947
makedepends=(
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

5260
optdepends=(
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

5864
provides=()
5965
conflicts=()
6066

61-
source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=@GITHUB_COMMIT@")
67+
source=("$pkgname::git+@GITHUB_CLONE_URL@#commit=${_commit}")
6268
sha256sums=('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+
64109
prepare() {
65110
cd "$pkgname"
66111
git submodule update --recursive --init
@@ -69,43 +114,74 @@ prepare() {
69114
build() {
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

101172
check() {
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

109185
package() {
110-
make -C build install DESTDIR="$pkgdir"
186+
make "-j$(nproc)" -C build install DESTDIR="$pkgdir"
111187
}

packaging/linux/Arch/sunshine.install

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
do_setcap() {
2-
setcap cap_sys_admin+p $(readlink -f $(which sunshine))
2+
setcap cap_sys_admin+p $(readlink -f usr/bin/sunshine)
33
}
44

55
do_udev_reload() {

src/platform/common.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,35 @@
1515
#include <boost/core/noncopyable.hpp>
1616
#ifndef _WIN32
1717
#include <boost/asio.hpp>
18-
#include <boost/process.hpp>
18+
#include <boost/version.hpp>
19+
#if BOOST_VERSION < 108800
20+
#include <boost/process.hpp>
21+
#else
22+
#ifndef BOOST_PROCESS_V1_HPP
23+
#define BOOST_PROCESS_V1_HPP
24+
25+
#include <boost/process/v1/args.hpp>
26+
#include <boost/process/v1/async.hpp>
27+
#include <boost/process/v1/async_system.hpp>
28+
#include <boost/process/v1/group.hpp>
29+
#include <boost/process/v1/child.hpp>
30+
#include <boost/process/v1/cmd.hpp>
31+
#include <boost/process/v1/env.hpp>
32+
#include <boost/process/v1/environment.hpp>
33+
#include <boost/process/v1/error.hpp>
34+
#include <boost/process/v1/exe.hpp>
35+
#include <boost/process/v1/group.hpp>
36+
#include <boost/process/v1/handles.hpp>
37+
#include <boost/process/v1/io.hpp>
38+
#include <boost/process/v1/pipe.hpp>
39+
#include <boost/process/v1/shell.hpp>
40+
#include <boost/process/v1/search_path.hpp>
41+
#include <boost/process/v1/spawn.hpp>
42+
#include <boost/process/v1/system.hpp>
43+
#include <boost/process/v1/start_dir.hpp>
44+
45+
#endif //BOOST_PROCESS_V1_HPP
46+
#endif
1947
#endif
2048

2149
// local includes

src/platform/linux/misc.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,35 @@
2222
// lib includes
2323
#include <boost/asio/ip/address.hpp>
2424
#include <boost/asio/ip/host_name.hpp>
25-
#include <boost/process/v1.hpp>
25+
#include <boost/version.hpp>
26+
#if BOOST_VERSION < 108800
27+
#include <boost/process/v1.hpp>
28+
#else
29+
#ifndef BOOST_PROCESS_V1_HPP
30+
#define BOOST_PROCESS_V1_HPP
31+
32+
#include <boost/process/v1/args.hpp>
33+
#include <boost/process/v1/async.hpp>
34+
#include <boost/process/v1/async_system.hpp>
35+
#include <boost/process/v1/group.hpp>
36+
#include <boost/process/v1/child.hpp>
37+
#include <boost/process/v1/cmd.hpp>
38+
#include <boost/process/v1/env.hpp>
39+
#include <boost/process/v1/environment.hpp>
40+
#include <boost/process/v1/error.hpp>
41+
#include <boost/process/v1/exe.hpp>
42+
#include <boost/process/v1/group.hpp>
43+
#include <boost/process/v1/handles.hpp>
44+
#include <boost/process/v1/io.hpp>
45+
#include <boost/process/v1/pipe.hpp>
46+
#include <boost/process/v1/shell.hpp>
47+
#include <boost/process/v1/search_path.hpp>
48+
#include <boost/process/v1/spawn.hpp>
49+
#include <boost/process/v1/system.hpp>
50+
#include <boost/process/v1/start_dir.hpp>
51+
52+
#endif //BOOST_PROCESS_V1_HPP
53+
#endif
2654
#include <fcntl.h>
2755
#include <unistd.h>
2856

@@ -43,7 +71,11 @@
4371

4472
using namespace std::literals;
4573
namespace fs = std::filesystem;
46-
namespace bp = boost::process;
74+
#if BOOST_VERSION < 108800
75+
namespace bp = boost::process;
76+
#else
77+
namespace bp = boost::process::v1;
78+
#endif
4779

4880
window_system_e window_system;
4981

src/process.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,35 @@
1313
#include <unordered_map>
1414

1515
// lib includes
16-
#include <boost/process/v1.hpp>
16+
#include <boost/version.hpp>
17+
#if BOOST_VERSION < 108800
18+
#include <boost/process/v1.hpp>
19+
#else
20+
#ifndef BOOST_PROCESS_V1_HPP
21+
#define BOOST_PROCESS_V1_HPP
22+
23+
#include <boost/process/v1/args.hpp>
24+
#include <boost/process/v1/async.hpp>
25+
#include <boost/process/v1/async_system.hpp>
26+
#include <boost/process/v1/group.hpp>
27+
#include <boost/process/v1/child.hpp>
28+
#include <boost/process/v1/cmd.hpp>
29+
#include <boost/process/v1/env.hpp>
30+
#include <boost/process/v1/environment.hpp>
31+
#include <boost/process/v1/error.hpp>
32+
#include <boost/process/v1/exe.hpp>
33+
#include <boost/process/v1/group.hpp>
34+
#include <boost/process/v1/handles.hpp>
35+
#include <boost/process/v1/io.hpp>
36+
#include <boost/process/v1/pipe.hpp>
37+
#include <boost/process/v1/shell.hpp>
38+
#include <boost/process/v1/search_path.hpp>
39+
#include <boost/process/v1/spawn.hpp>
40+
#include <boost/process/v1/system.hpp>
41+
#include <boost/process/v1/start_dir.hpp>
42+
43+
#endif //BOOST_PROCESS_V1_HPP
44+
#endif
1745

1846
// local includes
1947
#include "config.h"

0 commit comments

Comments
 (0)