Skip to content

bpo-31934: Abort when building out of a not clean source tree #4255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,17 @@ DTRACE_DEPS = \

# Default target
all: @DEF_MAKE_ALL_RULE@
build_all: $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks Programs/_testembed python-config
build_all: check-clean-src $(BUILDPYTHON) oldsharedmods sharedmods gdbhooks \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to put check-clean-src in $(BUILDPYTHON). I tested, it works:

# Build the interpreter
$(BUILDPYTHON):	check-clean-src Programs/python.o $(LIBRARY) $(LDLIBRARY) $(PY3LIBRARY)
	$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) -o $@ Programs/python.o $(BLDLIBRARY) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. One problem is that in this case the $(BUILDPYTHON) target is rebuilt even when it is up to date, for the following reason:
A phony target should not be a prerequisite of a real target file;
if it is, its recipe will be run every time make goes to update that file.

This is a quote from Phony Targets.

  1. Another minor problem is that the recipe of check-clean-src may be run multiple times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh oh, I didn't know.

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 ($(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

# Profile generation build must start from a clean tree.
profile-clean-stamp:
Expand Down Expand Up @@ -542,7 +552,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
Expand Down Expand Up @@ -1100,7 +1110,7 @@ altinstall: commoninstall
$$ensurepip --root=$(DESTDIR)/ ; \
fi

commoninstall: @FRAMEWORKALTINSTALLFIRST@ \
commoninstall: check-clean-src @FRAMEWORKALTINSTALLFIRST@ \
altbininstall libinstall inclinstall libainstall \
sharedinstall oldsharedinstall altmaninstall \
@FRAMEWORKALTINSTALLLAST@
Expand Down Expand Up @@ -1722,7 +1732,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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Abort the build when building out of a not clean source tree.