Skip to content

Commit

Permalink
Align to Micropyton v1.20.0
Browse files Browse the repository at this point in the history
Move LVGL build rules to exmod.mk
Update lv_bindings
  • Loading branch information
amirgon committed Jun 5, 2023
1 parent 5af201d commit 6ce2871
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 61 deletions.
2 changes: 1 addition & 1 deletion .gitpod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
63 changes: 63 additions & 0 deletions extmod/extmod.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion lib/lv_bindings
35 changes: 0 additions & 35 deletions ports/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
24 changes: 0 additions & 24 deletions py/py.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6ce2871

Please sign in to comment.