From d0f4a9e9c5d6f572f568b8152e45f4884f55182a Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Fri, 3 Nov 2017 15:20:06 +0100 Subject: [PATCH 1/4] bpo-31934: Abort when building out of a not clean source tree --- Makefile.pre.in | 9 ++++++++- .../next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst diff --git a/Makefile.pre.in b/Makefile.pre.in index e5d65bde26658e..f0e3c15041b282 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -439,9 +439,16 @@ DTRACE_DEPS = \ # Rules # Default target -all: @DEF_MAKE_ALL_RULE@ +all: check-clean-src @DEF_MAKE_ALL_RULE@ build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config +# Check that the source is clean when building out of source. +check-clean-src: + @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \ + echo "Error: The source directory is not clean" ;\ + exit 1; \ + fi + # Profile generation build must start from a clean tree. profile-clean-stamp: $(MAKE) clean profile-removal diff --git a/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst b/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst new file mode 100644 index 00000000000000..deaa74046e9689 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2017-11-03-15-17-50.bpo-31934.8bUlpv.rst @@ -0,0 +1 @@ +Abort the build when building out of a not clean source tree. From 1f82f054e14cd2de0d92ac779b76f0a6b5fda910 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Fri, 3 Nov 2017 15:26:12 +0100 Subject: [PATCH 2/4] Fix a typo. --- Makefile.pre.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index f0e3c15041b282..a952a512bc22c0 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -445,7 +445,7 @@ build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed # Check that the source is clean when building out of source. check-clean-src: @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \ - echo "Error: The source directory is not clean" ;\ + echo "Error: The source directory is not clean" ; \ exit 1; \ fi From 1bf0ae008db104239441ac0ea62ba7b2ff4c44cf Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Tue, 7 Nov 2017 10:55:00 +0100 Subject: [PATCH 3/4] The check-clean-src recipe is called on all high level make targets --- Makefile.pre.in | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index a952a512bc22c0..141bb5d650d2cd 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -439,8 +439,9 @@ DTRACE_DEPS = \ # Rules # Default target -all: check-clean-src @DEF_MAKE_ALL_RULE@ -build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config +all: @DEF_MAKE_ALL_RULE@ +build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \ + Programs/_testembed python-config # Check that the source is clean when building out of source. check-clean-src: @@ -549,7 +550,7 @@ coverage-report: regen-grammar regen-importlib # Run "Argument Clinic" over all source files # (depends on python having already been built) .PHONY=clinic -clinic: $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c +clinic: check-clean-src $(BUILDPYTHON) $(srcdir)/Modules/_blake2/blake2s_impl.c $(RUNSHARED) $(PYTHON_FOR_BUILD) $(srcdir)/Tools/clinic/clinic.py --make --srcdir $(srcdir) # Build the interpreter @@ -1107,7 +1108,7 @@ altinstall: commoninstall $$ensurepip --root=$(DESTDIR)/ ; \ fi -commoninstall: @FRAMEWORKALTINSTALLFIRST@ \ +commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \ altbininstall libinstall inclinstall libainstall \ sharedinstall oldsharedinstall altmaninstall \ @FRAMEWORKALTINSTALLLAST@ @@ -1729,7 +1730,7 @@ patchcheck: @DEF_MAKE_RULE@ Python/thread.o: @THREADHEADERS@ # Declare targets that aren't real files -.PHONY: all build_all sharedmods oldsharedmods test quicktest +.PHONY: all build_all sharedmods check-clean-src oldsharedmods test quicktest .PHONY: install altinstall oldsharedinstall bininstall altbininstall .PHONY: maninstall libinstall inclinstall libainstall sharedinstall .PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure From 147c7acc9dc2b74b3414fce5fe41a49852689030 Mon Sep 17 00:00:00 2001 From: Xavier de Gaye Date: Tue, 7 Nov 2017 15:16:34 +0100 Subject: [PATCH 4/4] Improve the error message --- Makefile.pre.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile.pre.in b/Makefile.pre.in index 141bb5d650d2cd..9a38cece239814 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -446,7 +446,9 @@ build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \ # Check that the source is clean when building out of source. check-clean-src: @if test -n "$(VPATH)" -a -f "$(srcdir)/Programs/python.o"; then \ - echo "Error: The source directory is not clean" ; \ + echo "Error: The source directory ($(srcdir)) is not clean" ; \ + echo "Building Python out of the source tree (in $(abs_builddir)) requires a clean source tree ($(abs_srcdir))" ; \ + echo "Try to run: make -C \"$(srcdir)\" clean" ; \ exit 1; \ fi