summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: a1ff4f1743fdb34407118207a326aa1e92efdadd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# Maintainer: Grey Christoforo <first name at last name dot net>

: ${_cuda_gcc_version:=14}

pkgname=sunshine-git
pkgver=2025.615.34501.r0.g958d783
pkgrel=1
pkgdesc="A self-hosted GameStream host for Moonlight"
url="https://github.com/LizardByte/Sunshine"
license=('GPL-3.0-only')
arch=('x86_64')

install=sunshine-git.install

depends=(
  'icu'
  'libayatana-appindicator'
  'libcap'
  'libdrm'
  'libevdev'
  'libnotify'
  'libpulse'
  'libva'
  'miniupnpc'
  'numactl'
  'openssl'
  'opus'
  'wayland'
)
makedepends=(
  "gcc${_cuda_gcc_version:?}"
  'boost'
  'cmake'
  'git'
  'ninja'
  'npm'
)
optdepends=(
  'cuda: Nvidia GPU encoding support'
  'intel-media-driver: Intel GPU encoding support'
  'libva-mesa-driver: AMD GPU encoding support'
)

provides=(sunshine)
conflicts=(sunshine)

source=(
  git+https://github.com/LizardByte/Sunshine.git#branch=master
  git+https://github.com/moonlight-stream/moonlight-common-c.git
  git+https://gitlab.com/eidheim/Simple-Web-Server.git
  git+https://github.com/LizardByte/Virtual-Gamepad-Emulation-Client.git
  git+https://github.com/miniupnp/miniupnp.git
  git+https://github.com/FFmpeg/nv-codec-headers.git
  git+https://github.com/michaeltyson/TPCircularBuffer.git
  git+https://github.com/LizardByte/build-deps.git
  git+https://github.com/sleepybishop/nanors.git
  git+https://github.com/cgutman/enet.git
)

sha256sums=(
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
  'SKIP'
)

pkgver() {
  cd Sunshine
  (
    set -o pipefail
    git describe --long --tags --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' \
      || printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
  cd Sunshine
  rm -f third-party/ffmpeg-windows-x86_64
  rm -f third-party/ffmpeg-macos-x86_64
  rm -f third-party/ffmpeg-macos-aarch64
  rm -f third-party/ffmpeg-linux-aarch64
  git submodule init
  git config submodule.third-party/moonlight-common-c.url "${srcdir}/moonlight-common-c"
  git config submodule.third-party/Simple-Web-Server.url "${srcdir}/Simple-Web-Server"
  git config submodule.third-party/ViGEmClient.url "${srcdir}/Virtual-Gamepad-Emulation-Client"
  git config submodule.third-party/miniupnp.url "${srcdir}/miniupnp"
  git config submodule.third-party/nv-codec-headers.url "${srcdir}/nv-codec-headers"
  git config submodule.third-party/TPCircularBuffer.url "${srcdir}/TPCircularBuffer"
  git config submodule.third-party/ffmpeg-linux-x86_64.url "${srcdir}/build-deps"
  git config submodule.third-party/nanors.url "${srcdir}/nanors"
  git -c protocol.file.allow=always submodule update --depth 1

  pushd third-party/moonlight-common-c
  git submodule init
  git config submodule.enet.url "${srcdir}/enet"
  git -c protocol.file.allow=always submodule update --depth 1
  popd

  # OK if this patch fails, probably means it's been upstreamed
  for patch in "${source[@]}"; do
    if [[ "$patch" == *.patch ]]; then
      patch -Np1 -i "$srcdir"/"$patch" || true
    fi
  done

  ## fix for miniupnpc 2.3.3
  sed '1i #include <cstddef>' -i src/upnp.cpp
}

build() {
  pushd Sunshine
  npm install
  popd

  export CFLAGS="${CFLAGS/-Werror=format-security/}"
  export CXXFLAGS="${CXXFLAGS/-Werror=format-security/}"

  export CC="gcc-$_cuda_gcc_version"
  export CXX="g++-$_cuda_gcc_version"

  cmake -B build_dir -S Sunshine -W no-dev -G Ninja \
    -D CMAKE_BUILD_TYPE=None \
    -D CUDA_FAIL_ON_MISSING=OFF \
    -D SUNSHINE_ENABLE_CUDA=1 \
    -D SUNSHINE_ENABLE_X11=1 \
    -D CMAKE_INSTALL_PREFIX=/usr \
    -D SUNSHINE_EXECUTABLE_PATH=/usr/bin/sunshine \
    -D SUNSHINE_ASSETS_DIR="share/sunshine" \
    -D BUILD_DOCS=0 # docs require doxygen, don't want to bother

  cmake --build build_dir
}

check() {
  cd "build_dir/tests"
  ./test_sunshine || :
}

package() {
  depends+=(
    'avahi'
    'libx11'
    'libxcb'
    'libxfixes'
    'libxrandr'
    'mesa' # libgbm
  )

  DESTDIR="${pkgdir}" cmake --install build_dir
}