# HG changeset patch
# User Antonio Muci <
a....@inwind.it>
# Date 1742812110 -3600
# Mon Mar 24 11:28:30 2025 +0100
# Branch stable
# Node ID 01a869f074da5772386e1de876eddcdadca5c9ae
# Parent 8b1e1df909713e4dc318b876511badd752fbe7a4
makefile: factor out common code in the "function" check_hgpath()
This change uses GNU Make specific syntax, as per:
https://stackoverflow.com/questions/6783243/functions-in-makefiles/74742720
I have verified with one of the FreeBSD maintainers for TortoiseHg that this
change would not impact packaging (this Makefile is for development only, and
Ports are a totally independent project), and the developers' workflow (because
it is common practice to use devel/gmake to work on upstream projects).
diff --git a/Makefile b/Makefile
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,13 @@ ifneq ($(HGPATH),)
export PYTHONPATH := $(realpath $(HGPATH)):$(PYTHONPATH)
endif
+# the following syntax requires GNU Make
+define check_hgpath
+ @[ -n "$(1)" ] || { echo "HGPATH not specified. Please run again with 'make $@ HGPATH=/path/to/hg'. For example, you could point to a checkout of the mercurial source code"; false; }
+ @[ -e "$(1)" ] || { echo "HGPATH not found: $(HGPATH)"; false; }
+ @[ -d "$(1)" ] || { echo "HGPATH must be a directory: $(HGPATH)"; false; }
+endef
+
.PHONY: help
help:
@echo 'Commonly used make targets:'
@@ -30,9 +37,7 @@ local:
.PHONY: tests
tests:
- @[ -n "$(HGPATH)" ] || { echo "HGPATH not specified. Please run again with 'make $@ HGPATH=/path/to/hg'. For example, you could point to a checkout of the mercurial source code"; false; }
- @[ -e "$(HGPATH)" ] || { echo "HGPATH not found: $(HGPATH)"; false; }
- @[ -d "$(HGPATH)" ] || { echo "HGPATH must be a directory: $(HGPATH)"; false; }
+ @$(call check_hgpath,"$(HGPATH)")
$(PYTHON) tests/run-tests.py -m 'not largefiles' --doctest-modules \
--ignore tortoisehg/hgqt/shellconf.py \
--ignore tortoisehg/util/bugtraq.py \
@@ -43,9 +48,7 @@ tests:
.PHONY: pytype
pytype: PYTHON_VERSION = 3.8
pytype:
- @[ -n "$(HGPATH)" ] || { echo "HGPATH not specified. Please run again with 'make $@ HGPATH=/path/to/hg'. For example, you could point to a checkout of the mercurial source code"; false; }
- @[ -e "$(HGPATH)" ] || { echo "HGPATH not found: $(HGPATH)"; false; }
- @[ -d "$(HGPATH)" ] || { echo "HGPATH must be a directory: $(HGPATH)"; false; }
+ @$(call check_hgpath,"$(HGPATH)")
$(PYTYPE) -P ".:$(HGPATH)" -V "$(PYTHON_VERSION)" -j auto \
--config pytype.cfg
@echo 'pytype crashed while generating the following type stubs:'