#!/usr/bin/make -f

export PYBUILD_NAME=yarf
export PYBUILD_TEST_PYTEST=1
export PYBUILD_TEST_ARGS=yarf

# The wheel excludes every "tests" directory, so copy the unit tests
# next to the built modules (which include the generated Wayland
# bindings) and drop them again afterwards, together with the
# output.xml that Robot writes into the working directory
export PYBUILD_BEFORE_TEST=cd {dir} && cp -r --parents $$(find yarf -type d -name tests) {build_dir}
export PYBUILD_AFTER_TEST=cd {build_dir} && rm -rf output.xml $$(find yarf -type d -name tests)

# Upstream's .gitignore for the generated Wayland bindings ends up in
# the wheel
export PYBUILD_AFTER_INSTALL=rm -f {destdir}/{install_dir}/yarf/lib/wayland/protocols/.gitignore

%:
	dh $@ --buildsystem=pybuild

# pybuild-autopkgtest runs the tests in an empty
# $AUTOPKGTEST_TMP/build. Put the installed package there so the
# copied unit tests run inside it
before-pybuild-autopkgtest:
	mkdir -p $(AUTOPKGTEST_TMP)/build
	cp -r /usr/lib/python3/dist-packages/yarf $(AUTOPKGTEST_TMP)/build/
