Adapt from our FROZEN_MPY_DIRS to manifests, incuding preprocessing

This commit is contained in:
Jeff Epler 2022-02-16 15:33:54 -06:00
parent 0326e004b8
commit 4f47a5e61c
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
3 changed files with 17 additions and 8 deletions

View File

@ -79,12 +79,8 @@ STATIC void mp_help_add_from_names(mp_obj_t list, const char *name) {
// These externs were originally declared inside mp_help_print_modules(),
// but they triggered -Wnested-externs, so they were moved outside.
#if MICROPY_MODULE_FROZEN_STR
extern const char mp_frozen_str_names[];
#endif
#if MICROPY_MODULE_FROZEN_MPY
extern const char mp_frozen_mpy_names[];
#if MICROPY_MODULE_FROZEN
extern const char mp_frozen_names[];
#endif
STATIC void mp_help_print_modules(void) {
@ -93,7 +89,6 @@ STATIC void mp_help_print_modules(void) {
mp_help_add_from_map(list, &mp_builtin_module_map);
#if MICROPY_MODULE_FROZEN
extern const char mp_frozen_names[];
mp_help_add_from_names(list, mp_frozen_names);
#endif

View File

@ -489,6 +489,7 @@ CFLAGS += -DLONGINT_IMPL_LONGLONG
else
$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)")
endif
MPY_TOOL_FLAGS += $(MPY_TOOL_LONGINT_IMPL)
###
ifeq ($(LONGINT_IMPL),NONE)
@ -497,3 +498,16 @@ else ifeq ($(LONGINT_IMPL),LONGLONG)
else
$(error LONGINT_IMPL set to surprising value: "$(LONGINT_IMPL)")
endif
PREPROCESS_FROZEN_MODULES = PYTHONPATH=$(TOP)/tools/python-semver $(TOP)/tools/preprocess_frozen_modules.py
ifneq ($(FROZEN_MPY_DIRS),)
$(BUILD)/frozen_mpy: $(FROZEN_MPY_DIRS)
$(ECHO) FREEZE $(FROZEN_MPY_DIRS)
$(Q)$(MKDIR) -p $@
$(Q)$(PREPROCESS_FROZEN_MODULES) -o $@ $(FROZEN_MPY_DIRS)
$(BUILD)/manifest.py: $(BUILD)/frozen_mpy | $(TOP)/py/circuitpy_mpconfig.mk mpconfigport.mk boards/$(BOARD)/mpconfigboard.mk
$(ECHO) MKMANIFEST $(FROZEN_MPY_DIRS)
(cd $(BUILD)/frozen_mpy && find * -name \*.py -exec printf 'freeze_as_mpy("frozen_mpy", "%s")\n' {} \; )> $@.tmp && mv -f $@.tmp $@
FROZEN_MANIFEST=$(BUILD)/manifest.py
endif

View File

@ -135,7 +135,7 @@ endif
ifneq ($(FROZEN_MANIFEST),)
# to build frozen_content.c from a manifest
$(BUILD)/frozen_content.c: FORCE $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY)
$(BUILD)/frozen_content.c: FORCE $(FROZEN_MANIFEST) $(BUILD)/genhdr/qstrdefs.generated.h | $(MICROPY_MPYCROSS_DEPENDENCY) $(TOP)/tools/makemanifest.py
$(Q)$(MAKE_MANIFEST) -o $@ -v "MPY_DIR=$(TOP)" -v "MPY_LIB_DIR=$(MPY_LIB_DIR)" -v "PORT_DIR=$(shell pwd)" -v "BOARD_DIR=$(BOARD_DIR)" -b "$(BUILD)" $(if $(MPY_CROSS_FLAGS),-f"$(MPY_CROSS_FLAGS)",) --mpy-tool-flags="$(MPY_TOOL_FLAGS)" $(FROZEN_MANIFEST)
endif