#!/usr/bin/make -f

%:
	dh $@ --buildsystem cargo

# regenerating the source code
# the xmlstarlet fixes are taken from upstream here: https://github.com/gtk-rs/gir-files/blob/master/fix.sh
execute_before_dh_auto_build:
	cp /usr/share/gir-1.0/GstAllocators-1.0.gir $(CURDIR)
	cp /usr/share/gir-1.0/Gst-1.0.gir $(CURDIR)
	cp /usr/share/gir-1.0/GLib-2.0.gir $(CURDIR)
	cp /usr/share/gir-1.0/GModule-2.0.gir $(CURDIR)
	cp /usr/share/gir-1.0/GObject-2.0.gir $(CURDIR)
	sed -i 's/girs_directories\s=\s\[\"\.\.\/\.\.\/gir-files\"\,\s\"\.\.\/\.\.\/gst-gir-files\"\]/girs_directories=\[\".\"\]/' $(CURDIR)/Gir.toml
	gir -o .

# Remove the .gir files before install
execute_before_dh_auto_install:
	rm $(CURDIR)/*.gir
