diff mbox series

[v2,1/3] kernel: classes: Extract savedefconfig to a class

Message ID 20221012071813.778-1-alex.kiernan@gmail.com
State New
Headers show
Series [v2,1/3] kernel: classes: Extract savedefconfig to a class | expand

Commit Message

Alex Kiernan Oct. 12, 2022, 7:18 a.m. UTC
Move savedefconfig task to a class so we can reuse it in other recipes
which support it.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---
 meta/classes-recipe/cml1-savedefconfig.bbclass | 12 ++++++++++++
 meta/classes-recipe/kernel.bbclass             |  9 +--------
 2 files changed, 13 insertions(+), 8 deletions(-)
 create mode 100644 meta/classes-recipe/cml1-savedefconfig.bbclass

Comments

Ross Burton Oct. 12, 2022, 4:35 p.m. UTC | #1
On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> 
> Move savedefconfig task to a class so we can reuse it in other recipes
> which support it.

There are three users of cml1 in oe-core: kernel, uboot, and busybox.  Does busybox support savedefconfig?

I’m thinking to avoid tiny classes we can just add this to cml1.bbclass and make it print a decent error message if it doesn’t work.

Ross
Khem Raj Oct. 12, 2022, 5:49 p.m. UTC | #2
On Wed, Oct 12, 2022 at 9:36 AM Ross Burton <ross.burton@arm.com> wrote:

> On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org
> <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> >
> > Move savedefconfig task to a class so we can reuse it in other recipes
> > which support it.
>
> There are three users of cml1 in oe-core: kernel, uboot, and busybox.
> Does busybox support savedefconfig?
>
> I’m thinking to avoid tiny classes we can just add this to cml1.bbclass
> and make it print a decent error message if it doesn’t work.
>

I agree I think it should be there for all kconfig users and they can strub
it in recipe if needed

>
> Ross
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#171669):
> https://lists.openembedded.org/g/openembedded-core/message/171669
> Mute This Topic: https://lists.openembedded.org/mt/94276340/1997914
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [
> raj.khem@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
>
Alex Kiernan Oct. 12, 2022, 7:43 p.m. UTC | #3
On Wed, Oct 12, 2022 at 5:36 PM Ross Burton <Ross.Burton@arm.com> wrote:
>
> On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> >
> > Move savedefconfig task to a class so we can reuse it in other recipes
> > which support it.
>
> There are three users of cml1 in oe-core: kernel, uboot, and busybox.  Does busybox support savedefconfig?
>

It doesn't and fairly obviously goes boom...

ERROR: busybox-1.35.0-r0 do_savedefconfig: oe_runmake failed
ERROR: busybox-1.35.0-r0 do_savedefconfig:
ExecutionError('/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/temp/run.do_savedefconfig.12421',
1, None, None)
ERROR: Logfile of failure stored in:
/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/temp/log.do_savedefconfig.12421
Log data follows:
| DEBUG: Executing shell function do_savedefconfig
| Saving defconfig to:
| /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0/defconfig
| NOTE: make CC=x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2
-msse3 -mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2
--sysroot=/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/recipe-sysroot
LD=x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3
-mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2
--sysroot=/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/recipe-sysroot
V=1 ARCH=x86_64 CROSS_COMPILE=x86_64-poky-linux- SKIP_STRIP=y
HOSTCC=gcc  HOSTCPP=gcc  -E -C
/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
savedefconfig
| make: Entering directory
'/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0'
| make -f scripts/Makefile.build obj=scripts/basic
| /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0/scripts/gen_build_files.sh
/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
| mkdir -p include
| make -f scripts/Makefile.build obj=scripts/kconfig savedefconfig
| make[1]: *** No rule to make target 'savedefconfig'.  Stop.
| make: *** [Makefile:444: savedefconfig] Error 2
| make: Leaving directory
'/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0'
| ERROR: oe_runmake failed

> I’m thinking to avoid tiny classes we can just add this to cml1.bbclass and make it print a decent error message if it doesn’t work.
>

So where I started, was adding it to u-boot.inc (which isn't a class,
I guess an artefact of history), because tiny classes felt like a poor
choice. I can add it to cml1 instead, at which point I've tried all
three options, maybe that's the best option and if you have a consumer
that doesn't do it, you just get a fail as above.

Are there are other users of cml1 other than these three? My suspicion
is there isn't (though I've only looked at layers I've got checked
out).
Ulrich Ölmann Oct. 13, 2022, 5:31 a.m. UTC | #4
On Wed, Oct 12 2022 at 20:43 +0100, "Alex Kiernan" <alex.kiernan@gmail.com> wrote:
> On Wed, Oct 12, 2022 at 5:36 PM Ross Burton <Ross.Burton@arm.com> wrote:
>>
>> On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
>> >
>> > Move savedefconfig task to a class so we can reuse it in other recipes
>> > which support it.
>>
>> There are three users of cml1 in oe-core: kernel, uboot, and busybox.  Does busybox support savedefconfig?
>>
>
> It doesn't and fairly obviously goes boom...
>
> ERROR: busybox-1.35.0-r0 do_savedefconfig: oe_runmake failed
> ERROR: busybox-1.35.0-r0 do_savedefconfig:
> ExecutionError('/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/temp/run.do_savedefconfig.12421',
> 1, None, None)
> ERROR: Logfile of failure stored in:
> /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/temp/log.do_savedefconfig.12421
> Log data follows:
> | DEBUG: Executing shell function do_savedefconfig
> | Saving defconfig to:
> | /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0/defconfig
> | NOTE: make CC=x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2
> -msse3 -mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2
> --sysroot=/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/recipe-sysroot
> LD=x86_64-poky-linux-gcc  -m64 -march=core2 -mtune=core2 -msse3
> -mfpmath=sse -fstack-protector-strong  -O2 -D_FORTIFY_SOURCE=2
> --sysroot=/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/recipe-sysroot
> V=1 ARCH=x86_64 CROSS_COMPILE=x86_64-poky-linux- SKIP_STRIP=y
> HOSTCC=gcc  HOSTCPP=gcc  -E -C
> /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
> savedefconfig
> | make: Entering directory
> '/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0'
> | make -f scripts/Makefile.build obj=scripts/basic
> | /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0/scripts/gen_build_files.sh
> /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
> /home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0
> | mkdir -p include
> | make -f scripts/Makefile.build obj=scripts/kconfig savedefconfig
> | make[1]: *** No rule to make target 'savedefconfig'.  Stop.
> | make: *** [Makefile:444: savedefconfig] Error 2
> | make: Leaving directory
> '/home/alexk/poky/build/tmp/work/core2-64-poky-linux/busybox/1.35.0-r0/busybox-1.35.0'
> | ERROR: oe_runmake failed
>
>> I’m thinking to avoid tiny classes we can just add this to
>> cml1.bbclass and make it print a decent error message if it doesn’t
>> work.
>>
>
> So where I started, was adding it to u-boot.inc (which isn't a class,
> I guess an artefact of history), because tiny classes felt like a poor
> choice. I can add it to cml1 instead, at which point I've tried all
> three options, maybe that's the best option and if you have a consumer
> that doesn't do it, you just get a fail as above.
>
> Are there are other users of cml1 other than these three? My suspicion
> is there isn't (though I've only looked at layers I've got checked
> out).

