#!/usr/bin/make -f

# Output every command that modifies files on the build system.
#export DH_VERBOSE = 1
export HOME = $(CURDIR)

EXCLUDED_TESTS := \
add_build_board_property_if_missing_test.go \
builder_test.go \
ctags_runner_test.go \
hardware_loader_test.go \
includes_to_include_folders_test.go \
libraries_loader_test.go \
load_vid_pid_specific_properties_test.go \
merge_sketch_with_bootloader_test.go \
prototypes_adder_test.go \
setup_build_properties_test.go \
target_board_resolver_test.go \
tools_loader_test.go \
try_build_of_problematic_sketch_test.go \
$(NULL)

# main packaging script based on dh7 syntax
%:
	dh $@ --buildsystem=golang --with=golang

override_dh_auto_configure:
	dh_auto_configure
	rm -rf obj-*/src/arduino.cc
	cp -r -t obj-*/src/ src/*

override_dh_auto_test:
ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
	# Remove tests which download stuff:
	@for extest in $(EXCLUDED_TESTS) ; do \
		rm -v obj-*/src/arduino.cc/builder/test/$$extest; \
	done
	# Execute the rest of the tests
	cd obj-* &&\
	export GOPATH=$$(pwd) &&\
	go test -v -timeout 30m arduino.cc/...
endif

override_dh_auto_install:
	dh_auto_install -- --no-source
