Skip to content

Commit ab6b962

Browse files
authored
bpo-23404: make touch becomes make regen-all (#1405) (#1461) (#1465)
* bpo-23404: make touch becomes make regen-all (#1405) Don't rebuild generated files based on file modification time anymore, the action is now explicit. Replace "make touch" with "make regen-all". Changes: * Remove "make touch", Tools/hg/hgtouch.py and .hgtouch * Add a new "make regen-all" command to rebuild all generated files * Add subcommands to only generate specific files: - regen-ast: Include/Python-ast.h and Python/Python-ast.c - regen-grammar: Include/graminit.h and Python/graminit.c - regen-importlib: Python/importlib_external.h and Python/importlib.h - regen-opcode: Include/opcode.h - regen-opcode-targets: Python/opcode_targets.h - regen-typeslots: Objects/typeslots.inc * Rename PYTHON_FOR_GEN to PYTHON_FOR_REGEN * pgen is now only built by by "make regen-grammar" * Add $(srcdir)/ prefix to paths to source files to handle correctly compilation outside the source directory Note: $(PYTHON_FOR_REGEN) is no more used nor needed by "make" default target building Python. (cherry picked from commit a5c62a8) * bpo-30273: Update sysconfig (#1464) The AST_H_DIR variable was removed from Makefile.pre.in by the commit a5c62a8 (bpo-23404). AST_H_DIR was hardcoded to "Include", so replace the removed variable by its content. Remove also ASDLGEN variable from sysconfig example since this variable was also removed. (cherry picked from commit b109a1d) (cherry picked from commit 9d02f56)
1 parent 7299088 commit ab6b962

File tree

9 files changed

+90
-261
lines changed

9 files changed

+90
-261
lines changed

.hgtouch

Lines changed: 0 additions & 17 deletions
This file was deleted.

Doc/library/sysconfig.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ You can use :mod:`sysconfig` as a script with Python's *-m* option:
255255
AIX_GENUINE_CPLUSPLUS = "0"
256256
AR = "ar"
257257
ARFLAGS = "rc"
258-
ASDLGEN = "./Parser/asdl_c.py"
259258
...
260259
261260
This call will print in the standard output the information returned by

Lib/distutils/sysconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_python_inc(plat_specific=0, prefix=None):
9797
if plat_specific:
9898
return base
9999
if _sys_home:
100-
incdir = os.path.join(_sys_home, get_config_var('AST_H_DIR'))
100+
incdir = os.path.join(_sys_home, 'Include')
101101
else:
102102
incdir = os.path.join(get_config_var('srcdir'), 'Include')
103103
return os.path.normpath(incdir)

Mac/BuildScript/build-installer.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,9 +1168,6 @@ def buildPython():
11681168
shellQuote(WORKDIR)[1:-1],
11691169
shellQuote(WORKDIR)[1:-1]))
11701170

1171-
print("Running make touch")
1172-
runCommand("make touch")
1173-
11741171
print("Running make")
11751172
runCommand("make")
11761173

Makefile.pre.in

Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ LIBOBJS= @LIBOBJS@
224224
PYTHON= python$(EXE)
225225
BUILDPYTHON= python$(BUILDEXE)
226226

227-
PYTHON_FOR_GEN=@PYTHON_FOR_GEN@
227+
PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@
228228
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
229229
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
230230
BUILD_GNU_TYPE= @build@
@@ -271,11 +271,6 @@ IO_OBJS= \
271271
Modules/_io/stringio.o
272272

273273
##########################################################################
274-
# Grammar
275-
GRAMMAR_H= Include/graminit.h
276-
GRAMMAR_C= Python/graminit.c
277-
GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
278-
279274

280275
LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
281276

@@ -337,38 +332,9 @@ PARSER_HEADERS= \
337332
PGENSRCS= $(PSRCS) $(PGSRCS)
338333
PGENOBJS= $(POBJS) $(PGOBJS)
339334

