#!/usr/bin/make -f

include /usr/share/dpkg/architecture.mk

XVFB_OPTS = --auto-servernum --server-num=20 -s "-ac +extension GLX -noreset"

IGNORED_TESTS =

ifeq ($(DEB_HOST_ARCH_ENDIAN),big)
# TODO These tests have non-obvious issues with endianness, which I could
# not figure out yet.
IGNORED_TESTS += \
	tests/test_compute_shader.py \
	tests/test_spirv_parsing.py \
	tests/test_vertex_attribute_double_types.py
endif

export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export PYBUILD_NAME = moderngl
export PYBUILD_TEST_CUSTOM = 1
export PYBUILD_TEST_ARGS= xvfb-run $(XVFB_OPTS) {interpreter} -m pytest -k "not (test_local or test_documentation or test_module_integrity)" $(addprefix --ignore=,$(IGNORED_TESTS))

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_test:
	dh_auto_test --buildsystem=pybuild

execute_after_dh_auto_build:
ifeq (,$(filter nodoc,$(DEB_BUILD_OPTIONS)))
	PYTHONPATH=$(shell pybuild --print {build_dir} --interpreter python3) \
		sphinx-build -M html $(CURDIR)/docs $(CURDIR)/docs/_build
endif

