stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode.

This commit is contained in:
Damien George 2016-02-25 12:19:40 +00:00
parent f9448ddc2c
commit 733db525e2

View File

@ -279,6 +279,28 @@ $(BUILD)/frozen-files.c: $(shell find $(FROZEN_DIR) -type f)
$(Q)$(PYTHON) $(MAKE_FROZEN) $(FROZEN_DIR) > $@ $(Q)$(PYTHON) $(MAKE_FROZEN) $(FROZEN_DIR) > $@
endif endif
ifneq ($(FROZEN_MPY_DIR),)
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
FROZEN_MPY_FILES := $(wildcard $(FROZEN_MPY_DIR)/*.py)
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
OBJ += $(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.o
MPY_CROSS = ../mpy-cross/mpy-cross
MPY_TOOL = ../tools/mpy-tool.py
$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py
@$(ECHO) "MPY $<"
$(Q)$(MPY_CROSS) -o $@ $^
$(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.c: $(addprefix $(BUILD)/,$(FROZEN_MPY_FILES:.py=.mpy))
@$(ECHO) "Creating $@"
$(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $^ > $@
$(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.o: $(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.c
$(call compile_c)
endif
.PHONY: deploy .PHONY: deploy
deploy: $(BUILD)/firmware.dfu deploy: $(BUILD)/firmware.dfu