340-
##########################################################################
341-
# opcode.h generation
342-
OPCODE_H_DIR= $(srcdir)/Include
343-
OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
344-
OPCODE_H= $(OPCODE_H_DIR)/opcode.h
345-
OPCODE_H_GEN= $(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
346-
#
347-
##########################################################################
348-
# AST
349-
AST_H_DIR= Include
350-
AST_H= $(AST_H_DIR)/Python-ast.h
351-
AST_C_DIR= Python
352-
AST_C= $(AST_C_DIR)/Python-ast.c
353-
AST_ASDL= $(srcdir)/Parser/Python.asdl
354-
355-
ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
356-
# Note that a build now requires Python to exist before the build starts.
357-
# Use "hg touch" to fix up screwed up file mtimes in a checkout.
358-
ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
359-
360335
##########################################################################
361336
# Python
362337

363-
OPCODETARGETS_H= \
364-
Python/opcode_targets.h
365-
366-
OPCODETARGETGEN= \
367-
$(srcdir)/Python/makeopcodetargets.py
368-
369-
OPCODETARGETGEN_FILES= \
370-
$(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
371-
372338
PYTHON_OBJS= \
373339
Python/_warnings.o \
374340
Python/Python-ast.o \
@@ -551,7 +517,8 @@ coverage-lcov:
551517
@echo "lcov report at $(COVERAGE_REPORT)/index.html"
552518
@echo
553519

554-
coverage-report:
520+
# Force regeneration of parser and importlib
521+
coverage-report: regen-grammar regen-importlib
555522
: # force rebuilding of parser and importlib
556523
@touch $(GRAMMAR_INPUT)
557524
@touch $(srcdir)/Lib/importlib/_bootstrap.py
@@ -721,14 +688,24 @@ Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
721688
Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
722689
$(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
723690

724-
Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib
691+
.PHONY: regen-importlib
692+
regen-importlib: Programs/_freeze_importlib
693+
# Regenerate Python/importlib_external.h
694+
# from Lib/importlib/_bootstrap_external.py using _freeze_importlib
725695
./Programs/_freeze_importlib \
726-
$(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h
727-
728-
Python/importlib.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib
696+
$(srcdir)/Lib/importlib/_bootstrap_external.py \
697+
$(srcdir)/Python/importlib_external.h
698+
# Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
699+
# using _freeze_importlib
729700
./Programs/_freeze_importlib \
730-
$(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
701+
$(srcdir)/Lib/importlib/_bootstrap.py \
702+
$(srcdir)/Python/importlib.h
703+
704+
705+
############################################################################
706+
# Regenerate all generated files
731707

708+
regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar regen-ast regen-importlib
732709

733710
############################################################################
734711
# Special rules for object files
@@ -787,15 +764,18 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
787764

788765
$(IO_OBJS): $(IO_H)
789766

790-
$(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
791-
@$(MKDIR_P) Include
792-
$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
793-
$(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
794-
touch $(GRAMMAR_C)
795-
796767
$(PGEN): $(PGENOBJS)
797768
$(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
798769

770+
.PHONY: regen-grammar
771+
regen-grammar: $(PGEN)
772+
# Regenerate Include/graminit.h and Python/graminit.c
773+
# from Grammar/Grammar using pgen
774+
@$(MKDIR_P) Include
775+
$(PGEN) $(srcdir)/Grammar/Grammar \
776+
$(srcdir)/Include/graminit.h \
777+
$(srcdir)/Python/graminit.c
778+
799779
Parser/grammar.o: $(srcdir)/Parser/grammar.c \
800780
$(srcdir)/Include/token.h \
801781
$(srcdir)/Include/grammar.h
@@ -807,18 +787,28 @@ Parser/printgrammar.o: $(srcdir)/Parser/printgrammar.c
807787

808788
Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
809789

810-
$(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
811-
$(MKDIR_P) $(AST_H_DIR)
812-
$(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
813-
814-
$(AST_C): $(AST_H) $(AST_ASDL) $(ASDLGEN_FILES)
815-
$(MKDIR_P) $(AST_C_DIR)
816-
$(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
817-
818-
$(OPCODE_H): $(srcdir)/Lib/opcode.py $(OPCODE_H_SCRIPT)
819-
$(OPCODE_H_GEN)
820-
821-
Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
790+
.PHONY=regen-ast
791+
regen-ast:
792+
# Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
793+
$(MKDIR_P) $(srcdir)/Include
794+
$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
795+
-h $(srcdir)/Include \
796+
$(srcdir)/Parser/Python.asdl
797+
# Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
798+
$(MKDIR_P) $(srcdir)/Python
799+
$(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
800+
-c $(srcdir)/Python \
801+
$(srcdir)/Parser/Python.asdl
802+
803+
.PHONY: regen-opcode
804+
regen-opcode:
805+
# Regenerate Include/opcode.h from Lib/opcode.py
806+
# using Tools/scripts/generate_opcode_h.py
807+
$(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
808+
$(srcdir)/Lib/opcode.py \
809+
$(srcdir)/Include/opcode.h
810+
811+
Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
822812

823813
Python/getplatform.o: $(srcdir)/Python/getplatform.c
824814
$(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -867,16 +857,26 @@ Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
867857
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
868858
Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
869859

870-
$(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
871-
$(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
860+
.PHONY: regen-opcode-targets
861+
regen-opcode-targets:
862+
# Regenerate Python/opcode_targets.h from Lib/opcode.py
863+
# using Python/makeopcodetargets.py
864+
$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
865+
$(srcdir)/Python/opcode_targets.h
872866

873-
Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
867+
Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h
874868

875-
Python/frozen.o: Python/importlib.h Python/importlib_external.h
869+
Python/frozen.o: $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib_external.h
876870

877871
Objects/typeobject.o: Objects/typeslots.inc
878-
Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
879-
$(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
872+
873+
.PHONY: regen-typeslots
874+
regen-typeslots:
875+
# Regenerate Objects/typeslots.inc from Include/typeslotsh
876+
# using Objects/typeslots.py
877+
$(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
878+
< $(srcdir)/Include/typeslots.h \
879+
$(srcdir)/Objects/typeslots.inc
880880

881881
############################################################################
882882
# Header files
@@ -929,7 +929,7 @@ PYTHON_HEADERS= \
929929
$(srcdir)/Include/node.h \
930930
$(srcdir)/Include/object.h \
931931
$(srcdir)/Include/objimpl.h \
932-
$(OPCODE_H) \
932+
$(srcdir)/Include/opcode.h \
933933
$(srcdir)/Include/osdefs.h \
934934
$(srcdir)/Include/patchlevel.h \
935935
$(srcdir)/Include/pgen.h \
@@ -970,7 +970,7 @@ PYTHON_HEADERS= \
970970
$(srcdir)/Include/weakrefobject.h \
971971
pyconfig.h \
972972
$(PARSER_HEADERS) \
973-
$(AST_H)
973+
$(srcdir)/Include/Python-ast.h
974974

975975
$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
976976

@@ -1551,9 +1551,12 @@ recheck:
15511551
$(SHELL) config.status --recheck
15521552
$(SHELL) config.status
15531553

1554-
# Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1554+
# Regenerate configure and pyconfig.h.in
1555+
.PHONY: autoconf
15551556
autoconf:
1557+
# Regenerate the configure script from configure.ac using autoconf
15561558
(cd $(srcdir); autoconf -Wall)
1559+
# Regenerate pyconfig.h.in from configure.ac using autoheader
15571560
(cd $(srcdir); autoheader -Wall)
15581561

15591562
# Create a tags file for vi
@@ -1570,14 +1573,6 @@ TAGS::
15701573
etags Include/*.h; \
15711574
for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15721575

1573-
# This fixes up the mtimes of checked-in generated files, assuming that they
1574-
# only *appear* to be outdated because of checkout order.
1575-
# This is run while preparing a source release tarball, and can be run manually
1576-
# to avoid bootstrap issues.
1577-
touch:
1578-
cd $(srcdir); \
1579-
hg --config extensions.touch=Tools/hg/hgtouch.py touch -v
1580-
15811576
# Sanitation targets -- clean leaves libraries, executables and tags
15821577
# files, which clobber removes as well
15831578
pycremoval:
@@ -1695,7 +1690,7 @@ Python/thread.o: @THREADHEADERS@
16951690
.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
16961691
.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
16971692
.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1698-
.PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1693+
.PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
16991694
.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
17001695
.PHONY: gdbhooks
17011696

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,10 @@ Documentation
203203
Build
204204
-----
205205

206+
- bpo-23404: Don't regenerate generated files based on file modification time
207+
anymore: the action is now explicit. Replace ``make touch`` with
208+
``make regen-all``.
209+
206210
- bpo-29643: Fix ``--enable-optimization`` didn't work.
207211

208212
Tests

0 commit comments

Comments
 (0)