summaryrefslogtreecommitdiff
blob: bdd694c0a1c5346ca3b3d047513cab8a7969e6c5 (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
# Copyright 1999-2022 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

WX_GTK_VER="3.0-gtk3"
inherit cmake fcaps flag-o-matic git-r3 toolchain-funcs wxwidgets

DESCRIPTION="A PlayStation 2 emulator"
HOMEPAGE="https://pcsx2.net/"
EGIT_REPO_URI="https://github.com/PCSX2/${PN}.git"
EGIT_SUBMODULES=(
	3rdparty/glslang/glslang # needs StandAlone/ResourceLimits.h
	3rdparty/imgui/imgui # not made to be system-wide
	3rdparty/vulkan-headers # to keep in sync with glslang
)

LICENSE="GPL-3 Apache-2.0 OFL-1.1" # TODO: needs review for a full list
SLOT="0"
KEYWORDS=""
IUSE="pulseaudio test"

RESTRICT="!test? ( test )"

RDEPEND="
	app-arch/xz-utils
	dev-cpp/rapidyaml:=
	dev-libs/glib:2
	dev-libs/libaio
	dev-libs/libchdr
	>=dev-libs/libfmt-7.1.3:=
	dev-libs/libxml2:2
	media-libs/alsa-lib
	media-libs/cubeb
	media-libs/freetype
	media-libs/libglvnd
	media-libs/libpng:=
	media-libs/libsamplerate
	media-libs/libsdl2[haptic,joystick,sound]
	media-libs/libsoundtouch:=
	net-libs/libpcap
	sys-libs/zlib
	virtual/libudev:=
	x11-libs/gdk-pixbuf:2
	x11-libs/gtk+:3
	x11-libs/libICE
	x11-libs/libX11
	x11-libs/libXext
	x11-libs/libXrandr
	x11-libs/wxGTK:${WX_GTK_VER}[X]
	pulseaudio? ( media-sound/pulseaudio )
"
DEPEND="
	${RDEPEND}
	x11-base/xorg-proto"
BDEPEND="test? ( dev-cpp/gtest )"

FILECAPS=(
	-m 755 "CAP_NET_RAW+eip CAP_NET_ADMIN+eip" usr/bin/pcsx2
)

pkg_setup() {
	if [[ ${MERGE_TYPE} != binary && $(tc-getCC) == *gcc* ]]; then
		# -mxsave flag is needed when GCC >= 8.2 is used
		# https://bugs.gentoo.org/685156
		if [[ $(gcc-major-version) -gt 8 || $(gcc-major-version) == 8 && $(gcc-minor-version) -ge 2 ]]; then
			append-flags -mxsave
		fi
	fi
}

src_prepare() {
	cmake_src_prepare

	# unbundle, use sed over patch for less chances to break -9999
	sed -e '/add_subdir.*cubeb/c\find_package(cubeb REQUIRED)' \
		-e '/add_subdir.*libchdr/c\pkg_check_modules(chdr REQUIRED IMPORTED_TARGET libchdr)' \
		-e '/compile_options(\(cubeb\|chdr-static\|speex\)/d' \
		-i cmake/SearchForStuff.cmake || die
	sed -i 's/chdr-static/PkgConfig::chdr/' pcsx2/CMakeLists.txt || die

	# pulseaudio is only used for usb-mic, not audio output
	use pulseaudio || > cmake/FindPulseAudio.cmake || die
}

src_configure() {
	# Build with ld.gold fails
	# https://github.com/PCSX2/pcsx2/issues/1671
	tc-ld-disable-gold

	# pcsx2 build scripts will force CMAKE_BUILD_TYPE=Devel
	# if it something other than "Devel|Debug|Release"
	local CMAKE_BUILD_TYPE="Release"
	local mycmakeargs=(
		-DARCH_FLAG=
		-DBUILD_SHARED_LIBS=FALSE
		-DDISABLE_BUILD_DATE=TRUE
		-DDISABLE_PCSX2_WRAPPER=TRUE
		-DDISABLE_SETCAP=TRUE
		-DENABLE_TESTS=$(usex test)
		-DPACKAGE_MODE=TRUE
		-DSDL2_API=TRUE # uses SDL2 either way but option is needed if wxGTK[sdl]
		-DUSE_SYSTEM_YAML=TRUE
		-DUSE_VTUNE=FALSE
		-DXDG_STD=TRUE
	)

	setup-wxwidgets
	cmake_src_configure
}