8000 stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode. · micropython/micropython@42bc25b · GitHub
[go: up one dir, main page]

Skip to content

Commit 42bc25b

Browse files
committed
stmhal: Add Makefile option FROZEN_MPY_DIR to support frozen bytecode.
1 parent 42b6bbe commit 42bc25b

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

stmhal/Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,28 @@ $(BUILD)/frozen-files.c: $(shell find $(FROZEN_DIR) -type f)
276276
$(Q)$(PYTHON) $(MAKE_FROZEN) $(FROZEN_DIR) > $@
277277
endif
278278

279+
ifneq ($(FROZEN_MPY_DIR),)
280+
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
281+
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
282+
FROZEN_MPY_FILES := $(wildcard $(FROZEN_MPY_DIR)/*.py)
283+
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
284+
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
285+
OBJ += $(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.o
286+
MPY_CROSS = ../mpy-cross/mpy-cross
287+
MPY_TOOL = ../tools/mpy-tool.py
288+
289+
$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py
290+
@$(ECHO) "MPY $<"
291+
$(Q)$(MPY_CROSS) -o $@ $^
292+
293+
$(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.c: $(addprefix $(BUILD)/,$(FROZEN_MPY_FILES:.py=.mpy))
294+
@$(ECHO) "Creating $@"
295+
$(Q)$(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $^ > $@
296+
297+
$(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.o: $(BUILD)/$(FROZEN_MPY_DIR)/frozen_mpy.c
298+
$(call compile_c)
299+
endif
300+
279301
.PHONY: deploy
280302

281303
deploy: $(BUILD)/firmware.dfu

0 commit comments

Comments
 (0)
0