# Contributor: Zach DeCook <zachdecook@librem.one>
maintainer="Zach DeCook <zachdecook@librem.one>"
pkgname=hyprcursor
pkgver=0.1.12
pkgrel=0
pkgdesc="The hyprland cursor format, library and utilities."
url="https://github.com/hyprwm/Hyprcursor"
arch="all"
license="BSD-3-Clause"
source="
	https://github.com/hyprwm/Hyprcursor/archive/v$pkgver/Hyprcursor-v$pkgver.tar.gz
"
makedepends="
	cairo-dev
	cmake
	hyprlang-dev
	librsvg-dev
	libzip-dev
	samurai
	tomlplusplus-dev
	"
checkdepends="adwaita-icon-theme xcur2png"
subpackages="$pkgname-dev $pkgname-doc $pkgname-util"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_BUILD_TYPE=None
	cmake --build build
}

check() {
	# Pre-emptively clean up in case it wasn't cleaned up before
	rm -rf ~/.local/share/icons/theme_Adwaita
	cd build
	# Create a hyprcursor, so that the tests will work
	./hyprcursor-util -x /usr/share/icons/Adwaita/ -o ./
	sed -i "s/name = .*/name = Adwaita/g" extracted_Adwaita/manifest.hl
	# Put this in one of the paths it will search
	mkdir -p ~/.local/share/icons/
	./hyprcursor-util -c ./extracted_Adwaita -o ~/.local/share/icons/
	# run the tests
	LD_LIBRARY_PATH=./ ctest
	# Clean up afterwards
	rm -r ~/.local/share/icons/theme_Adwaita
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
	install -Dm644 -t "$pkgdir"/usr/share/doc/hyprcursor docs/*
	install -Dm644 hyprcursor-util/README.md "$pkgdir"/usr/share/doc/hyprcursor/README.md
}

util() {
	depends="xcur2png"
	amove usr/bin/hyprcursor-util
}


sha512sums="
2ebe8b424905ada5db00625fa839d0475815f5fce44dc50d5528e7f4e5d5684bc6a8e4b1e254dbca2fe42e80eb79efbd57371e0a37bec91939d81a91fb45a34c  Hyprcursor-v0.1.12.tar.gz
"
