# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Francesco Colista <fcolista@alpinelinux.org>
pkgname=picom
pkgver=12.5
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="
	asciidoctor
	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="
	bash
	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")"

	# Disable glx test
	sed -i 's/test_with_backend glx/# test_with_backend glx/' ./tests/run_one_test.sh
	xvfb-run -a ./tests/run_tests.sh build/src/picom
}

sha512sums="
e4e8d8d6edc5fd5115ee880ee36e3b217b07336e09c457a3eb9a4824c19ac4f98ae807c3a902f327e7a2d036e2ae2d1ab2a5da8bdee47e33e49faebf4893a78b  picom-12.5.tar.gz
"
