# Maintainer: lilydjwg <lilydjwg@gmail.com>
# Contributor: Brett Cornwall <ainola@archlinux.org>
# Contributor: Maxim Baz <$pkgname at maximbaz dot com>
# Contributor: Omar Pakker
pkgname=wlroots-lily-git
_suffixver=0.19
pkgver=0.19.2.20251104.031626
pkgrel=3
license=('MIT')
pkgdesc='Modular Wayland compositor library (with patches, for x86_64_v3)'
url='https://gitlab.freedesktop.org/lilydjwg/wlroots'
arch=('x86_64')
depends=(
    'libdisplay-info.so'
    'libglvnd'
    'libinput'
    'liblcms2.so'
    'libliftoff.so'
    'libpixman-1.so'
    'libseat.so'
    'libudev.so'
    'libvulkan.so'
    'libwayland-client.so'
    'libwayland-server.so'
    'libxcb'
    'libxkbcommon.so'
    'opengl-driver'
    'xcb-util-errors'
    'xcb-util-renderutil'
    'xcb-util-wm'
)
makedepends=(
    'git'
    'glslang'
    'meson'
    'ninja'
    'systemd'
    'vulkan-headers'
    'wayland-protocols'
    'xorg-xwayland'
)
optdepends=(
    'xorg-xwayland: Xwayland support'
    'xorg-xwayland-lily: HiDPI Xwayland support, see https://gitlab.freedesktop.org/xorg/xserver/-/merge_requests/733'
)
provides=(
    "libwlroots-$_suffixver.so"
    "wlroots$_suffixver=$pkgver"
)
conflicts=(
    "wlroots$_suffixver"
)

pkgver() {
  cd "${startdir}/wlroots-lily"
  (
     set -o pipefail
     version=$(grep -zoP "project\([^)]*\)" meson.build | xargs --null echo | grep -oP "^\sversion:\s'\K[^-']*")
     printf "${version}.%s" "$(TZ=UTC git log -1 --pretty='%cd' --date=format-local:%Y%m%d.%H%M%S)"
  )
}

build() {
    arch-meson \
      -Dwerror=false \
      -Dexamples=false \
      -Dcolor-management=enabled \
      "${startdir}/wlroots-lily" build
    ninja -C build
}

package() {
    DESTDIR="$pkgdir" ninja -C build install
    install -Dm644 "${startdir}/wlroots-lily/LICENSE" -t "$pkgdir/usr/share/licenses/$pkgname/"
}
