# Contributor: Anjandev Momi <anjan@momi.ca>
# Maintainer: Anjandev Momi <anjan@momi.ca>
pkgname=py3-pynest2d
pkgver=5.2.2
pkgrel=2
pkgdesc="Python bindings for libnest2d"
url="https://github.com/Ultimaker/pynest2d"
arch="all"
license="LGPL-3.0-or-later"
makedepends="samurai cmake libnest2d-dev clipper-dev py3-sip nlopt-dev boost-dev python3-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/Ultimaker/pynest2d/archive/refs/tags/$pkgver.tar.gz
	cmake.patch
	cmake-helpers.patch
	pyproject.patch"
builddir="$srcdir/pynest2d-$pkgver"
options="!check" # doesn't seem like tests are packaged anymore

prepare() {
	mv ./python ./src
	default_prepare
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=Release \
		$CMAKE_CROSSOPTS
	cmake --build build
}

check() {
	cd build
	CTEST_OUTPUT_ON_FAILURE=TRUE ctest
}

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

sha512sums="
f5d701e431c81f8d2da7b14ca5677d3303064cf7910e80d289d7ff8fe99117fb9c470242f25f21fa8e1f064c63accf5349f4956981e316b09b14342223f79b61  py3-pynest2d-5.2.2.tar.gz
c8133d221a2fd8ed5fb32933a69f992dab2e83cdb9db30dcb715ebdfe6d403be3e94df393a921f506b63ef9d8b30a107f26b57cd39810faa9bee461afe5e1afd  cmake.patch
dbf6609a21e39ae87fa89f2faf9c98a011f287cb383c5b74f92f41e3a350b487e69643c94110f7fcc25e9e25921a698cc20d9ee021d36ff908d03c0d5ca88a46  cmake-helpers.patch
f1b710509d97b5a2a4d021747e73884d27ae00fd93a04c90be01f123cdcc59be4757b4a73dff9c9921b7794551e531cf6729e4211144c60294d107b92a928b51  pyproject.patch
"
