# Contributor: Andreas Røsdal <andreas.rosdal@gmail.com>
# Maintainer: Andreas Røsdal <andreas.rosdal@gmail.com>
pkgname=nordstjernen
pkgver=1.0.33
pkgrel=0
pkgdesc="Small, hand-written web browser written in C with GTK 4 and libcurl"
url="https://nordstjernen.org"
# quickjs is vendored C and the HTML/URL parsers are in-tree Rust; the engine also links
# a little C++ (glslang, libavif). Restrict to arches the deps + WAMR asm cover.
arch="x86_64 aarch64"
license="LicenseRef-NSL-1.0 OR GPL-3.0-or-later"
makedepends="
	meson
	rust
	ninja
	gtk4.0-dev
	libepoxy-dev
	curl-dev
	openssl-dev
	uchardet-dev
	libpsl-dev
	sqlite-dev
	libseccomp-dev
	libwebp-dev
	libavif-dev
	ffmpeg-dev
	fontconfig-dev
	freetype-dev
	pango-dev
	brotli-dev
	libjxl-dev
	gstreamer-dev
	gst-plugins-base-dev
	enchant2-dev
	sdl3-dev
	glslang-dev
	"
_pdfjs=pdfjs-dist-6.5.438.tgz
_wuffs=wuffs-0.4.0-alpha.12.tar.gz
_wamr=wasm-micro-runtime-WAMR-2.4.6.tar.gz
source="$pkgname-$pkgver.tar.gz::https://github.com/nordstjernen-web/nordstjernen-sol-browser/archive/refs/tags/$pkgver.tar.gz
	$_pdfjs::https://registry.npmjs.org/pdfjs-dist/-/$_pdfjs
	$_wuffs::https://github.com/google/wuffs/archive/refs/tags/v0.4.0-alpha.12.tar.gz
	$_wamr::https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-2.4.6.tar.gz
	"
# GitHub names the archive root after the repository, not after $pkgname.
builddir="$srcdir/nordstjernen-sol-browser-$pkgver"
# No test suite upstream — behaviour is verified by running the browser.
options="!check"

# PDF.js, Wuffs and WAMR come from these pinned tarballs (the wraps in
# subprojects/) instead of being downloaded during the build.
prepare() {
	default_prepare
	mkdir -p subprojects/packagecache
	cp "$srcdir"/$_pdfjs "$srcdir"/$_wuffs "$srcdir"/$_wamr subprojects/packagecache/
}

build() {
	abuild-meson -Dwebgpu=disabled . output
	meson compile -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
	install -Dm644 License.md \
		"$pkgdir"/usr/share/licenses/$pkgname/License.md
	install -Dm644 COPYING \
		"$pkgdir"/usr/share/licenses/$pkgname/COPYING
}

# Regenerate with `abuild checksum` whenever pkgver moves.
sha512sums="
1a332d71763009d7dacb758c0e4bf0288f5ed39e1d2252804fcc6f5258a20596507bd8503019920eb06a770fa55e5f31da81d899ce109be5ddedd40f25f2951d  nordstjernen-1.0.33.tar.gz
be0f0fc35c7e0052b2e00303be1b9697970e615f1debdf14a0400da0516173bf61a970e7650aa7397a31c371c6f74ed61ce8352583af2e13fbe7a6e875d171a4  pdfjs-dist-6.5.438.tgz
8349ab42d0e012365e9dc1e3d2cfafdaf418b52c3d08dc715fdafe93bffa12ec110876a47d7d6c8f24c113d7b3773da7b2f2ee00bedf5428332264984f4465bd  wuffs-0.4.0-alpha.12.tar.gz
8737b3e92fccb2fab9384485a76f4b8994bcba47ce0452545a6b8205b2d3cd3f8a2869c81fa03a2e1fabcb534838fc4ce937087746b112e48b1ef6386c388dfd  wasm-micro-runtime-WAMR-2.4.6.tar.gz
"
