8000 bpo-23404: make touch becomes make regen-all (#1405) · xiaolanpython/cpython@a5c62a8 · GitHub
[go: up one dir, main page]

Skip to content

Commit a5c62a8

Browse files
authored
bpo-23404: make touch becomes make regen-all (python#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.
1 parent 13f1f42 commit a5c62a8

File tree

7 files changed

+89
-263
lines changed

7 files changed

+89
-263
lines changed

.hgtouch

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

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 & 81 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 \
@@ -548,11 +514,8 @@ coverage-lcov:
548514
@echo "lcov report at $(COVERAGE_REPORT)/index.html"
549515
@echo
550516

551-
coverage-report:
552-
@ # force rebuilding of parser and importlib
553-
@touch $(GRAMMAR_INPUT)
554-
@touch $(srcdir)/Lib/importlib/_bootstrap.py
555-
@touch $(srcdir)/Lib/importlib/_bootstrap_external.py
517+
# Force regeneration of parser and importlib
518+
coverage-report: regen-grammar regen-importlib
556519
@ # build with coverage info
557520
$(MAKE) coverage
558521
@ # run tests, ignore failures
@@ -724,14 +687,24 @@ Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
724687
Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
725688
$(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
726689

727-
Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib Python/marshal.c
690+
.PHONY: regen-importlib
691+
regen-importlib: Programs/_freeze_importlib
692+
# Regenerate Python/importlib_external.h
693+
# from Lib/importlib/_bootstrap_external.py using _freeze_importlib
728694
./Programs/_freeze_importlib \
729-
$(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h
730-
731-
Python/importlib.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib Python/marshal.c
695+
$(srcdir)/Lib/importlib/_bootstrap_external.py \
696+
$(srcdir)/Python/importlib_external.h
697+
# Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
698+
# using _freeze_importlib
732699
./Programs/_freeze_importlib \
733-
$(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
700+
$(srcdir)/Lib/importlib/_bootstrap.py \
701+
$(srcdir)/Python/importlib.h
702+
703+
704+
############################################################################
705+
# Regenerate all generated files
734706

707+
regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar regen-ast regen-importlib
735708

736709
############################################################################
737710
# Special rules for object files
@@ -790,15 +763,18 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
790763

791764
$(IO_OBJS): $(IO_H)
792765

793-
$(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
794-
@$(MKDIR_P) Include
795-
$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
796-
$(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
797-
touch $(GRAMMAR_C)
798-
799766
$(PGEN): $(PGENOBJS)
800767
$(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
801768

769+
.PHONY: regen-grammar
770+
regen-grammar: $(PGEN)
771+
# Regenerate Include/graminit.h and Python/graminit.c
772+
# from Grammar/Grammar using pgen
773+
@$(MKDIR_P) Include
774+
$(PGEN) $(srcdir)/Grammar/Grammar \
775+
$(srcdir)/Include/graminit.h \
776+
$(srcdir)/Python/graminit.c
777+
802778
Parser/grammar.o: $(srcdir)/Parser/grammar.c \
803779
$(srcdir)/Include/token.h \
804780
$(srcdir)/Include/grammar.h
@@ -810,18 +786,28 @@ Parser/printgrammar.o: $(srcdir)/Parser/printgrammar.c
810786

811787
Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
812788

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

826812
Python/getplatform.o: $(srcdir)/Python/getplatform.c
827813
$(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -871,12 +857,16 @@ Objects/odictobject.o: $(srcdir)/Objects/dict-common.h
871857
Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h $(srcdir)/Objects/dict-common.h
872858
Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
873859

874-
$(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
875-
$(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
876866

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

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

881871
# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
882872
# follow our naming conventions. dtrace(1) uses the output filename to generate
@@ -891,8 +881,14 @@ Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
891881
$(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
892882

893883
Objects/typeobject.o: Objects/typeslots.inc
894-
Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
895-
$(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
884+
885+
.PHONY: regen-typeslots
886+
regen-typeslots:
887+
# Regenerate Objects/typeslots.inc from Include/typeslotsh
888+
# using Objects/typeslots.py
889+
$(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
890+
< $(srcdir)/Include/typeslots.h \
891+
$(srcdir)/Objects/typeslots.inc
896892

897893
############################################################################
898894
# Header files
@@ -945,7 +941,7 @@ PYTHON_HEADERS= \
945941
$(srcdir)/Include/node.h \
946942
$(srcdir)/Include/object.h \
947943
$(srcdir)/Include/objimpl.h \
948-
$(OPCODE_H) \
944+
$(srcdir)/Include/opcode.h \
949945
$(srcdir)/Include/osdefs.h \
950946
$(srcdir)/Include/osmodule.h \
951947
$(srcdir)/Include/patchlevel.h \
@@ -988,7 +984,7 @@ PYTHON_HEADERS= \
988984
$(srcdir)/Include/weakrefobject.h \
989985
pyconfig.h \
990986
$(PARSER_HEADERS) \
991-
$(AST_H) \
987+
$(srcdir)/Include/Python-ast.h \
992988
$(DTRACE_HEADERS)
993989

994990
$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
@@ -1555,9 +1551,12 @@ recheck:
15551551
$(SHELL) config.status --recheck
15561552
$(SHELL) config.status
15571553

1558-
# Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1554+
# Regenerate configure and pyconfig.h.in
1555+
.PHONY: autoconf
15591556
autoconf:
1557+
# Regenerate the configure script from configure.ac using autoconf
15601558
(cd $(srcdir); autoconf -Wall)
1559+
# Regenerate pyconfig.h.in from configure.ac using autoheader
15611560
(cd $(srcdir); autoheader -Wall)
15621561

15631562
# Create a tags file for vi
@@ -1574,14 +1573,6 @@ TAGS::
15741573
etags Include/*.h; \
15751574
for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15761575

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

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,10 @@ Documentation
10261026
Build
10271027
-----
10281028

1029+
- bpo-23404: Don't regenerate generated files based on file modification time
1030+
anymore: the action is now explicit. Replace ``make touch`` with
1031+
``make regen-all``.
1032+
10291033
- bpo-29643: Fix ``--enable-optimization`` didn't work.
10301034

10311035
- bpo-27593: sys.version and the platform module python_build(),

0 commit comments

Comments
 (0)
0