diff mbox series

[meta-oe,7/9] lvgl: Add support for modifying the configuration using menuconfig

Message ID 20251025031748.2728416-7-pkj@axis.com
State Under Review
Headers show
Series [meta-oe,1/9] python3-pcpp: Add recipe for https://github.com/ned14/pcpp | expand

Commit Message

Peter Kjellerstedt Oct. 25, 2025, 3:17 a.m. UTC
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 <peter.kjellerstedt@axis.com>
---

I plan on updating cml1.bbclass so that it better supports code that
does not use "make" to run menuconfig, maybe even giving it native
support for kconfiglib. However, due to the current situation, I do not
expect any such changes to be accepted until after Whinlatter is out of
the door. Thus, the copied do_menuconfig in this recipe will have to do
as an interim solution.

 meta-oe/recipes-graphics/lvgl/lv-conf.inc | 48 ++++++++++++++++++++++-
 1 file changed, 47 insertions(+), 1 deletion(-)

Comments

Khem Raj Oct. 25, 2025, 4:50 a.m. UTC | #1
On Fri, Oct 24, 2025 at 8:18 PM Peter Kjellerstedt via
lists.openembedded.org
<peter.kjellerstedt=axis.com@lists.openembedded.org> wrote:
>
> 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 <peter.kjellerstedt@axis.com>
> ---
>
> I plan on updating cml1.bbclass so that it better supports code that
> does not use "make" to run menuconfig, maybe even giving it native
> support for kconfiglib. However, due to the current situation, I do not
> expect any such changes to be accepted until after Whinlatter is out of
> the door. Thus, the copied do_menuconfig in this recipe will have to do
> as an interim solution.
>
>  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.

I wonder if we can add this flexibility to cml1.bbclass and use the
class directly then here.

> +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
> +}
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#120979): https://lists.openembedded.org/g/openembedded-devel/message/120979
> Mute This Topic: https://lists.openembedded.org/mt/115939735/1997914
> Group Owner: openembedded-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-devel/unsub [raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Peter Kjellerstedt Oct. 25, 2025, 5:02 a.m. UTC | #2
> -----Original Message-----
> From: Khem Raj <raj.khem@gmail.com>
> Sent: den 25 oktober 2025 06:51
> To: Peter Kjellerstedt <peter.kjellerstedt@axis.com>
> Cc: openembedded-devel@lists.openembedded.org
> Subject: Re: [oe] [meta-oe][PATCH 7/9] lvgl: Add support for modifying the configuration using menuconfig
> 
> On Fri, Oct 24, 2025 at 8:18 PM Peter Kjellerstedt via lists.openembedded.org <peter.kjellerstedt=axis.com@lists.openembedded.org> wrote:
> >
> > 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 <peter.kjellerstedt@axis.com>
> > ---
> >
> > I plan on updating cml1.bbclass so that it better supports code that
> > does not use "make" to run menuconfig, maybe even giving it native
> > support for kconfiglib. However, due to the current situation, I do not
> > expect any such changes to be accepted until after Whinlatter is out of
> > the door. Thus, the copied do_menuconfig in this recipe will have to do
> > as an interim solution.
> >
> >  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.
> 
> I wonder if we can add this flexibility to cml1.bbclass and use the
> class directly then here.

Yes, that is my plan. See my comment above.

> > +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
> > +}

//Peter
diff mbox series

Patch

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
+}