Skip to content

Commit 24dd8a1

Browse files
authored
Merge pull request lvgl#84 from liamHowatt/fix/lvgl-api-refactor
feat(gen): generate LVGL API JSON and pass it to gen_mpy.py
2 parents 96162df + a190ce4 commit 24dd8a1

File tree

2 files changed

+19
-3
lines changed

2 files changed

+19
-3
lines changed

extmod/extmod.mk

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,18 +375,34 @@ LVGL_DIR = $(LVGL_BINDING_DIR)/lvgl
375375
LVGL_GENERIC_DRV_DIR = $(LVGL_BINDING_DIR)/driver/generic
376376
INC += -I$(LVGL_BINDING_DIR)
377377
ALL_LVGL_SRC = $(shell find $(LVGL_DIR) -type f -name '*.h') $(LVGL_BINDING_DIR)/lv_conf.h
378+
LVGL_ALL_H = $(BUILD)/lvgl/lvgl_all.h
379+
LVGL_ALL_JSON = $(BUILD)/lvgl/lvgl_all.json
378380
LVGL_PP = $(BUILD)/lvgl/lvgl.pp.c
379381
LVGL_MPY = $(BUILD)/lvgl/lv_mpy.c
380382
LVGL_MPY_METADATA = $(BUILD)/lvgl/lv_mpy.json
381383
CFLAGS_EXTMOD += $(LV_CFLAGS)
382384

383-
$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py
385+
ifneq (,$(wildcard $(LVGL_DIR)/scripts/gen_json/gen_json.py))
386+
$(LVGL_ALL_JSON): $(ALL_LVGL_SRC) $(LVGL_DIR)/scripts/gen_json/gen_json.py
387+
$(ECHO) "LVGL-JSON-GEN $@"
388+
$(Q)mkdir -p $(dir $@)
389+
$(ECHO) "#include \"$(LVGL_DIR)/lvgl.h\"\n#include \"$(LVGL_DIR)/src/lvgl_private.h\"" > $(LVGL_ALL_H)
390+
$(Q)$(PYTHON) $(LVGL_DIR)/scripts/gen_json/gen_json.py --target-header $(LVGL_ALL_H) > $(LVGL_ALL_JSON)
391+
else
392+
$(LVGL_ALL_JSON):
393+
$(ECHO) "LVGL-JSON-GEN $@"
394+
$(Q)mkdir -p $(dir $@)
395+
$(ECHO) "{}" > $(LVGL_ALL_JSON)
396+
endif
397+
398+
$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py $(LVGL_ALL_JSON)
384399
$(ECHO) "LVGL-GEN $@"
385400
$(Q)mkdir -p $(dir $@)
386401
$(Q)$(CPP) $(CFLAGS_EXTMOD) -DPYCPARSER -x c -I $(LVGL_BINDING_DIR)/pycparser/utils/fake_libc_include $(INC) $(LVGL_DIR)/lvgl.h > $(LVGL_PP)
387-
$(Q)$(PYTHON) $(LVGL_BINDING_DIR)/gen/gen_mpy.py -M lvgl -MP lv -MD $(LVGL_MPY_METADATA) -E $(LVGL_PP) $(LVGL_DIR)/lvgl.h > $@
402+
$(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 > $@
388403

389404
.PHONY: LVGL_MPY
405+
LVGL_ALL_JSON: $(LVGL_ALL_JSON)
390406
LVGL_MPY: $(LVGL_MPY)
391407

392408
CFLAGS_EXTMOD += -Wno-unused-function

lib/lv_bindings

0 commit comments

Comments
 (0)