# Contributor: Bart Ribbers <bribbers@disroot.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=maplibre-gl-native
pkgver=2.0.1
pkgrel=3
pkgdesc="Open-source alternative to Mapbox GL Native"
url="https://maplibre.org/"
arch="all"
license="BSD-2-Clause"
makedepends="
	cmake
	icu-dev
	qt5-qtbase-dev
	rapidjson-dev
	samurai
	"
source="https://dev.alpinelinux.org/archive/maplibre-gl-native/maplibre-gl-native-$pkgver.tar.xz
	cstdint.patch
	"
options="!check" # No tests
subpackages="$pkgname-dev"
builddir="$srcdir/$pkgname"

provides="mapbox-gl-native=$pkgver-r$pkgrel"
replaces="mapbox-gl-native"

_disturl="dev.alpinelinux.org:/archive/$pkgname/"

snapshot() {
	clean
	deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone https://github.com/maplibre/maplibre-gl-native -b qt-v$pkgver --recursive
	tar cv maplibre-gl-native | xz -T0 -9 -vv - > $SRCDEST/$pkgname-$pkgver.tar.xz
	rsync --progress -La $SRCDEST/$pkgname-$pkgver.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We prefer to build with our system version
	rm -r vendor/mapbox-base/extras/rapidjson
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=TRUE \
		-DMBGL_WITH_WERROR=OFF \
		-DMBGL_WITH_QT=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
f4f10b7ebe5f63a153e491d48d25b7ca9b1b83e67dcedfc337976ff82735bbd6f97e828cec1af098077f9259ce4fde78abf4d6488095014b2de486d9223eb384  maplibre-gl-native-2.0.1.tar.xz
948b2febeb200b5b86950424103347d0ecd5d47f08601b2e415c6c4969bc65908530c20ac6f2bceb8f44916779e0e8723d9f7e6f4bf6e156a37e134f4d87a83e  cstdint.patch
"
