From 6ce287156002ce031689603983bd76d5c5e5a2fc Mon Sep 17 00:00:00 2001 From: Amir Gonnen Date: Sun, 4 Jun 2023 00:05:31 +0300 Subject: [PATCH] Align to Micropyton v1.20.0 Move LVGL build rules to exmod.mk Update lv_bindings --- .gitpod | 2 +- extmod/extmod.mk | 63 +++++++++++++++++++++++++++++++++++++++++++++ lib/lv_bindings | 2 +- ports/unix/Makefile | 35 ------------------------- py/py.mk | 24 ----------------- 5 files changed, 65 insertions(+), 61 deletions(-) diff --git a/.gitpod b/.gitpod index 6edd69c6ed8c..467bec33fb4d 100644 --- a/.gitpod +++ b/.gitpod @@ -15,7 +15,7 @@ tasks: # source tools/ci.sh && ci_esp32_build command: | xrandr --fb 500x500 # Fix resolution for LVGL screens which are smaller - ports/unix/micropython-dev -i lib/lv_bindings/examples/advanced_demo.py + ports/unix/build-standard/micropython -i lib/lv_bindings/examples/advanced_demo.py vscode: extensions: - ms-vscode.cpptools diff --git a/extmod/extmod.mk b/extmod/extmod.mk index 5aecedc2281b..4d6971af7c16 100644 --- a/extmod/extmod.mk +++ b/extmod/extmod.mk @@ -366,3 +366,66 @@ include $(TOP)/extmod/btstack/btstack.mk endif endif + +################################################################################ +# LVGL + +# Additional optional libraries + +ifneq ($(UNAME_S),Darwin) +CFLAGS_EXTMOD += -DMICROPY_FB=1 +endif + +SDL_CFLAGS_EXTMOD := $(shell pkg-config --silence-errors --cflags sdl2) +SDL_LDFLAGS_EXTMOD := $(shell pkg-config --silence-errors --libs sdl2) +ifneq ($(SDL_LDFLAGS_EXTMOD),) +CFLAGS_EXTMOD += $(SDL_CFLAGS_EXTMOD) -DMICROPY_SDL=1 +LDFLAGS_EXTMOD += $(SDL_LDFLAGS_EXTMOD) +endif + +RLOTTIE_CFLAGS_EXTMOD := $(shell pkg-config --silence-errors --cflags rlottie) +RLOTTIE_LDFLAGS_EXTMOD := $(shell pkg-config --silence-errors --libs rlottie) +ifneq ($(RLOTTIE_LDFLAGS_EXTMOD),) +CFLAGS_EXTMOD += $(RLOTTIE_CFLAGS_EXTMOD) -DMICROPY_RLOTTIE=1 +LDFLAGS_EXTMOD += $(RLOTTIE_LDFLAGS_EXTMOD) +endif + +FREETYPE_CFLAGS_EXTMOD := $(shell pkg-config --silence-errors --cflags freetype2) +FREETYPE_LDFLAGS_EXTMOD := $(shell pkg-config --silence-errors --libs freetype2) +ifneq ($(FREETYPE_LDFLAGS_EXTMOD),) +CFLAGS_EXTMOD += $(FREETYPE_CFLAGS_EXTMOD) -DMICROPY_FREETYPE=1 +LDFLAGS_EXTMOD += $(FREETYPE_LDFLAGS_EXTMOD) +endif + +FFMPEG_LIBS := libavformat libavcodec libswscale libavutil +FFMPEG_CFLAGS_EXTMOD := $(shell pkg-config --silence-errors --cflags $(FFMPEG_LIBS)) +FFMPEG_LDFLAGS_EXTMOD := $(shell pkg-config --silence-errors --libs $(FFMPEG_LIBS)) +ifneq ($(FFMPEG_LDFLAGS_EXTMOD),) +CFLAGS_EXTMOD += $(FFMPEG_CFLAGS_EXTMOD) -DMICROPY_FFMPEG=1 +LDFLAGS_EXTMOD += $(FFMPEG_LDFLAGS_EXTMOD) +endif + +# LVGL build rules + +LVGL_BINDING_DIR = $(TOP)/lib/lv_bindings +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_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 + $(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 > $@ + +.PHONY: LVGL_MPY +LVGL_MPY: $(LVGL_MPY) + +CFLAGS_EXTMOD += -Wno-unused-function +SRC_THIRDPARTY_C += $(subst $(TOP)/,,$(shell find $(LVGL_DIR)/src $(LVGL_DIR)/examples $(LVGL_GENERIC_DRV_DIR) -type f -name "*.c")) +SRC_EXTMOD_C += $(LVGL_MPY) diff --git a/lib/lv_bindings b/lib/lv_bindings index e4cc7668cd6e..90c631da3fde 160000 --- a/lib/lv_bindings +++ b/lib/lv_bindings @@ -1 +1 @@ -Subproject commit e4cc7668cd6ed170d71c874ab2ba15cc8804fd4a +Subproject commit 90c631da3fde4c6078bb7de57f32578af77bbd3d diff --git a/ports/unix/Makefile b/ports/unix/Makefile index e5f2363e3590..a4ea5bca2515 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -193,41 +193,6 @@ ifeq ($(MICROPY_PY_JNI),1) CFLAGS += -I/usr/lib/jvm/java-7-openjdk-amd64/include -DMICROPY_PY_JNI=1 endif -# Additional optional libraries - -ifneq ($(UNAME_S),Darwin) -CFLAGS_MOD += -DMICROPY_FB=1 -endif - -SDL_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags sdl2) -SDL_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs sdl2) -ifneq ($(SDL_LDFLAGS_MOD),) -CFLAGS_MOD += $(SDL_CFLAGS_MOD) -DMICROPY_SDL=1 -LDFLAGS_MOD += $(SDL_LDFLAGS_MOD) -endif - -RLOTTIE_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags rlottie) -RLOTTIE_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs rlottie) -ifneq ($(RLOTTIE_LDFLAGS_MOD),) -CFLAGS_MOD += $(RLOTTIE_CFLAGS_MOD) -DMICROPY_RLOTTIE=1 -LDFLAGS_MOD += $(RLOTTIE_LDFLAGS_MOD) -endif - -FREETYPE_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags freetype2) -FREETYPE_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs freetype2) -ifneq ($(FREETYPE_LDFLAGS_MOD),) -CFLAGS_MOD += $(FREETYPE_CFLAGS_MOD) -DMICROPY_FREETYPE=1 -LDFLAGS_MOD += $(FREETYPE_LDFLAGS_MOD) -endif - -FFMPEG_LIBS := libavformat libavcodec libswscale libavutil -FFMPEG_CFLAGS_MOD := $(shell pkg-config --silence-errors --cflags $(FFMPEG_LIBS)) -FFMPEG_LDFLAGS_MOD := $(shell pkg-config --silence-errors --libs $(FFMPEG_LIBS)) -ifneq ($(FFMPEG_LDFLAGS_MOD),) -CFLAGS_MOD += $(FFMPEG_CFLAGS_MOD) -DMICROPY_FFMPEG=1 -LDFLAGS_MOD += $(FFMPEG_LDFLAGS_MOD) -endif - # source files SRC_C += \ main.c \ diff --git a/py/py.mk b/py/py.mk index f04a816d7686..1dc0c8641f30 100644 --- a/py/py.mk +++ b/py/py.mk @@ -28,30 +28,6 @@ CXX += -m32 LD += -m32 endif -#LittlevGL -LVGL_BINDING_DIR = $(TOP)/lib/lv_bindings -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_PP = $(BUILD)/lvgl/lvgl.pp.c -LVGL_MPY = $(BUILD)/lvgl/lv_mpy.c -LVGL_MPY_METADATA = $(BUILD)/lvgl/lv_mpy.json -QSTR_GLOBAL_DEPENDENCIES += $(LVGL_MPY) -CFLAGS_MOD += $(LV_CFLAGS) - -$(LVGL_MPY): $(ALL_LVGL_SRC) $(LVGL_BINDING_DIR)/gen/gen_mpy.py - $(ECHO) "LVGL-GEN $@" - $(Q)mkdir -p $(dir $@) - $(Q)$(CPP) $(CFLAGS_MOD) -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 > $@ - -.PHONY: LVGL_MPY -LVGL_MPY: $(LVGL_MPY) - -CFLAGS_MOD += -Wno-unused-function -SRC_MOD += $(subst $(TOP)/,,$(shell find $(LVGL_DIR)/src $(LVGL_DIR)/examples $(LVGL_GENERIC_DRV_DIR) -type f -name "*.c") $(LVGL_MPY)) - # External modules written in C. ifneq ($(USER_C_MODULES),) # pre-define USERMOD variables as expanded so that variables are immediate