# Template file for 'gamescope'
pkgname=gamescope
version=3.16.1
revision=1
_stb_hash=5736b15f7ea0ffb08dd38af21067c314d6a3aae9
_vkroots_hash=5106d8a0df95de66cc58dc1ea37e69c99afc9540
_reshade_hash=696b14cd6006ae9ca174e6164450619ace043283
_spirv_hash=d790ced752b5bfc06b6988baadef6eb2d16bdf96
_libdisplay_info_hash=66b802d05b374cd8f388dc6ad1e7ae4f08cb3300
_libliftoff_hash=8b08dc1c14fd019cc90ddabe34ad16596b0691f4
_wlroots_hash=4bc5333a2cbba0b0b88559f281dbde04b849e6ef
build_style=meson
configure_args="-Denable_openvr_support=false"
hostmakedepends="glslang pkg-config wayland-devel hwids"
makedepends="pipewire-devel SPIRV-Headers libX11-devel
 libXdamage-devel libXcomposite-devel libXrender-devel libXxf86vm-devel
 libXtst-devel libXres-devel libXmu-devel libdrm-devel vulkan-loader-devel
 libxkbcommon-devel libcap-devel LuaJIT-devel SDL2-devel glm benchmark-devel pixman-devel
 libinput-devel libseat-devel libavif-devel libei-devel xcb-util-wm-devel
 wayland-protocols xorg-server-xwayland"
depends="xorg-server-xwayland"
short_desc="SteamOS session compositing window manager"
maintainer="Dexter Gaon-Shatford <dexter.gaonshatford@gmail.com>"
license="BSD-2-Clause, BSD-3-Clause, MIT"
homepage="https://github.com/ValveSoftware/gamescope"
distfiles="https://github.com/ValveSoftware/gamescope/archive/refs/tags/${version}.tar.gz
 https://github.com/nothings/stb/archive/${_stb_hash}.tar.gz
 https://github.com/Joshua-Ashton/vkroots/archive/${_vkroots_hash}.tar.gz
 https://github.com/Joshua-Ashton/reshade/archive/${_reshade_hash}.tar.gz
 https://github.com/KhronosGroup/SPIRV-Headers/archive/${_spirv_hash}.tar.gz
 https://gitlab.freedesktop.org/emersion/libdisplay-info/-/archive/${_libdisplay_info_hash}/libdisplay-info-${_libdisplay_info_hash}.tar.gz
 https://gitlab.freedesktop.org/emersion/libliftoff/-/archive/${_libliftoff_hash}/libliftoff-${_libliftoff_hash}.tar.gz
 https://github.com/Joshua-Ashton/wlroots/archive/${_wlroots_hash}.tar.gz"
checksum="acaa77c80670357ed29b8aacd59cc960b7314eb092ca8f2a2f127c456d2ae281
 d00921d49b06af62aa6bfb97c1b136bec661dd11dd4eecbcb0da1f6da7cedb4c
 37b77586e91f7ebee70380dcddd73bf01ae4acef1053e6be41d0485ede022422
 3aa6feda7773cc8ffa8fb012fe95e6207c776101e29198d0e0d34a0c5e339f6a
 90141b3f6261dba643fe546d56b4539e61fe40e307c5c3b9985ea9fa0622ac3f
 bca0664e23671572311b3b91f3b2fff3fd6501940320a8daff5e11b5219554a4
 8de28aee6f90f47b7fc7037dcd2360166197c0b5d2033f3afdbd34f2ea1bf216
 41272ce410c2815de1e268f5baa906b26286bb910e514677d15b8e69f81c5a04"
skip_extraction="${_stb_hash}.tar.gz
 ${_vkroots_hash}.tar.gz
 ${_reshade_hash}.tar.gz
 ${_spirv_hash}.tar.gz
 libdisplay-info-${_libdisplay_info_hash}.tar.gz
 libliftoff-${_libliftoff_hash}.tar.gz
 ${_wlroots_hash}.tar.gz"

# wlroots and libliftoff fail to build because of these warnings
CFLAGS="-Wno-error=unused-variable
 -Wno-error=unused-but-set-variable
 -Wno-error=unused-result
 -Wno-error=return-type"

if [ "$XBPS_CHECK_PKGS" ]; then
	# The libliftoff test suite checks for NDEBUG and fails if it is defined,
	# even if all other tests would pass
	CFLAGS+=" -UNDEBUG"
fi

post_extract() {
	vsrcextract -C subprojects/stb "${_stb_hash}.tar.gz"
	cp subprojects/packagefiles/stb/meson.build subprojects/stb
	vsrcextract -C subprojects/vkroots "${_vkroots_hash}.tar.gz"
	vsrcextract -C src/reshade "${_reshade_hash}.tar.gz"
	vsrcextract -C thirdparty/SPIRV-Headers "${_spirv_hash}.tar.gz"
	vsrcextract -C subprojects/libdisplay-info "libdisplay-info-${_libdisplay_info_hash}.tar.gz"
	vsrcextract -C subprojects/libliftoff "libliftoff-${_libliftoff_hash}.tar.gz"
	vsrcextract -C subprojects/wlroots "${_wlroots_hash}.tar.gz"
}

post_patch() {
	# libdisplay-info tests require currently unpackaged edid-decode
	vsed -i subprojects/libdisplay-info/meson.build -e "s/subdir('test')//"
	echo "${version}" > voidlinux_pkg_version.txt
}

post_install() {
	vlicense LICENSE

	rm ${DESTDIR}/usr/include/vkroots.h
	rm ${DESTDIR}/usr/lib/pkgconfig/vkroots.pc

	rm ${DESTDIR}/usr/include/libliftoff.h
	rm ${DESTDIR}/usr/lib/pkgconfig/libliftoff.pc
	rm ${DESTDIR}/usr/lib/libliftoff.a

	rm -r ${DESTDIR}/usr/include/wlroots*
	rm ${DESTDIR}/usr/lib/pkgconfig/wlroots*.pc
	rm ${DESTDIR}/usr/lib/libwlroots*.a

	rm ${DESTDIR}/usr/bin/di-edid-decode
	rm -r ${DESTDIR}/usr/include/libdisplay-info
	rm ${DESTDIR}/usr/lib/pkgconfig/libdisplay-info.pc
	rm ${DESTDIR}/usr/lib/libdisplay-info.a
}
