# Contributor: TBK <alpine@jjtc.eu>
# Maintainer: lauren n. liberda <lauren@selfisekai.rocks>
pkgname=gn
pkgver=0_git20240402
pkgrel=0
_commit=415b3b19e094cd4b6982147693485df65037f942
pkgdesc="Meta-build system that generates build files for Ninja"
arch="all"
url="https://gn.googlesource.com/gn"
license="BSD-3-Clause"
depends="samurai"
makedepends="python3 zstd"
# gitiles has no clones
source="https://ab-sn.lnl.gay/gn-$_commit.tar.zst
	lfs64.patch
	"
builddir="$srcdir/gn"

_distbucket="sakamoto/lnl-aports-snapshots/"
snapshot() {
	clean
	deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone https://gn.googlesource.com/gn
	(
		cd gn
		git checkout -q $_commit
		python3 ./build/gen.py
	)
	rm -rf gn/.git
	tar cf gn-$_commit.tar gn
	zstd --auto-threads=logical --ultra --long -22 -T"${ZSTD_LIMIT:-0}" -vv gn-$_commit.tar \
		-o "$SRCDEST"/gn-$_commit.tar.zst
	mcli cp "$SRCDEST"/gn-$_commit.tar.zst "$_distbucket"
}

build() {
	unset CFLAGS # all sources C++ but passes both
	CXXFLAGS="$CXXFLAGS -flto=auto" \
	python3 ./build/gen.py \
		--no-last-commit-position \
		--no-static-libstdc++ \
		--no-strip \
		--allow-warnings
	ninja -C out
}

check() {
	./out/gn_unittests
}

package() {
	install -Dm755 out/gn "$pkgdir"/usr/bin/gn
}

sha512sums="
a601bba2c16f3fe04b866d198affe483ebdf86e78ad710b165fb7f38e467b4d306d769682a44bda1c04407dd8c4b66803c2eb02222fcf24021714a1786ec1aa8  gn-415b3b19e094cd4b6982147693485df65037f942.tar.zst
76138e5471b4f6d23cb3e09bba68622fd1cb6a96cc52cb97752e8ccbce952fc509468b6c036844699c567346414035cadd6be105bc5ba6e680b73856109bdc37  lfs64.patch
"
