# Maintainer: gbr <gbr at pm dot me>

pkgname=notes-git
_pkgname=${pkgname%-git}
pkgver=2.3.1.r60.g5d2bbff
pkgrel=1
pkgdesc="Note taking application, write down your thoughts"
arch=('x86_64')
url="https://www.notes-foss.com"
license=('MPL-2.0')
makedepends=('cmake' 'git')
depends=('hicolor-icon-theme' 'qt6-base' 'qt6-declarative' 'qt6-quick3d')
provides=("${_pkgname}")
conflicts=("${_pkgname}")
source=("git+https://github.com/nuttyartist/${_pkgname}"
	'git+https://github.com/b00f/qautostart.git'
	'git+https://github.com/pbek/qmarkdowntextedit.git')
sha256sums=('SKIP'
            'SKIP'
            'SKIP')

pkgver() {
	cd "${_pkgname}/"
	git describe --long --abbrev=7 | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

prepare() {
	cd "${_pkgname}/"
	git rm 3rdParty/QSimpleUpdater

	git submodule init
	git submodule set-url 3rdParty/qautostart "${srcdir}/qautostart/"
	git submodule set-url 3rdParty/qmarkdowntextedit "${srcdir}/qmarkdowntextedit/"
	git -c protocol.file.allow=always submodule update
}

build() {
	cmake -B build \
		-S "${_pkgname}/" \
		-D CMAKE_BUILD_TYPE=Release \
		-D CMAKE_INSTALL_PREFIX=/usr \
		-D UPDATE_CHECKER=OFF \
		-D GIT_REVISION=ON

	cmake --build build
}

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