# Maintainer: Marian Buschsieweke <marian.buschsieweke@posteo.net>
# Contributor: Marian Buschsieweke <marian.buschsieweke@posteo.net>
pkgname=kicad-library
pkgver=8.0.7
pkgrel=0
pkgdesc="KiCad component and footprint libraries"
url="https://kicad.github.io/"
# limited by kicad
arch="noarch !armv7 !armhf !riscv64 !s390x"
license="GPL-3.0-or-later"
makedepends="cmake samurai"
depends="kicad"
subpackages="$pkgname-3d:three_d"
source="
	https://gitlab.com/kicad/libraries/kicad-symbols/-/archive/$pkgver/kicad-symbols-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-footprints/-/archive/$pkgver/kicad-footprints-$pkgver.tar.gz
	https://gitlab.com/kicad/libraries/kicad-packages3D/-/archive/$pkgver/kicad-packages3D-$pkgver.tar.gz
	"
options="!check" # package only provides data files, so not tests possible

build() {
	cd "$srcdir"/kicad-symbols-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-footprints-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build

	cd "$srcdir"/kicad-packages3D-$pkgver
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-symbols-$pkgver/build
	DESTDIR="$pkgdir" cmake --install "$srcdir"/kicad-footprints-$pkgver/build
}

three_d() {
	pkgdesc="3D models for KiCad component and footprint libraries"
	depends="$pkgname"
	DESTDIR="$subpkgdir" cmake --install "$srcdir"/kicad-packages3D-$pkgver/build

	# Remove .step version of 3D models; only .wrl versions are needed
	find "$subpkgdir" -name '*.step' -exec rm {} \;
}

sha512sums="
45770c99f6f65ea233910a6442096ea471f19f7e5deffb41cd4f4c048261cc6d95bd2bd3f75f6216e4e18117045c970c3d726720f216436979ee03c6ae439336  kicad-symbols-8.0.7.tar.gz
6a98c6d904675184f062cb77cfee1b4d6da05fd41a5ed75841b62496f7be8f73c8085579c419e0af98afc112eb587ac5a766bfbbb15a90c92b2d9973647da798  kicad-footprints-8.0.7.tar.gz
f01291fc3a87a361c52b5c82f8a0d287f8a266b78875e07ffc370883a6adf6c80c59cc7ce010ebc1f776b36cffd751a43433bc743609e7efc6ef2fd3f09781aa  kicad-packages3D-8.0.7.tar.gz
"
