blob: 44f1f36ddbf210b4f52b22b551fdc363d5332ea5 (
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
|
# 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}
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"
_pkgtype+="-git"
_pkgname="pcsx2"
pkgname="$_pkgname${_pkgtype:-}"
pkgver=2.5.333.r0.g7942ee4
pkgrel=1
pkgdesc='PlayStation 2 emulator'
url="https://github.com/PCSX2/pcsx2"
license=('GPL-3.0-or-later')
arch=('x86_64')
depends=(
kddockwidgets
libpcap
libpng
libwebp
libxi
libxrandr
plutosvg # AUR
plutovg # AUR
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'
)
provides=("$_pkgname")
conflicts=("$_pkgname")
options=('!debug' 'lto')
install="$_pkgname.install"
_pkgsrc="$_pkgname"
source=(
"$_pkgsrc"::"git+$url.git${_commit:+#commit=$_commit}"
"pcsx2_patches"::"git+https://github.com/PCSX2/pcsx2_patches.git"
)
sha256sums=(
'SKIP'
'SKIP'
)
prepare() {
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
# relax requirements
sed -E -e 's&^(find_package\s*\(plutos?vg) [0-9.]* ([A-Z]+\))$&\1 \2&' \
-i cmake/SearchForStuff.cmake
}
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'
}
build() (
export CC CXX CFLAGS CXXFLAGS LDFLAGS
CC=clang
CXX=clang++
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} -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} -O3
$(sed -E -e 's&-(march|mtune)=\S+\b&&g' -e 's&-O[0-9]+\b&&g' <<< "${CXXFLAGS}")
)
CXXFLAGS="${_cxxflags[@]}"
fi
echo "Building pcsx2..."
local _cmake_pcsx2
_cmake_pcsx2=(
-S "$_pkgsrc"
-B build_pcsx2
-G Ninja
-DCMAKE_BUILD_TYPE=None
-DCMAKE_INSTALL_PREFIX='/usr'
-DCMAKE_SKIP_RPATH=ON
-DENABLE_TESTS=$CHECKFUNC
-Wno-dev
-DENABLE_SETCAP=OFF
-DPACKAGE_MODE=ON
-DUSE_ASAN=OFF
-DUSE_BACKTRACE=OFF
-DUSE_VULKAN=ON
-DWAYLAND_API=ON
-DX11_API=ON
)
if [[ ${_build_level::1} =~ ^[2-4]$ ]] || [[ ${CARCH: -2} =~ ^v[0-9]$ ]]; 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
echo "Archiving game patches..."
cd pcsx2_patches
7z a -mx=9 -r ../patches.zip patches/.
)
package() {
DESTDIR="$pkgdir" cmake --install build_pcsx2
ln -sf pcsx2-qt "$pkgdir/usr/bin/$_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
}
|