[PATCH] v4: factor out check_hgpath

2 views
Skip to first unread message

Antonio Muci

unread,
Mar 24, 2025, 4:54:15 PMMar 24
to thg...@googlegroups.com, a....@inwind.it
# HG changeset patch
# User Antonio Muci <a....@inwind.it>
# Date 1742849451 -3600
# Mon Mar 24 21:50:51 2025 +0100
# Branch stable
# Node ID b00eb73e3e50911a0a125e87b74a088554582cf1
# Parent c05fe66abb4ad3fdb75473e7ffd7732876443886
makefile: factor out common code in the canned recipe check_hgpath

This change uses GNU Make specific syntax, as per:
https://www.gnu.org/software/make/manual/make.html#Canned-Recipes

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,14 @@ ifneq ($(HGPATH),)
export PYTHONPATH := $(realpath $(HGPATH)):$(PYTHONPATH)
endif

+# the following syntax for "define" requires GNU Make. See:
+# https://www.gnu.org/software/make/manual/make.html#Canned-Recipes
+define check_hgpath =
+ @[ -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; }
+endef
+
.PHONY: help
help:
@echo 'Commonly used make targets:'
@@ -30,9 +38,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; }
+ $(check_hgpath)
$(PYTHON) tests/run-tests.py -m 'not largefiles' --doctest-modules \
--ignore tortoisehg/hgqt/shellconf.py \
--ignore tortoisehg/util/bugtraq.py \
@@ -43,9 +49,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; }
+ $(check_hgpath)
$(PYTYPE) -P ".:$(HGPATH)" -V "$(PYTHON_VERSION)" -j auto \
--config pytype.cfg
@echo 'pytype crashed while generating the following type stubs:'
@@ -56,9 +60,7 @@ app: DISTDIR = dist/app
app: SETUPCFG = contrib/setup-py2app.cfg
app: export MACOSX_DEPLOYMENT_TARGET=10.7
app:
- @[ -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; }
+ $(check_hgpath)
[ -z "$(SETUPCFG)" ] || cp "$(SETUPCFG)" setup.cfg
$(MAKE) -C "$(HGPATH)" local
FORCE_SETUPTOOLS= $(PYTHON) setup.py py2app -d "$(DISTDIR)"

Yuya Nishihara

unread,
Mar 25, 2025, 12:03:37 AMMar 25
to 'Antonio Muci' via TortoiseHg Developers, a....@inwind.it
On Mon, 24 Mar 2025 21:54:11 +0100, 'Antonio Muci' via TortoiseHg
Developers wrote:
> # HG changeset patch
> # User Antonio Muci <a....@inwind.it>
> # Date 1742849451 -3600
> # Mon Mar 24 21:50:51 2025 +0100
> # Branch stable
> # Node ID b00eb73e3e50911a0a125e87b74a088554582cf1
> # Parent c05fe66abb4ad3fdb75473e7ffd7732876443886
> makefile: factor out common code in the canned recipe check_hgpath

Queued, thanks.
Reply all
Reply to author
Forward
0 new messages