Skip to content

Commit 9d02f56

Browse files
authored
[3.6] bpo-23404: make touch becomes make regen-all (#1405) (#1461)
* 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)
1 parent a7e48b5 commit 9d02f56

File tree

9 files changed

+91
-262
lines changed

9 files changed

+91
-262
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 & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,10 +1142,6 @@ def buildPython():
11421142
shellQuote(WORKDIR)[1:-1],
11431143
shellQuote(WORKDIR)[1:-1]))
11441144

1145-
# bpo-29550: avoid using make touch until it is fixed for git
1146-
# print("Running make touch")
1147-
# runCommand("make touch")
1148-
11491145
print("Running make")
11501146
runCommand("make")
11511147

Makefile.pre.in

Lines changed: 72 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ LIBOBJS= @LIBOBJS@
229229
PYTHON= python$(EXE)
230230
BUILDPYTHON= python$(BUILDEXE)
231231

232-
PYTHON_FOR_GEN=@PYTHON_FOR_GEN@
232+
PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@
233233
PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
234234
_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
235235
BUILD_GNU_TYPE= @build@
@@ -273,11 +273,6 @@ IO_OBJS= \
273273
Modules/_io/stringio.o
274274

275275
##########################################################################
276-
# Grammar
277-
GRAMMAR_H= Include/graminit.h
278-
GRAMMAR_C= Python/graminit.c
279-
GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
280-
281276

282277
LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
283278

@@ -316,38 +311,9 @@ PARSER_HEADERS= \
316311

317312
PGENOBJS= $(POBJS) $(PGOBJS)
318313

