public inbox for isar-users@googlegroups.com
 help / color / mirror / Atom feed
From: "chris.larson via isar-users" <isar-users@googlegroups.com>
To: isar-users@googlegroups.com
Cc: Cedric Hombourger <cedric.hombourger@siemens.com>,
	Christopher Larson <chris.larson@siemens.com>
Subject: [PATCH 1/4] per-kernel.bbclass: add class
Date: Fri, 11 Apr 2025 13:08:49 -0700	[thread overview]
Message-ID: <20250411200852.51967-2-chris.larson@siemens.com> (raw)
In-Reply-To: <20250411200852.51967-1-chris.larson@siemens.com>

From: Christopher Larson <chris.larson@siemens.com>

Add support for generation of per-kernel recipe variants. This aids in the
ability for a MACHINE to support multiple kernels, by allowing us to generate
per-kernel packages in recipes like external kernel modules.

A new variable KERNEL_NAMES will list the kernels for which variants will be
generated. For any kernels listed other than KERNEL_NAME, a variant of the
recipe will be produced, to generate a package or packages for that kernel.
In each variant, the KERNEL_NAME variable will be set to the kernel name for
which the variant is being built, and the `kernel-<kernel_name>` override
will be added, allowing for further metadata customization on a per-kernel
basis.

Signed-off-by: Christopher Larson <chris.larson@siemens.com>
---
 meta/classes/per-kernel.bbclass | 35 +++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 meta/classes/per-kernel.bbclass

diff --git a/meta/classes/per-kernel.bbclass b/meta/classes/per-kernel.bbclass
new file mode 100644
index 00000000..8abe117f
--- /dev/null
+++ b/meta/classes/per-kernel.bbclass
@@ -0,0 +1,35 @@
+# Generate per-kernel recipe variants
+#
+# Recipes which are specific to a specific kernel currently append KERNEL_NAME to the PN,
+# and depend on and target that specific kernel. For a machine which supports and builds
+# multiple kernel images, there is a need to generate a variant of the recipe for each
+# kernel image.
+# 
+# Each variant listed in KERNEL_NAMES will add `kernel-<kernel_name>` to the OVERRIDES variable, and
+# `per-kernel:<kernel_name>` to the BBCLASSEXTEND variable. In addition, KERNEL_NAME will be
+# set to the kernel name for the current variant.
+#
+# Copyright (c) Siemens AG, 2025
+# SPDX-License-Identifier: MIT
+
+OVERRIDES .= ":kernel-${KERNEL_NAME}"
+
+KERNEL_NAMES ?= "${KERNEL_NAME}"
+BBCLASSEXTEND += "${@' '.join(f'per-kernel:{kernel}' for kernel in d.getVar('KERNEL_NAMES').split() if kernel != d.getVar('KERNEL_NAME'))}"
+
+python per_kernel_virtclass_handler() {
+    orig_pn = d.getVar('PN')
+
+    d = e.data
+    extend = d.getVar('BBEXTENDCURR') or ''
+    variant = d.getVar('BBEXTENDVARIANT') or ''
+    if extend != 'per-kernel':
+        return
+    elif variant == '':
+        d.appendVar('PROVIDES', f' {orig_pn}')
+        return
+
+    d.setVar('KERNEL_NAME', variant)
+}
+addhandler per_kernel_virtclass_handler
+per_kernel_virtclass_handler[eventmask] = "bb.event.RecipePreFinalise"
-- 
2.47.2

-- 
You received this message because you are subscribed to the Google Groups "isar-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to isar-users+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/isar-users/20250411200852.51967-2-chris.larson%40siemens.com.

  reply	other threads:[~2025-04-11 20:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-11 20:08 [PATCHv2 0/4] Add support for per-kernel recipe variants chris.larson via isar-users
2025-04-11 20:08 ` chris.larson via isar-users [this message]
2025-04-11 20:08 ` [PATCH 2/4] linux-module: inherit per-kernel chris.larson via isar-users
2025-04-11 20:08 ` [PATCH 3/4] testsuite: add 'extra_lines' argument to configure chris.larson via isar-users
2025-04-11 20:08 ` [PATCH 4/4] testsuite: add a test for per_kernel support chris.larson via isar-users
2025-04-11 20:10 ` [PATCHv2 0/4] Add support for per-kernel recipe variants 'Larson, Chris' via isar-users

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250411200852.51967-2-chris.larson@siemens.com \
    --to=isar-users@googlegroups.com \
    --cc=cedric.hombourger@siemens.com \
    --cc=chris.larson@siemens.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox