Skip to content

Commit

Permalink
Merge pull request #84 from liamHowatt/fix/lvgl-api-refactor
Browse files Browse the repository at this point in the history
feat(gen): generate LVGL API JSON and pass it to gen_mpy.py
  • Loading branch information
kisvegabor authored Jul 19, 2024
2 parents 96162df + a190ce4 commit 24dd8a1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions extmod/extmod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -375,18 +375,34 @@ LVGL_DIR = $(LVGL_BINDING_DIR)/lvgl
LVGL_GENERIC_DRV_DIR = $(LVGL_BINDING_DIR)/driver/generic
INC += -I$(LVGL_BINDING_DIR)
ALL_LVGL_SRC = $(shell find $(LVGL_DIR) -type f -name '*.h') $(LVGL_BINDING_DIR)/lv_conf.h
LVGL_ALL_H = $(BUILD)/lvgl/lvgl_all.h
LVGL_ALL_JSON = $(BUILD)/lvgl/lvgl_all.json
LVGL_PP = $(BUILD)/lvgl/lvgl.pp.c
LVGL_MPY = $(BUILD)/lvgl/lv_mpy.c
LVGL_MPY_METADATA = $(BUILD)/lvgl/lv_mpy.json
CFLAGS_EXTMOD += $(LV_CFLAGS)

$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py
ifneq (,$(wildcard $(LVGL_DIR)/scripts/gen_json/gen_json.py))
$(LVGL_ALL_JSON): $(ALL_LVGL_SRC) $(LVGL_DIR)/scripts/gen_json/gen_json.py
$(ECHO) "LVGL-JSON-GEN $@"
$(Q)mkdir -p $(dir $@)
$(ECHO) "#include \"$(LVGL_DIR)/lvgl.h\"\n#include \"$(LVGL_DIR)/src/lvgl_private.h\"" > $(LVGL_ALL_H)
$(Q)$(PYTHON) $(LVGL_DIR)/scripts/gen_json/gen_json.py --target-header $(LVGL_ALL_H) > $(LVGL_ALL_JSON)
else
$(LVGL_ALL_JSON):
$(ECHO) "LVGL-JSON-GEN $@"
$(Q)mkdir -p $(dir $@)
$(ECHO) "{}" > $(LVGL_ALL_JSON)
endif

$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py $(LVGL_ALL_JSON)
$(ECHO) "LVGL-GEN $@"
$(Q)mkdir -p $(dir $@)
$(Q)$(CPP) $(CFLAGS_EXTMOD) -DPYCPARSER -x c -I $(LVGL_BINDING_DIR)/pycparser/utils/fake_libc_include $(INC) $(LVGL_DIR)/lvgl.h > $(LVGL_PP)
$(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/gen_mpy.py -M lvgl -MP lv -MD $(LVGL_MPY_METADATA) -E $(LVGL_PP) $(LVGL_DIR)/lvgl.h > $@
$(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/gen_mpy.py -M lvgl -MP lv -MD $(LVGL_MPY_METADATA) -E $(LVGL_PP) -J $(LVGL_ALL_JSON) $(LVGL_DIR)/lvgl.h > $@

.PHONY: LVGL_MPY
LVGL_ALL_JSON: $(LVGL_ALL_JSON)
LVGL_MPY: $(LVGL_MPY)

CFLAGS_EXTMOD += -Wno-unused-function
Expand Down
2 changes: 1 addition & 1 deletion lib/lv_bindings
Submodule lv_bindings updated 1 files
+15 −2 gen/gen_mpy.py

0 comments on commit 24dd8a1

Please sign in to comment.