Skip to content

Commit 2133924

Browse files
committed
unix: Support frozen packages.
To use, put your directory structure with .py files in frozen/ and then: make FROZEN_MPY_DIR=frozen
1 parent 202d5ac commit 2133924

1 file changed

Lines changed: 4 additions & 7 deletions

File tree

unix/Makefile

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,22 +181,19 @@ ifneq ($(FROZEN_MPY_DIR),)
181181
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
182182
MPY_CROSS = ../mpy-cross/mpy-cross
183183
MPY_TOOL = ../tools/mpy-tool.py
184-
FROZEN_MPY_PY_FILES := $(wildcard $(FROZEN_MPY_DIR)/*.py)
184+
FROZEN_MPY_PY_FILES := $(shell find $(FROZEN_MPY_DIR)/ -type f -name '*.py')
185185
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
186186
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
187187
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
188188
CFLAGS += -DMICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE=0 # not supported
189189
CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs
190190
OBJ += $(BUILD)/$(BUILD)/frozen_mpy.o
191191

192-
# to create output directory for .mpy files
193-
$(BUILD)/$(FROZEN_MPY_DIR):
194-
$(MKDIR) -p $@
195-
196192
# to build .mpy files from .py files
197-
$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py | $(BUILD)/$(FROZEN_MPY_DIR)
193+
$(BUILD)/$(FROZEN_MPY_DIR)/%.mpy: $(FROZEN_MPY_DIR)/%.py
198194
@$(ECHO) "MPY $<"
199-
$(Q)$(MPY_CROSS) -o $@ $^
195+
$(Q)$(MKDIR) -p $(dir $@)
196+
$(Q)$(MPY_CROSS) -o $@ -s $(^:$(FROZEN_MPY_DIR)/%=%) $^
200197

201198
# to build frozen_mpy.c from all .mpy files
202199
$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h

0 commit comments

Comments
 (0)