#!/usr/bin/make -f

#export DH_VERBOSE := 1
# Disable conformance due to it requires with Bazel workspace, and not to vendoring it due to out of previous discussion.
export DH_GOLANG_EXCLUDES := examples codelab repl/main conformance
export DH_GOLANG_INSTALL_EXTRA := cel/templates/authoring.tmpl

export BUILDDIR := build

%:
	dh $@ --builddirectory=$(BUILDDIR)

execute_before_dh_auto_configure:
	mkdir -p -v $(BUILDDIR)/src/github.com/google/cel-go/vendor
	cp -v -a debian/missing-sources/* $(BUILDDIR)/src/github.com/google/cel-go/vendor

override_dh_install:
	find debian/golang-github-google-cel-go-dev/usr/share/gocode/src/github.com/google/cel-go/ \
	    -type f -exec chmod -x \{\} \;
	dh_install -i

# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1102312#12
#
# Building on a system with Linux kernel parameter 'nr_cpus=1' results in:
#
# === RUN   TestInterpreter_InterruptableEval
#     interpreter_test.go:1888: Got true, wanted operation interrupted error
# --- FAIL: TestInterpreter_InterruptableEval (0.00s)
#
# https://people.debian.org/~sanvila/build-logs/202503/golang-github-google-cel-go_0.27.0+ds-4_amd64-20260828T043700.568Z
#
# === RUN   TestContextEval
#     cel_test.go:1161: Got result 1975, wanted timeout error
# --- FAIL: TestContextEval (0.01s)
SKIP="TestInterpreter_InterruptableEval|TestContextEval"
override_dh_auto_test:
	-dh_auto_test -- -run=$(SKIP)
	# Set to warn to workaround the conflict registration from vendor/
	GOLANG_PROTOBUF_REGISTRATION_CONFLICT=warn \
		dh_auto_test -- -short -skip $(SKIP)
