# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=picom
pkgver=11.2
pkgrel=0
pkgdesc="X Compositor (a fork of compton)"
url="https://github.com/yshui/picom"
# s390x: tests hang
arch="all !s390x"
license="MIT AND MPL-2.0"
makedepends="
	asciidoc
	dbus-dev
	libconfig-dev
	libdrm-dev
	libev-dev
	libepoxy-dev
	libx11-dev
	libxcomposite-dev
	libxdamage-dev
	libxdg-basedir-dev
	libxinerama-dev
	libxrandr-dev
	mesa-dev
	meson
	pcre2-dev
	pixman-dev
	uthash-dev
	xcb-util-image-dev
	xcb-util-renderutil-dev
	"
checkdepends="
	dbus-x11
	libffi-dev
	py3-dbus-next
	py3-wheel
	py3-xcffib
	python3
	python3-dev
	xvfb-run
	"
subpackages="$pkgname-doc"
source="picom-$pkgver.tar.gz::https://github.com/yshui/picom/archive/v$pkgver.tar.gz"

# one test fails
[ "$CARCH" = "ppc64le" ] && options="$options !check"

replaces="compton" # Backwards compatibility
provides="compton=$pkgver-r$pkgrel" # Backwards compatibility

build() {
	abuild-meson \
		-Db_lto=true \
		-Dwith_docs=true \
		build
	meson compile -C build
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C build

	mkdir -p "$pkgdir/usr/share/doc/picom"
	install -m644 README* "$pkgdir/usr/share/doc/picom/"
	install -D -m644 "picom.sample.conf" "$pkgdir/etc/xdg/picom.conf.example"
}

check() {
	export XDG_RUNTIME_DIR="$(mktemp -d -p "$builddir")"
	xvfb-run -a build/src/picom --config picom.sample.conf --no-vsync --diagnostics
	xvfb-run -a ./tests/run_tests.sh build/src/picom
}

sha512sums="
df8fc1a593e108b37be185129ac1f3a23c2ae648a04352c45b9d5888838e5754c68f2eb684f12f1ed4d973eca0aef83a61789f028c63bc2d0f0f38902232aadc  picom-11.2.tar.gz
"
