From 733db525e2f7096289ee5d710f7a7f3891da4fd5 Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 25 Feb 2016 12:19:40 +0000 Subject: [PATCH] stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode. --- stmhal/Makefile | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/stmhal/Makefile b/stmhal/Makefile index 7dde98bd14..b305e45063 100644 --- a/stmhal/Makefile +++ b/stmhal/Makefile @@ -279,6 +279,28 @@ $(BUILD)/frozen-files.c: $(shell find $(FROZEN_DIR) -type f) $(Q)$(PYTHON) $(MAKE_FROZEN) $(FROZEN_DIR) > $@ 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 deploy: $(BUILD)/firmware.dfu