@@ -101,29 +101,30 @@ $(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DE
101101 $(Q )$(MAKE_FROZEN ) $(FROZEN_DIR ) > $@
102102endif
103103
104- ifneq ($(FROZEN_MPY_DIR ) ,)
104+ ifneq ($(FROZEN_MPY_DIRS ) ,)
105105# to build the MicroPython cross compiler
106- $(TOP ) /mpy-cross/mpy-cross : $(TOP ) /py/* .[ch] $(TOP ) /mpy-cross/* .[ch] $(TOP ) /windows/fmode.c
106+ # Currently not used, because the wrong mpy-cross may be left over from a previous build. Build by hand to make sure.
107+ $(MPY_CROSS ) : $(TOP ) /py/* .[ch] $(TOP ) /mpy-cross/* .[ch] $(TOP ) /windows/fmode.c
107108 $(Q )$(MAKE ) -C $(TOP ) /mpy-cross
108109
109- # make a list of all the .py files that need compiling and freezing
110- BLAH := $( info $( shell pwd) )
111-
112- FROZEN_MPY_PY_FILES := $( shell find -L $( FROZEN_MPY_DIR ) -type f -name ' * .py' | $( SED ) -e 's=^ $( FROZEN_MPY_DIR ) /==' )
113- FROZEN_MPY_MPY_FILES := $( addprefix $( BUILD ) /frozen_mpy/, $( FROZEN_MPY_PY_FILES:.py=.mpy ) )
114-
115- # to build .mpy files from .py files
116- $( BUILD ) /frozen_mpy/ % .mpy : $( FROZEN_MPY_DIR ) / % .py
117- @ $( ECHO ) " MPY $< "
118- $( Q )$( MKDIR ) -p $( dir $@ )
119- $( Q )$( MPY_CROSS ) -o $@ -s $( <: $( FROZEN_MPY_DIR ) /%=% ) $(MPY_CROSS_FLAGS ) $<
110+ # Copy all the modules and single python files to freeze to a common area, omitting top-level dirs (the repo names).
111+ # Remove any conf.py (sphinx config) and setup.py (module install info) files, which are not meant to be frozen.
112+ # Then compile .mpy files from all the .py files, placing them in the same directories as the .py files.
113+ $( BUILD ) /frozen_mpy : $( FROZEN_MPY_DIRS )
114+ $( ECHO ) FREEZE $( FROZEN_MPY_DIRS )
115+ $( Q )$( MKDIR ) -p $@
116+ $( Q )$( RSYNC ) -rL --include= " */ " --include= ' *.py ' --exclude= " * " $( addsuffix / * , $( FROZEN_MPY_DIRS ) ) $@
117+ $( Q )$( RM ) -f $@ /conf.py $@ /setup .py
118+ $( Q )$( CD ) $@ && \
119+ $(FIND) -L . -type f -name '*.py' | sed 's=^\./==' | \
120+ xargs -n1 $(abspath $(MPY_CROSS) ) $(MPY_CROSS_FLAGS)
120121
121122# to build frozen_mpy.c from all .mpy files
122123# You need to define MPY_TOOL_LONGINT_IMPL in mpconfigport.mk
123124# if the default will not work (mpz is the default).
124- $(BUILD ) /frozen_mpy.c : $(FROZEN_MPY_MPY_FILES ) $(BUILD ) /genhdr/qstrdefs.generated.h
125+ $(BUILD ) /frozen_mpy.c : $(BUILD ) /frozen_mpy $(BUILD ) /genhdr/qstrdefs.generated.h
125126 $(STEPECHO ) " Creating $@ "
126- $(Q )$(PYTHON ) $(MPY_TOOL ) $(MPY_TOOL_LONGINT_IMPL ) -f -q $(BUILD ) /genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES ) > $@
127+ $(Q )$(PYTHON ) $(MPY_TOOL ) $(MPY_TOOL_LONGINT_IMPL ) -f -q $(BUILD ) /genhdr/qstrdefs.preprocessed.h $(shell $( FIND ) -L $( BUILD ) /frozen_mpy -type f -name ' * .mpy' ) > $@
127128endif
128129
129130ifneq ($(PROG ) ,)
0 commit comments