# Maintainer: Pierre-Loup A. Griffais <pgriffais@valvesoftware.com>

# This is just for the Gamescope WSI layer.

pkgname=lib32-gamescope
_srctag=3.16.2
pkgver=${_srctag//-/.}
pkgrel=1.2
pkgdesc="gaming shell based on Xwayland, powered by Vulkan and DRM (32-bit)"
arch=(x86_64)
url="https://github.com/Plagman/gamescope"
license=('MIT')
depends=('lib32-wayland' 'lib32-libx11' 'lib32-libxcb' 'lib32-vulkan-icd-loader')
makedepends=(openssh git meson cmake wayland-protocols ninja glslang glm vulkan-headers lib32-glm)
source=("lib32-gamescope::git+https://github.com/ValveSoftware/gamescope.git#tag=$_srctag")
sha256sums=('928b91e4ee11d9b7f7cdc092632f6337da2ae1bb394089663df5a45699ab1b9b')

prepare() {
	cd "$pkgname"
}

build() {
	cd "$pkgname"

	export CC="gcc -m32"
	export CXX="g++ -m32"
	export PKG_CONFIG="i686-pc-linux-gnu-pkg-config"

	rm -rf build
	mkdir build
	cd build
	arch-meson --libdir=/usr/lib32 -Denable_gamescope=false -Denable_gamescope_wsi_layer=true -Denable_openvr_support=false -Dpipewire=disabled --buildtype release --prefix /usr ..
	ninja
}

package() {
	cd "$pkgname/build"

	DESTDIR="$pkgdir" meson install --skip-subprojects

	rm -rf "$pkgdir"/usr/include
	rm -rf "$pkgdir"/usr/lib/libwlroots*
	rm -rf "$pkgdir"/usr/lib32/libwlroots*
	rm -rf "$pkgdir"/usr/lib/pkgconfig
	rm -rf "$pkgdir"/usr/lib32/pkgconfig
	rm -rf "$pkgdir"/usr/share/gamescope/scripts
}
