From 9f73c95792669f1693964a87e8e3fe389a9b7f73 Mon Sep 17 00:00:00 2001 From: Peter Kjellerstedt Date: Sat, 25 Oct 2025 05:17:46 +0200 Subject: [PATCH] lvgl: Add support for modifying the configuration using menuconfig Generating a configuration fragment for a feature can now be done using: bitbake lvgl -c menuconfig && bitbake lvgl -c diffconfig While this uses the standard cml1.bbclass, it expects that "make" is used to run menuconfig etc. This is not true for lvgl, so unfortunately the whole do_menuconfig() function had to be copied to be able to remove the use of "make". Signed-off-by: Peter Kjellerstedt Signed-off-by: Khem Raj --- meta-oe/recipes-graphics/lvgl/lv-conf.inc | 48 ++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/meta-oe/recipes-graphics/lvgl/lv-conf.inc b/meta-oe/recipes-graphics/lvgl/lv-conf.inc index ab3ad01a5a..cc8a2a16d9 100644 --- a/meta-oe/recipes-graphics/lvgl/lv-conf.inc +++ b/meta-oe/recipes-graphics/lvgl/lv-conf.inc @@ -21,7 +21,7 @@ PACKAGECONFIG[gridnav] = ",," PACKAGECONFIG[thorvg] = ",," PACKAGECONFIG[sdl] = ",,virtual/libsdl2 libsdl2-image" -inherit python3native +inherit cml1 python3native EXTRA_OECMAKE += "-DLV_BUILD_USE_KCONFIG=ON" @@ -35,6 +35,7 @@ CXXFLAGS += "${LVGL_FLAGS}" KCONFIG_CONFIG_ROOTDIR ?= "${S}" KCONFIG_FILE ?= "${KCONFIG_CONFIG_ROOTDIR}/Kconfig" export KCONFIG_CONFIG ?= "${KCONFIG_CONFIG_ROOTDIR}/.config" +KCONFIG_CONFIG_COMMAND ?= "menuconfig ${KCONFIG_FILE}" do_configure() { cat ${UNPACKDIR}/defconfig ${@" ".join(find_cfgs(d))} > ${B}/defconfig @@ -42,3 +43,48 @@ do_configure() { cmake_do_configure } + +# Copied from cml1.bbclass. The only modification is that +# ${KCONFIG_CONFIG_COMMAND} is not prefixed with "make" when called by +# oe_terminal. +python do_menuconfig() { + import shutil + + if not bb.utils.to_boolean(d.getVar("KCONFIG_CONFIG_ENABLE_MENUCONFIG")): + bb.fatal("do_menuconfig is disabled, please check KCONFIG_CONFIG_ENABLE_MENUCONFIG variable.") + return + + config = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config") + configorig = os.path.join(d.getVar('KCONFIG_CONFIG_ROOTDIR'), ".config.orig") + + try: + mtime = os.path.getmtime(config) + shutil.copy(config, configorig) + except OSError: + mtime = 0 + + # setup native pkg-config variables (kconfig scripts call pkg-config directly, cannot generically be overriden to pkg-config-native) + d.setVar("PKG_CONFIG_DIR", "${STAGING_DIR_NATIVE}${libdir_native}/pkgconfig") + d.setVar("PKG_CONFIG_PATH", "${PKG_CONFIG_DIR}:${STAGING_DATADIR_NATIVE}/pkgconfig") + d.setVar("PKG_CONFIG_LIBDIR", "${PKG_CONFIG_DIR}") + d.setVarFlag("PKG_CONFIG_SYSROOT_DIR", "unexport", "1") + # ensure that environment variables are overwritten with this tasks 'd' values + d.appendVar("OE_TERMINAL_EXPORTS", " PKG_CONFIG_DIR PKG_CONFIG_PATH PKG_CONFIG_LIBDIR PKG_CONFIG_SYSROOT_DIR") + + oe_terminal("sh -c '%s; if [ $? -ne 0 ]; then echo \"Command failed.\"; printf \"Press any key to continue... \"; read r; fi'" % d.getVar('KCONFIG_CONFIG_COMMAND'), + d.getVar('PN') + ' Configuration', d) + + try: + newmtime = os.path.getmtime(config) + except OSError: + newmtime = 0 + + if newmtime > mtime: + bb.plain("Changed configuration saved at:\n %s\nRecompile will be forced" % config) + bb.build.write_taint('do_compile', d) +} + +do_savedefconfig() { + bbplain "Saving defconfig to:\n${B}/defconfig" + savedefconfig --kconfig ${KCONFIG_FILE} --out ${B}/defconfig +}