From 41739506589ec8397613c86d8f682fb7f86c0a9f Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 31 May 2019 14:37:11 +1000 Subject: [PATCH] mpy-cross: Do not automatically build mpy-cross, rather do it manually. Building mpy-cross automatically leads to some issues with the build process and slows it down. Instead, require it to be built manually. --- README.md | 11 +++++++++++ mpy-cross/Makefile | 17 ----------------- py/mkrules.mk | 6 +----- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 843511a60b..aaf310b662 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,17 @@ You will also need bash, gcc, and Python 3.3+ available as the command `python3` (if your system only has Python 2.7 then invoke make with the additional option `PYTHON=python2`). +The MicroPython cross-compiler, mpy-cross +----------------------------------------- + +Most ports require the MicroPython cross-compiler to be built first. This +program, called mpy-cross, is used to pre-compile Python scripts to .mpy +files which can then be included (frozen) into the firmware/executable for +a port. To build mpy-cross use: + + $ cd mpy-cross + $ make + The Unix version ---------------- diff --git a/mpy-cross/Makefile b/mpy-cross/Makefile index 4ff96fc80c..2116cc6708 100644 --- a/mpy-cross/Makefile +++ b/mpy-cross/Makefile @@ -1,20 +1,3 @@ -# The following is a temporary hack to forefully undefine vars that might have -# be defined by a calling Makefile (from recursive make). -# TODO: Find a better way to be able to call this Makefile recursively. -ifneq ($(findstring undefine,$(.FEATURES)),) -override undefine COPT -override undefine CFLAGS_EXTRA -override undefine LDFLAGS_EXTRA -override undefine MICROPY_FORCE_32BIT -override undefine CROSS_COMPILE -override undefine FROZEN_DIR -override undefine FROZEN_MPY_DIR -override undefine USER_C_MODULES -override undefine SRC_MOD -override undefine BUILD -override undefine PROG -endif - include ../py/mkenv.mk # define main target diff --git a/py/mkrules.mk b/py/mkrules.mk index 4e4fdef55c..5c214090cc 100644 --- a/py/mkrules.mk +++ b/py/mkrules.mk @@ -103,16 +103,12 @@ $(BUILD)/frozen.c: $(wildcard $(FROZEN_DIR)/*) $(HEADER_BUILD) $(FROZEN_EXTRA_DE endif ifneq ($(FROZEN_MPY_DIR),) -# to build the MicroPython cross compiler -$(TOP)/mpy-cross/mpy-cross: $(TOP)/py/*.[ch] $(TOP)/mpy-cross/*.[ch] $(TOP)/ports/windows/fmode.c - $(Q)$(MAKE) -C $(TOP)/mpy-cross - # make a list of all the .py files that need compiling and freezing FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)/==') FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/frozen_mpy/,$(FROZEN_MPY_PY_FILES:.py=.mpy)) # to build .mpy files from .py files -$(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py $(TOP)/mpy-cross/mpy-cross +$(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py @$(ECHO) "MPY $<" $(Q)$(MKDIR) -p $(dir $@) $(Q)$(MPY_CROSS) -o $@ -s $(<:$(FROZEN_MPY_DIR)/%=%) $(MPY_CROSS_FLAGS) $<