#!/usr/bin/make -f

export PYTHONDONTWRITEBYTECODE = 1

%:
	dh $@

# GTK reads @media from 4.20 on and rejects the whole rule before that, and upstream's one gtk-4.0
# stylesheet picks its dark palette with it. A build against an older GTK (trixie's 4.18) resolves
# the rules so each theme directory carries its own palette; a newer one ships upstream's files
# as they are (BASED-674).
override_dh_auto_build:
	rm -rf debian/build
	mkdir debian/build
	cp -a adw-gtk3 adw-gtk3-dark debian/build/
	gtk_version="$$(dpkg-query -W -f='$${Version}' libgtk-4-common)" && \
	if dpkg --compare-versions "$$gtk_version" lt 4.20; then \
		python3 debian/resolve_media.py --light debian/build/adw-gtk3 --dark debian/build/adw-gtk3-dark; \
	fi

override_dh_auto_test:
	ADW_GTK3_BUILD=debian/build python3 -m unittest discover -s debian -p 'test_*.py' -v

# Upstream compiles its Sass with dart-sass, which neither Debian nor Ubuntu packages,
# and sassc and rsass both reject its module syntax, so the orig is upstream's release
# asset with the CSS already compiled (the asset Fedora packages too).
override_dh_auto_install:
	install -d debian/adw-gtk3/usr/share/themes
	cp -a debian/build/adw-gtk3 debian/build/adw-gtk3-dark debian/adw-gtk3/usr/share/themes/
