# HG changeset patch # Parent 1d72402c1c91f4d7f95e142562aee17aac13eca6 Issue #22359: Decouple regeneration of checked-in files from main build Four files are now only regenerated by special “phony” Make targets: make graminit → Include/graminit.h and Python/graminit.c make importlib → Python/importlib.h make importlib_external → Python/importlib_external.h This avoids shared Make prerequisites from being built multiple times, and also avoids concerns with regenerating files unnecessarily and running cross- compiled programs on the native build host. Also remove makefile variables no longer in use. diff -r 1d72402c1c91 Grammar/Grammar --- a/Grammar/Grammar Tue Mar 15 13:33:28 2016 +1300 +++ b/Grammar/Grammar Wed Mar 16 04:23:08 2016 +0000 @@ -9,6 +9,7 @@ # NOTE WELL: You should also follow all the steps listed at # https://docs.python.org/devguide/grammar.html +# Use "make graminit" to regenerate Include/graminit.h and Python/graminit.c. # Start symbols for the grammar: # single_input is a single interactive statement; diff -r 1d72402c1c91 Lib/importlib/_bootstrap.py --- a/Lib/importlib/_bootstrap.py Tue Mar 15 13:33:28 2016 +1300 +++ b/Lib/importlib/_bootstrap.py Wed Mar 16 04:23:08 2016 +0000 @@ -8,10 +8,8 @@ """ # # IMPORTANT: Whenever making changes to this module, be sure to run -# a top-level make in order to get the frozen version of the module -# updated. Not doing so will result in the Makefile to fail for -# all others who don't have a ./python around to freeze the module -# in the early stages of compilation. +# "make importlib" in order to get the frozen version of the module +# updated. Not doing so will result in the frozen version being out of date. # # See importlib._setup() for what is injected into the global namespace. diff -r 1d72402c1c91 Lib/importlib/_bootstrap_external.py --- a/Lib/importlib/_bootstrap_external.py Tue Mar 15 13:33:28 2016 +1300 +++ b/Lib/importlib/_bootstrap_external.py Wed Mar 16 04:23:08 2016 +0000 @@ -8,10 +8,8 @@ """ # # IMPORTANT: Whenever making changes to this module, be sure to run -# a top-level make in order to get the frozen version of the module -# updated. Not doing so will result in the Makefile to fail for -# all others who don't have a ./python around to freeze the module -# in the early stages of compilation. +# "make importlib_external" in order to get the frozen version of the module +# updated. Not doing so will result in the frozen version being out of date. # # See importlib._setup() for what is injected into the global namespace. diff -r 1d72402c1c91 Makefile.pre.in --- a/Makefile.pre.in Tue Mar 15 13:33:28 2016 +1300 +++ b/Makefile.pre.in Wed Mar 16 04:23:08 2016 +0000 @@ -277,18 +277,6 @@ # Parser PGEN= Parser/pgen$(EXE) -PSRCS= \ - Parser/acceler.c \ - Parser/grammar1.c \ - Parser/listnode.c \ - Parser/node.c \ - Parser/parser.c \ - Parser/bitset.c \ - Parser/metagrammar.c \ - Parser/firstsets.c \ - Parser/grammar.c \ - Parser/pgen.c - POBJS= \ Parser/acceler.o \ Parser/grammar1.o \ @@ -303,16 +291,6 @@ PARSER_OBJS= $(POBJS) Parser/myreadline.o Parser/parsetok.o Parser/tokenizer.o -PGSRCS= \ - Objects/obmalloc.c \ - Python/dynamic_annotations.c \ - Python/mysnprintf.c \ - Python/pyctype.c \ - Parser/tokenizer_pgen.c \ - Parser/printgrammar.c \ - Parser/parsetok_pgen.c \ - Parser/pgenmain.c - PGOBJS= \ Objects/obmalloc.o \ Python/dynamic_annotations.o \ @@ -328,7 +306,6 @@ $(srcdir)/Include/parsetok.h \ $(srcdir)/Parser/tokenizer.h -PGENSRCS= $(PSRCS) $(PGSRCS) PGENOBJS= $(POBJS) $(PGOBJS) ########################################################################## @@ -546,7 +523,7 @@ @echo coverage-report: - : # force rebuilding of parser and importlib + : # force rebuilding of parser and importlib (broken!?) @touch $(GRAMMAR_INPUT) @touch $(srcdir)/Lib/importlib/_bootstrap.py @touch $(srcdir)/Lib/importlib/_bootstrap_external.py @@ -715,11 +692,15 @@ Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST) -Python/importlib_external.h: $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib +# Regenerate Python/importlib_external.h and Python/importlib.h +# See comment for the "graminit" target about generated files. +.PHONY: importlib_external importlib + +importlib_external: $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib ./Programs/_freeze_importlib \ $(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h -Python/importlib.h: $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib +importlib: $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib ./Programs/_freeze_importlib \ $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h @@ -781,11 +762,18 @@ $(IO_OBJS): $(IO_H) -$(GRAMMAR_H): $(GRAMMAR_INPUT) $(PGEN) +# Regenerate Include/graminit.h and Python/graminit.c +# This target (and the "importlib" targets) regenerate files that are +# checked into the repository and distributed with the Python source code. +# These files are not automatically generated during the normal build process +# for various reasons: +# * To avoid building shared prerequisites multiple times +# * To avoid running cross-compiled programs on the native build host +# * To minimize the steps involved in a basic build of Python +.PHONY: graminit +graminit: $(GRAMMAR_INPUT) $(PGEN) @$(MKDIR_P) Include $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C) -$(GRAMMAR_C): $(GRAMMAR_H) - touch $(GRAMMAR_C) $(PGEN): $(PGENOBJS) $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)