There is the barebox bootloader which supports 'savedefconfig', whose
recipe in meta-ptx uses cml1 via [2] and which would benefit from this
change.

Best regards
Ulrich


[1] https://barebox.org/
[2] https://github.com/pengutronix/meta-ptx/blob/master/recipes-bsp/barebox/barebox.inc#L12
Ross Burton Oct. 31, 2022, 10:12 p.m. UTC | #5
On 12 Oct 2022, at 20:43, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> 
> On Wed, Oct 12, 2022 at 5:36 PM Ross Burton <Ross.Burton@arm.com> wrote:
>> 
>> On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
>>> 
>>> Move savedefconfig task to a class so we can reuse it in other recipes
>>> which support it.
>> 
>> There are three users of cml1 in oe-core: kernel, uboot, and busybox.  Does busybox support savedefconfig?
>> 
> 
> It doesn't and fairly obviously goes boom…

If you really keen you could see if savedefconfig is a valid target somehow (search make -p for savedefconfig?), but to be honest given Ulrich’s reply I’m fine with the cml1 class supporting a function that most implementations, if not all, support.

It seems preferable to a class which is just "oe_runmake savedefconfig”, at least.

Ross
Richard Purdie Nov. 1, 2022, 11:32 a.m. UTC | #6
On Mon, 2022-10-31 at 22:12 +0000, Ross Burton wrote:
> On 12 Oct 2022, at 20:43, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> > 
> > On Wed, Oct 12, 2022 at 5:36 PM Ross Burton <Ross.Burton@arm.com> wrote:
> > > 
> > > On 12 Oct 2022, at 08:18, Alex Kiernan via lists.openembedded.org <alex.kiernan=gmail.com@lists.openembedded.org> wrote:
> > > > 
> > > > Move savedefconfig task to a class so we can reuse it in other recipes
> > > > which support it.
> > > 
> > > There are three users of cml1 in oe-core: kernel, uboot, and busybox.  Does busybox support savedefconfig?
> > > 
> > 
> > It doesn't and fairly obviously goes boom…
> 
> If you really keen you could see if savedefconfig is a valid target somehow (search make -p for savedefconfig?), but to be honest given Ulrich’s reply I’m fine with the cml1 class supporting a function that most implementations, if not all, support.
> 
> It seems preferable to a class which is just "oe_runmake savedefconfig”, at least.

The other "trick" that could work here is to put most of the definition
in the class but put the addtask in the recipe/inc file. That way most
is command and shared but only the valid users enable it with what is a
single line.

Cheers,

Richard
diff mbox series

Patch

diff --git a/meta/classes-recipe/cml1-savedefconfig.bbclass b/meta/classes-recipe/cml1-savedefconfig.bbclass
new file mode 100644
index 000000000000..c340aac11204
--- /dev/null
+++ b/meta/classes-recipe/cml1-savedefconfig.bbclass
@@ -0,0 +1,12 @@ 
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+do_savedefconfig() {
+	bbplain "Saving defconfig to:\n${B}/defconfig"
+	oe_runmake -C ${B} savedefconfig
+}
+do_savedefconfig[nostamp] = "1"
+addtask savedefconfig after do_configure
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index e4e69e076375..eae7b2f78a9e 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -634,14 +634,7 @@  kernel_do_configure() {
 	${KERNEL_CONFIG_COMMAND}
 }
 
-do_savedefconfig() {
-	bbplain "Saving defconfig to:\n${B}/defconfig"
-	oe_runmake -C ${B} savedefconfig
-}
-do_savedefconfig[nostamp] = "1"
-addtask savedefconfig after do_configure
-
-inherit cml1
+inherit cml1 cml1-savedefconfig
 
 # Need LD, HOSTLDFLAGS and more for config operations
 KCONFIG_CONFIG_COMMAND:append = " ${EXTRA_OEMAKE}"