blob: a3ef62710eecd478eb0b77b8cd997b490a22616f (
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
# Maintainer:
## useful commands
# LLVM_PROFILE_FILE="default_%9m.profraw" pcsx2-qt
# llvm-profdata merge -output=pcsx2-avx-git.profdata *.profraw
## options
: ${_build_instrumented:=false}
: ${_build_pgo:=try}
: ${_build_level:=3}
: ${_build_git:=true}
unset _pkgtype
[[ "${_build_instrumented::1}" == "t" ]] && _pkgtype+="-instrumented"
[[ "${_build_level::1}" == "2" ]] && _pkgtype+="-x64v2"
[[ "${_build_level::1}" == "3" ]] && _pkgtype+="-avx"
[[ "${_build_level::1}" == "4" ]] && _pkgtype+="-x64v4"
[[ "${_build_git::1}" == "t" ]] && _pkgtype+="-git"
_pkgname="pcsx2"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.3.212.r1.gfbc95f2
pkgrel=2
pkgdesc='PlayStation 2 emulator'
url="https://github.com/PCSX2/pcsx2"
license=('GPL-3.0-or-later')
arch=('x86_64' 'x86_64_v2' 'x86_64_v3' 'x86_64_v4')
depends=(
libpcap
libpng
libpulse
libwebp
libxi
libxrandr
qt6-base
sdl3
)
makedepends=(
## compiler
clang
lld
llvm
## build
cmake
extra-cmake-modules
git
ninja
## pcsx2
shaderc
qt6-tools
# patches
7zip
)
optdepends=(
'alsa-utils: Sound player for RetroAchievements'
'gstreamer: Backup sound player for RetroAchievements'
)
case "$CARCH" in
x86_64_v2)
_build_level=2
;;
x86_64_v3)
_build_level=3
;;
x86_64_v4)
_build_level=4
;;
*) # no changes; may be user defined
;;
esac
if [ "${_build_git::1}" == "t" ]; then
provides=("$_pkgname")
conflicts=("$_pkgname")
_commit="master"
pkgver() {
cd "$_pkgsrc"
git describe --long --tags --abbrev=7 --exclude='*[a-zA-Z][a-zA-Z]*' \
| sed -E 's/^[^0-9]*//;s/([^-]*-g)/r\1/;s/-/./g'
}
fi
options=('!debug' 'lto')
install="$_pkgname.install"
_source_pcsx2() {
_pkgsrc="$_pkgname"
source+=("$_pkgsrc"::"git+$url.git#commit=$_commit")
sha256sums+=('SKIP')
}
_source_pcsx2_patches() {
source+=("pcsx2_patches"::"git+https://github.com/PCSX2/pcsx2_patches.git")
sha256sums+=('SKIP')
}
_source_pcsx2
_source_pcsx2_patches
prepare() {
_submodule_update() {
local _module
for _module in "${_submodules[@]}"; do
git submodule init "${_module##*::}"
git submodule set-url "${_module##*::}" "$srcdir/${_module%::*}"
git -c protocol.file.allow=always submodule update "${_module##*::}"
done
}
cd "$_pkgsrc"
# prevent march=native
sed -E -e 's@^(\s*)(add_compile_options\(.*march=native.*\))@\1message("skip: march=native")@' \
-i "cmake/BuildParameters.cmake"
# adjust data path
sed -E -e '/CMAKE_INSTALL_FULL_DATADIR/s@/PCSX2\b@/'"${_pkgname}@" \
-i "pcsx2/CMakeLists.txt" \
"cmake/BuildParameters.cmake"
}
_build_pcsx2() (
echo "Building pcsx2..."
local _cmake_pcsx2
_cmake_pcsx2+=(
-S "$_pkgsrc"
-B build_pcsx2
-G Ninja
-DCMAKE_BUILD_TYPE=None
-DCMAKE_INSTALL_PREFIX='/usr'
-DENABLE_SETCAP=OFF
-DPACKAGE_MODE=ON
-DUSE_ASAN=OFF
-DUSE_BACKTRACE=OFF
-DUSE_VULKAN=ON
-DWAYLAND_API=ON
-DX11_API=ON
-DENABLE_TESTS=OFF
-Wno-dev
)
if [[ ${_build_level::1} =~ ^[2-4]$ ]]; then
_cmake_pcsx2+=(-DDISABLE_ADVANCE_SIMD=OFF)
else
_cmake_pcsx2+=(-DDISABLE_ADVANCE_SIMD=ON)
fi
local _pgo_profile_old="${SRCDEST:-$startdir}/$pkgname.profdata"
local _pgo_profile="$srcdir/$pkgname.profdata"
if [[ "${_build_instrumented::1}" == "t" ]]; then
echo "Compiling with instrumentation."
CFLAGS+=" -fprofile-generate"
CXXFLAGS+=" -fprofile-generate"
elif [[ "${_build_pgo::1}" == "t" ]] && [ -e "$_pgo_profile_old" ]; then
echo "Compiling with profile-guided optimization."
cp --reflink=auto "$_pgo_profile_old" "$_pgo_profile"
CFLAGS+=" -fprofile-use='$_pgo_profile'"
CXXFLAGS+=" -fprofile-use='$_pgo_profile'"
else
echo "Compiling with standard optimization."
fi
cmake "${_cmake_pcsx2[@]}"
cmake --build build_pcsx2
)
_build_pcsx2_patches() (
cd pcsx2_patches
7z a -mx=9 -r ../patches.zip patches/.
)
build() (
export CC CXX CFLAGS CXXFLAGS LDFLAGS
CC=clang
CXX=clang++
local _ldflags=(${LDFLAGS})
LDFLAGS="${_ldflags[@]//*fuse-ld*/} -fuse-ld=lld"
if [[ ${_build_level::1} =~ ^[2-4]$ ]]; then
local _cflags _cxxflags
_cflags=(
-march=x86-64-v${_build_level::1} -mtune=generic -O3
$(sed -E -e 's&-(march|mtune)=\S+\b&&g' -e 's&-O[0-9]+\b&&g' <<< "${CFLAGS}")
)
CFLAGS="${_cflags[@]}"
_cxxflags=(
-march=x86-64-v${_build_level::1} -mtune=generic -O3
$(sed -E -e 's&-(march|mtune)=\S+\b&&g' -e 's&-O[0-9]+\b&&g' <<< "${CXXFLAGS}")
)
CXXFLAGS="${_cxxflags[@]}"
fi
_build_pcsx2
_build_pcsx2_patches
)
package() {
DESTDIR="$pkgdir" cmake --install build_pcsx2
ln -srf "$pkgdir/usr/bin"/{pcsx2-qt,$_pkgname}
install -Dm644 patches.zip -t "$pkgdir/usr/share/$_pkgname/resources/"
install -Dm644 pcsx2/bin/resources/icons/AppIconLarge.png "$pkgdir/usr/share/pixmaps/$_pkgname.png"
install -Dm755 /dev/stdin "$pkgdir/usr/share/applications/$_pkgname.desktop" << END
[Desktop Entry]
Type=Application
Name=PCSX2
GenericName=$pkgdesc
Comment=$pkgdesc
TryExec=$_pkgname
Exec=$_pkgname %f
Icon=$_pkgname
Terminal=false
StartupNotify=true
StartupWMClass=$_pkgname
Categories=Game;Emulator
END
}
|