#!/usr/bin/make -f
#export DH_VERBOSE = 1
export PYBUILD_NAME=briefcase

export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export http_proxy=http://127.0.0.1:9/
export https_proxy=https://127.0.0.1:9/

#skipped tests that require connection and tests
# for platforms/architecture that are not part of the unix environment
export PYBUILD_TEST_CUSTOM=1
export PYBUILD_TEST_ARGS={interpreter} -m pytest  -v \
	-k 'not test_build_appimage \
	and not test_build_app_with_support_package_update \
	and not test_build_failure \
	and not test_binary_path \
	and not test_cmdline_tools_url \
	and not test_data_path_creation_failure \
	and not test_detects_bad_zipfile \
	and not test_file_name \
	and not test_distribution_path \
	and not test_download_url \
	and not test_download_missing \
	and not test_download_sdk \
	and not test_download_sdk_legacy_install \
	and not test_download_wix \
	and not test_download_sdk_if_sdkmanager_not_executable \
	and not test_install_custom_stub_binary_url \
	and not test_install_stub_binary_missing \
	and not test_open_no_docker_linux \
	and not test_output_format_template_context_bad_tag \
	and not test_output_format_template_context \
	and not test_package_app \
	and not test_raises_networkfailure_on_connectionerror \
	and not test_rcedit_url \
	and not test_run_app_test_mode_with_args \
	and not test_run_app_test_mode \
	and not test_run_console_app \
	and not test_run_gui_app_failed \
	and not test_run_gui_app \
	and not test_run_console_app_failed \
	and not test_run_console_app_with_passthrough \
	and not test_successful_jdk_download \
	and not test_supported_host_os_docker \
	and not test_cleanup_app_content\
	and not test_Subprocess__run__controlled_console \
	and not test_command_explicit_platform_help \
	and not test_command_explicit_format_help \
	and not test_test_failure \
	and not test_install_image \
	and not test_wait_bar \
	and not test_supported_arch \
	and not test_upgrade_existing_sdk \
	and not test_verify_tools_download_failure \
	and not test_unsupported_arch_external \
	and not test_support_package_url_with_unsupported_platform \
	and not test_no_support_revisio'

# the tests test_unsupported_arch_external,test_support_package_url_with_unsupported_platform and test_no_support_revision\
# Skip tests that fail on i386 because briefcase raises UnsupportedHostError when running under a 32bit Python interpreter,
# which is the case on i386 build environments.

%:
	dh $@ --buildsystem=pybuild


ifeq ($(filter nodoc,$(DEB_BUILD_OPTIONS)),)
execute_before_dh_installdocs:
	cp -r docs/en/how-to/contribute/ /tmp/contribute-bkp
	find docs/en -name "*.md" -exec sed -i '/^{%[[:space:]]*extends/d' {} +
	HOME=/tmp mkdocs build \
	-f docs/mkdocs.en.yml \
	-d $(CURDIR)/debian/python-briefcase-doc/usr/share/doc/python-briefcase-doc/html

	rm -rf docs/en/how-to/contribute
	mv /tmp/contribute-bkp docs/en/how-to/contribute

# Fix duplicate-files
execute_after_dh_installdocs:
	jdupes -rl debian/python-briefcase-doc/usr/share
endif
