#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

%:
	dh $@ --buildsystem=cmake --builddirectory=build

override_dh_auto_configure:
	dh_auto_configure -- \
		-DSENTRY_BACKEND=inproc \
		-DSENTRY_TRANSPORT=curl \
		-DSENTRY_TRANSPORT_COMPRESSION=ON \
		-DSENTRY_LIBUNWIND_SYSTEM=ON \
		-DSENTRY_BUILD_SHARED_LIBS=ON \
		-DSENTRY_BUILD_EXAMPLES=OFF \
		-DSENTRY_BUILD_TESTS=$(if $(filter nocheck,$(DEB_BUILD_OPTIONS)),OFF,ON) \
		-DSENTRY_INTEGRATION_QT=OFF

# The unit tests are run directly instead of through the upstream pytest
# suite, which rebuilds the SDK with the removed bundled backends.
# They locate their fixtures relative to __FILE__, which is "./tests/unit/..."
# due to -ffile-prefix-map, so make the sources reachable from the test cwd.
# build_id_parser needs the prebuilt fixtures removed from the source.
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	ln -sfn $(CURDIR)/tests build/tests/unit/tests
	cd build/tests/unit && ./sentry_test_unit --skip build_id_parser
endif