319-
##########################################################################
320-
# opcode.h generation
321-
OPCODE_H_DIR= $(srcdir)/Include
322-
OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
323-
OPCODE_H= $(OPCODE_H_DIR)/opcode.h
324-
OPCODE_H_GEN= $(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
325-
326-
##########################################################################
327-
# AST
328-
AST_H_DIR= Include
329-
AST_H= $(AST_H_DIR)/Python-ast.h
330-
AST_C_DIR= Python
331-
AST_C= $(AST_C_DIR)/Python-ast.c
332-
AST_ASDL= $(srcdir)/Parser/Python.asdl
333-
334-
ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
335-
# Note that a build now requires Python to exist before the build starts.
336-
# Use "hg touch" to fix up screwed up file mtimes in a checkout.
337-
ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
338-
339314
##########################################################################
340315
# Python
341316

342-
OPCODETARGETS_H= \
343-
Python/opcode_targets.h
344-
345-
OPCODETARGETGEN= \
346-
$(srcdir)/Python/makeopcodetargets.py
347-
348-
OPCODETARGETGEN_FILES= \
349-
$(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
350-
351317
PYTHON_OBJS= \
352318
Python/_warnings.o \
353319
Python/Python-ast.o \
@@ -547,7 +513,8 @@ coverage-lcov:
547513
@echo "lcov report at $(COVERAGE_REPORT)/index.html"
548514
@echo
549515

550-
coverage-report:
516+
# Force regeneration of parser and importlib
517+
coverage-report: regen-grammar regen-importlib
551518
: # force rebuilding of parser and importlib
552519
@touch $(GRAMMAR_INPUT)
553520
@touch $(srcdir)/Lib/importlib/_bootstrap.py
@@ -723,14 +690,24 @@ Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
723690
Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
724691
$(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
725692

726-
Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib Python/marshal.c
693+
.PHONY: regen-importlib
694+
regen-importlib: Programs/_freeze_importlib
695+
# Regenerate Python/importlib_external.h
696+
# from Lib/importlib/_bootstrap_external.py using _freeze_importlib
727697
./Programs/_freeze_importlib \
728-
$(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h
729-
730-
Python/importlib.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib Python/marshal.c
698+
$(srcdir)/Lib/importlib/_bootstrap_external.py \
699+
$(srcdir)/Python/importlib_external.h
700+
# Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
701+
# using _freeze_importlib
731702
./Programs/_freeze_importlib \
732-
$(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
703+
$(srcdir)/Lib/importlib/_bootstrap.py \
704+
$(srcdir)/Python/importlib.h
705+
706+
707+
############################################################################
708+
# Regenerate all generated files
733709

710+
regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar regen-ast regen-importlib
734711

735712
############################################################################
736713
# Special rules for object files
@@ -789,15 +766,18 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
789766

790767
$(IO_OBJS): $(IO_H)
791768

792-
$(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
793-
@$(MKDIR_P) Include
794-
$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
795-
$(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
796-
touch $(GRAMMAR_C)
797-
798769
$(PGEN): $(PGENOBJS)
799770
$(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
800771

772+
.PHONY: regen-grammar
773+
regen-grammar: $(PGEN)
774+
# Regenerate Include/graminit.h and Python/graminit.c
775+
# from Grammar/Grammar using pgen
776+
@$(MKDIR_P) Include
777+
$(PGEN) $(srcdir)/Grammar/Grammar \
778+
$(srcdir)/Include/graminit.h \
779+
$(srcdir)/Python/graminit.c
780+
801781
Parser/grammar.o: $(srcdir)/Parser/grammar.c \
802782
$(srcdir)/Include/token.h \
803783
$(srcdir)/Include/grammar.h
@@ -809,18 +789,28 @@ Parser/printgrammar.o: $(srcdir)/Parser/printgrammar.c
809789

810790
Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
811791

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

825815
Python/getplatform.o: $(srcdir)/Python/getplatform.c
826816
$(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -870,12 +860,16 @@ Objects/odictobject.o: $(srcdir)/Objects/dict-common.h
870860
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h $(srcdir)/Objects/dict-common.h
871861
Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
872862

873-
$(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
874-
$(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
863+
.PHONY: regen-opcode-targets
864+
regen-opcode-targets:
865+
# Regenerate Python/opcode_targets.h from Lib/opcode.py
866+
# using Python/makeopcodetargets.py
867+
$(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
868+
$(srcdir)/Python/opcode_targets.h
875869

876-
Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
870+
Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h
877871

878-
Python/frozen.o: Python/importlib.h Python/importlib_external.h
872+
Python/frozen.o: $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib_external.h
879873

880874
# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
881875
# follow our naming conventions. dtrace(1) uses the output filename to generate
@@ -890,8 +884,14 @@ Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
890884
$(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
891885

892886
Objects/typeobject.o: Objects/typeslots.inc
893-
Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
894-
$(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
887+
888+
.PHONY: regen-typeslots
889+
regen-typeslots:
890+
# Regenerate Objects/typeslots.inc from Include/typeslotsh
891+
# using Objects/typeslots.py
892+
$(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
893+
< $(srcdir)/Include/typeslots.h \
894+
$(srcdir)/Objects/typeslots.inc
895895

896896
############################################################################
897897
# Header files
@@ -944,7 +944,7 @@ PYTHON_HEADERS= \
944944
$(srcdir)/Include/node.h \
945945
$(srcdir)/Include/object.h \
946946
$(srcdir)/Include/objimpl.h \
947-
$(OPCODE_H) \
947+
$(srcdir)/Include/opcode.h \
948948
$(srcdir)/Include/osdefs.h \
949949
$(srcdir)/Include/osmodule.h \
950950
$(srcdir)/Include/patchlevel.h \
@@ -987,7 +987,7 @@ PYTHON_HEADERS= \
987987
$(srcdir)/Include/weakrefobject.h \
988988
pyconfig.h \
989989
$(PARSER_HEADERS) \
990-
$(AST_H) \
990+
$(srcdir)/Include/Python-ast.h \
991991
$(DTRACE_HEADERS)
992992

993993
$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
@@ -1554,9 +1554,12 @@ recheck:
15541554
$(SHELL) config.status --recheck
15551555
$(SHELL) config.status
15561556

1557-
# Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1557+
# Regenerate configure and pyconfig.h.in
1558+
.PHONY: autoconf
15581559
autoconf:
1560+
# Regenerate the configure script from configure.ac using autoconf
15591561
(cd $(srcdir); autoconf -Wall)
1562+
# Regenerate pyconfig.h.in from configure.ac using autoheader
15601563
(cd $(srcdir); autoheader -Wall)
15611564

15621565
# Create a tags file for vi
@@ -1573,14 +1576,6 @@ TAGS::
15731576
etags Include/*.h; \
15741577
for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15751578

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

Misc/NEWS

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ What's New in Python 3.6.2 release candidate 1?
1010
Core and Builtins
1111
-----------------
1212

13-
- bpo-12414: sys.getsizeof() on a code object now returns the sizes
13+
- bpo-12414: sys.getsizeof() on a code object now returns the sizes
1414
which includes the code struct and sizes of objects which it references.
1515
Patch by Dong-hee Na.
1616

@@ -116,6 +116,10 @@ Library
116116
Build
117117
-----
118118

119+
- bpo-23404: Don't regenerate generated files based on file modification time
120+
anymore: the action is now explicit. Replace ``make touch`` with
121+
``make regen-all``.
122+
119123
- bpo-29643: Fix ``--enable-optimization`` didn't work.
120124

121125
Documentation

0 commit comments

Comments
 (0)