summaryrefslogtreecommitdiff
path: root/games-emulation/eden/eden-9999.ebuild
blob: adb2fd2b46579084c30c5d1134e285067739c74b (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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake xdg toolchain-funcs optfeature

DESCRIPTION="Nintendo Switch Emulator"
HOMEPAGE="https://eden-emu.dev"

if [[ "${PV}" == 9999 ]]; then
	inherit git-r3
	EGIT_REPO_URI="https://git.eden-emu.dev/eden-emu/eden.git"
	EGIT_CLONE_TYPE="shallow"
	EGIT_CHECKOUT_DIR="${WORKDIR}/${PN}"
else
	KEYWORDS="~amd64 ~arm64"
	SRC_URI="
		https://git.eden-emu.dev/eden-emu/eden/archive/v${PV/_/-}.tar.gz -> ${P}.tar.gz
	"
fi

_TZDB_VER=121125
SRC_URI+="
	https://git.eden-emu.dev/eden-emu/tzdb_to_nx/releases/download/${_TZDB_VER}/${_TZDB_VER}.tar.gz ->
		nx-tzdb-${_TZDB_VER}.tar.gz
"

S="${WORKDIR}/${PN}"

LICENSE="GPL-3+"
SLOT="0"
IUSE="camera +cubeb discord llvm lto +opengl +qt6 room sdl test +usb web-applet web-service wifi"
REQUIRED_USE="
	!qt6? ( !camera !discord !web-applet )
	web-service? ( || ( qt6 room ) )
"

RESTRICT="!test? ( test )"

RDEPEND="
	app-arch/lz4
	app-arch/zstd
	dev-cpp/cpp-httplib:=[ssl]
	dev-libs/libfmt:=
	dev-libs/mcl
	dev-libs/openssl:=
	>=dev-libs/sirit-1.0.1
	dev-util/spirv-tools
	games-util/gamemode
	media-gfx/renderdoc
	media-libs/libsdl3[udev]
	media-libs/libva
	media-video/ffmpeg[opus]
	net-libs/enet
	net-libs/mbedtls:3
	virtual/zlib:=

	camera? ( dev-qt/qtmultimedia:6 )
	cubeb? ( media-libs/cubeb )
	discord? (
		dev-libs/discord-rpc
	)
	qt6? (
		dev-libs/quazip[qt6(+)]
		dev-qt/qtbase:6[concurrent,dbus,gui,widgets]
		dev-qt/qtcharts:6
	)
	usb? ( dev-libs/libusb )
	web-applet? ( dev-qt/qtwebengine:6[widgets] )
	web-service? ( dev-cpp/cpp-httplib:=[ssl] )
	wifi? ( net-wireless/wireless-tools )
	llvm? ( llvm-core/llvm )
"
DEPEND="
	${RDEPEND}
	dev-cpp/nlohmann_json
	dev-cpp/simpleini
	dev-libs/boost:=[context]
	dev-libs/frozen
	dev-util/spirv-headers
	dev-util/vulkan-headers
	dev-util/vulkan-utility-libraries
	media-libs/VulkanMemoryAllocator

	amd64? ( dev-libs/xbyak )
	arm64? ( dev-libs/oaknut )
	x86? ( dev-libs/xbyak )

	web-service? ( dev-cpp/cpp-jwt )

	test? ( dev-libs/oaknut )
"
BDEPEND="
	app-arch/unzip
	dev-util/glslang
	virtual/pkgconfig

	test? ( dev-cpp/catch )
"

# [directory]=license
declare -A KEEP_BUNDLED=(
	# Generated or copied files for internal usage
	[bc_decoder]=MPL-2.0
	[cmake-modules]=LGPL-3+
	[demangle]=Apache-2.0-with-LLVM-exceptions
	[FidelityFX-FSR]=MIT
	[glad]=GPL-2+
	[nx_tzdb]="GPL-2+"
	[stb]="MIT public-domain"
	[tz]=BSD-2

	# Configuration for the system library
	[libusb]=GPL-3+
)

add_bundled_licenses() {
	for license in "${KEEP_BUNDLED[@]}"; do
		if [[ -n "$license" ]]; then
			LICENSE+=" ${license}"
		fi
	done
}
add_bundled_licenses

src_unpack() {
	git-r3_src_unpack

	# unpack src files
	unpack "${A}"
}

src_prepare() {
	local s remove=()
	for s in externals/*; do
		[[ -f ${s} ]] && continue
		if ! has "${s#externals/}" "${!KEEP_BUNDLED[@]}"; then
			remove+=( "${s}" )
		fi
	done

	if [[ -n "${remove}" ]]; then
		einfo "removing sources: ${remove[*]}"
		rm -r "${remove[@]}" || die
	fi

	cmake_src_prepare
}

src_configure() {
	if [[ "${PV}" == 9999 ]]; then
		eden_ver="$(git rev-parse --short=10 HEAD)-9999"
	else
		eden_ver="v${PV/_/-}"
	fi

	if tc-is-gcc; then
		eden_comp_id="GCC $(gcc-fullversion)"
	elif tc-is-clang; then
		eden_comp_id="Clang $(clang-fullversion)"
	else
		eden_comp_id="$(tc-getcc)"
	fi

	local mycmakeargs=(
		-DCPMUTIL_FORCE_SYSTEM=yes
		-DTITLE_BAR_FORMAT_IDLE="Eden | ${eden_ver} | ${eden_comp_id}"
		-DYUZU_TZDB_PATH="${WORKDIR}/nx-tzdb-${_TZDB_VER}"
		-DUSE_FASTER_LINKER=no

		-DENABLE_LTO=$(usex lto)

		-DDYNARMIC_USE_LLVM=$(usex llvm)
		-DYUZU_DISABLE_LLVM=$(usex !llvm)

		-DBUILD_TESTING=$(usex test)
		-DENABLE_CUBEB=$(usex cubeb)
		-DENABLE_LIBUSB=$(usex usb)
		-DENABLE_OPENGL=$(usex opengl)
		-DENABLE_QT=$(usex qt6)
		-DENABLE_WEB_SERVICE=$(usex web-service)
		-DENABLE_WIFI_SCAN=$(usex wifi)
		-DUSE_DISCORD_PRESENCE=$(usex discord)
		-DYUZU_USE_QT_MULTIMEDIA=$(usex camera)
		-DYUZU_USE_QT_WEB_ENGINE=$(usex web-applet)

		-DYUZU_CMD=$(usex sdl)
		-DYUZU_ROOM=$(usex room)

		-Wno-dev
	)

	cmake_src_configure
}

src_test() {
	cd "${BUILD_DIR}" || die

	./bin/dynarmic_tests || die

	# See https://git.eden-emu.dev/eden-emu/eden/issues/126
	./bin/tests "~Fibers::InterExchange" "~RingBuffer: Threaded Test" || die
}

pkg_postinst() {
	xdg_pkg_postinst

	optfeature_header "SDL requires HIDRAW access for many controller gyroscopes to work."
	optfeature "HIDRAW support" games-util/game-device-udev-rules
}