summarylogtreecommitdiffstats
path: root/PKGBUILD
blob: 53cc3c7fc567bbc9bea91a578e1ecc39c9a10a43 (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
# Maintainer: HurricanePootis <hurricane
pkgname=panda3ds
pkgver=0.9
pkgrel=1
pkgdesc="HLE 3DS emulator"
arch=(x86_64)
url="https://github.com/wheremyfoodat/Panda3DS"
license=('GPL-3.0-only')
depends=('glibc' 'gcc-libs' 'zydis' 'qt6-base' 'libx11' 'hicolor-icon-theme' 'bash' 'sdl2' 'libglvnd')
makedepends=('cmake' 'git' 'boost' 'vulkan-headers' 'gendesk')
source=("$pkgname::git+$url.git#tag=v${pkgver}"
	"elfio::git+https://github.com/serge1/ELFIO.git"
	"SDL2::git+https://github.com/libsdl-org/SDL.git"
	"git+https://github.com/weidai11/cryptopp.git"
	"git+https://github.com/herumi/xbyak.git"
	"git+https://github.com/ToruNiina/toml11.git"
	"git+https://github.com/yhirose/cpp-httplib.git"
	"git+https://github.com/nothings/stb.git"
	"git+https://github.com/vector-of-bool/cmrc.git"
	"git+https://github.com/g-truc/glm.git"
	"git+https://github.com/Panda3DS-emu/discord-rpc.git"
	"git+https://github.com/Panda3DS-emu/LuaJIT.git"
	"git+https://github.com/vimpunk/mio.git"
	"hydra_core::git+https://github.com/hydra-emu/core.git"
	"git+https://github.com/Panda3DS-emu/zep.git"
	"git+https://github.com/luvit/luv.git"
	"git+https://github.com/libuv/libuv.git"
	"git+https://github.com/mackron/miniaudio.git"
	"git+https://github.com/wwylele/teakra.git"
	"boost::git+https://github.com/Panda3DS-emu/ext-boost.git"
	"git+https://github.com/Panda3DS-emu/dynarmic.git"
	"git+https://github.com/neobrain/nihstro.git"
	"git+https://github.com/catchorg/Catch2.git"
	"git+https://github.com/capstone-engine/capstone.git"
	"hips::git+https://github.com/wheremyfoodat/Hips.git"
	"git+https://github.com/Panda3DS-emu/metal-cpp.git"
	"git+https://github.com/fmtlib/fmt.git"
	"git+https://github.com/Panda3DS-emu/fdk-aac.git"
	"cryptoppwin::git+https://github.com/shadps4-emu/ext-cryptoppwin.git"
	"git+https://github.com/panda3ds-emu/oaknut.git"
	#Capstone submodule
	"git+https://github.com/tree-sitter/tree-sitter-cpp.git"
	#Dynarmics zydis submodule
	"zycore::git+https://github.com/zyantific/zycore-c.git"
	#Luv submodules
	"git+https://github.com/lua/lua.git"
	"git+https://github.com/keplerproject/lua-compat-5.3.git"
	"luajit::git+https://github.com/LuaJIT/LuaJIT.git"
	'dynamic.patch'
	)
sha256sums=('a56a7f0e54a20a1d2d4c5ad586efd9c229bca4b1db7fc932c3f4da8733e1dd1a'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            'SKIP'
            '0bbea178a09c1a2bd4426bcd90d844c5a719fa31dcf39eb01b9b07fada164b04')
validpgpkeys=()

prepare() {
	cd "$srcdir/$pkgname"
	patch -p1 < "$srcdir/dynamic.patch"
	git submodule init
	#third_party submodules first
	for submodule in {elfio,SDL2,xbyak,toml11,cmrc,glm,discord-rpc,LuaJIT,mio,hydra_core,zep,luv,libuv,miniaudio,teakra,boost,dynarmic,nihstro,Catch2,capstone,hips,metal-cpp,fmt,fdk-aac,cryptoppwin,oaknut};
	do
		git config submodule.third_party/${submodule}.url "$srcdir/${submodule}"
	done
	git config submodule.cpp-httplib.url "$srcdir/cpp-httplib"
	git config submodule.stb.url "$srcdir/stb"
	git config submodule.third_party/cryptopp/cryptopp.url "$srcdir/cryptopp"
	git -c protocol.file.allow=always submodule update

	cd "$srcdir/$pkgname/third_party/capstone"
	git submodule init
	git config submodule.suite/audio-sync/vendor/tree-sitter-cpp.url "$srcdir/tree-sitter-cpp"
	git -c protocol.file.allow=always submodule update
	
	cd "$srcdir/$pkgname/third_party/dynarmic/externals/zydis"
	git submodule init
	git config submodule.dependencies/zycore.url "$srcdir/zycore"
	git -c protocol.file.allow=always submodule update

	cd "$srcdir/$pkgname/third_party/luv"
	git submodule init
	for submodule in {libuv,luajit,lua,lua-compat-5.3};
	do
		git config submodule.${submodule}.url "$srcdir/$submodule"
	done
	git -c protocol.file.allow=always submodule update
}

build() {
	cd "$srcdir"
	export CFLAGS="$CFLAGS -flto=thin"
	export CXXFLAGS="$CXXFLAGS -flto=thin"
	_cmake_args=(
	-DCMAKE_INSTALL_PREFIX=/usr
	-DCMAKE_BUILD_TYPE=None
	-DBUILD_EXAMPLES=OFF
	-DBUILD_TESTING=OFF
	-DBUILD_TESTS=OFF
	-DENABLE_USER_BUILD=ON
	-DENABLE_VULKAN=ON
	-DUSE_SYSTEM_SDL2=ON
	-GNinja
	-DCMAKE_C_COMPILER=clang
	-DCMAKE_CXX_COMPILER=clang++
	)

	cmake -S $pkgname -B build ${_cmake_args[@]}

	cmake --build build

	_cmake_args+=(
	-DENABLE_QT_GUI=ON
	)

	cmake -S $pkgname -B buildqt ${_cmake_args[@]}

	cmake --build buildqt

	gendesk -f \
	--pkgname=$pkgname \
	--pkgdesc="$pkgdesc" \
	--name=Panda3DS \
	--exec=panda3ds-qt \
	--icon=panda3ds \
	--terminal=false \
	--categories="Games"
}

package() {
	cd "$srcdir"
	install -Dm755 "$srcdir/build/Alber" "$pkgdir/usr/lib/$pkgname/$pkgname"
	install -Dm755 "$srcdir/buildqt/Alber" "$pkgdir/usr/lib/$pkgname/$pkgname-qt"
	install -Dm644 "$srcdir/$pkgname/docs/img/Alber.png" "$pkgdir/usr/share/icons/hicolor/512x512/apps/$pkgname.png"
	install -dm755 "$pkgdir/usr/bin"
	cat > "$pkgdir/usr/bin/$pkgname" <<EOF
#!/usr/bin/env bash
cd "\$HOME/.config" || exit
[[ ! -d "\$HOME/.config/$pkgname" ]] && mkdir $pkgname
cd "\$HOME/.config/$pkgname" || exit

cd "\$HOME/.config/$pkgname" || exit
/usr/lib/$pkgname/$pkgname "\$@"
wait
exit
EOF

	cat > "$pkgdir/usr/bin/$pkgname-qt" <<EOF
#!/usr/bin/env bash

cd "\$HOME/.config/" || exit
[[ ! -d "\$HOME/.config/$pkgname" ]] && mkdir $pkgname
cd "\$HOME/.config/$pkgname" || exit

QT_QPA_PLATFORM=xcb /usr/lib/$pkgname/$pkgname-qt "\$@"
wait
exit
EOF
	chmod 755 "$pkgdir/usr/bin/$pkgname"
	chmod 755 "$pkgdir/usr/bin/$pkgname-qt"

	install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
}