* [PATCH] kernel_dep_check.bbclass: help track kernel depend
@ 2022-11-15 23:44 jebr
2022-11-22 12:45 ` [OE-core] " Richard Purdie
0 siblings, 1 reply; 2+ messages in thread
From: jebr @ 2022-11-15 23:44 UTC (permalink / raw)
To: openembedded-core; +Cc: brandonkim, edtanous, John Edward Broadbent
From: John Edward Broadbent <jebr@google.com>
This recipe can be used to identify kernel dependencies, and
immediately throw build errors if those dependencies are not met.
Signed-off-by: John Edward Broadbent <jebr@google.com>
---
meta/classes-global/kernel_dep_check.bbclass | 81 ++++++++++++++++++++
1 file changed, 81 insertions(+)
create mode 100644 meta/classes-global/kernel_dep_check.bbclass
diff --git a/meta/classes-global/kernel_dep_check.bbclass b/meta/classes-global/kernel_dep_check.bbclass
new file mode 100644
index 0000000000..25bef1533c
--- /dev/null
+++ b/meta/classes-global/kernel_dep_check.bbclass
@@ -0,0 +1,81 @@
+# This class is meant to help in tracking recipe's dependencies
+# on certain Linux Kernel's compile time options, by making them
+# explicit.
+#
+# Usage.
+# 1. Inherit this class.
+# 2. If the Linux Kernel MUST have certain compile time options
+# enabled, add them to KERNEL_OPTIONS_REQUIRED variable.
+# Multiple options can be added, separated by whitespace.
+# If the kernel built with the image does not have these
+# options enabled, the build will fail.
+# 3. If some options are simply recommended, but not mandatory,
+# they can be added to KERNEL_OPTIONS_RECOMMENDED variable.
+# If the kernel built with the image does not have these
+# options enabled, warning will be produced, but the build
+# will succeed.
+# 4. If some options has alternatives, i.e. if only one of the
+# options has to be enabled to pass the check, separate
+# the alternatives with '|' with no spaces, like so:
+# DECOMPRESS_GZIP|DECOMPRESS_BZIP2
+
+
+KERNEL_OPTIONS_REQUIRED ??= ""
+KERNEL_OPTIONS_RECOMMENDED ??= ""
+
+def report_opt_warn(pn, opt):
+ if len(opt_alt_list) > 1:
+ bb.warn("%s recommends one of the following Linux Kernel"
+ " options to be enabled: %s"
+ % (pn, ",".join(opt_alt_list)))
+ else:
+ bb.warn("%s recommends Linux Kernel option %s to be enabled"
+ % (pn, opt_alt_list[0]))
+
+
+def report_opt_fatal(pn, opt_alt_list):
+ if len(opt_alt_list) > 1:
+ bb.fatal("%s requires one of the following Linux Kernel"
+ " options to be enabled: %s"
+ % (pn, ",".join(opt_alt_list)))
+ else:
+ bb.fatal("%s requires Linux Kernel option %s to be enabled"
+ % (pn, opt_alt_list[0]))
+
+
+def check_kernel_option(pn, opt_expr, opt_map, report_f):
+ alt_list = opt_expr.split("|")
+ alt_list_full = []
+ for opt in alt_list:
+ if not opt.startswith("CONFIG_"):
+ alt_list_full.append("CONFIG_" + opt)
+ else:
+ alt_list_full.append(opt)
+
+ if not any(opt_map.get(o) == "y" for o in alt_list_full):
+ report_f(pn, alt_list_full)
+
+
+python do_package:qa:append () {
+ kconfig_path = os.path.join(d.getVar("STAGING_KERNEL_BUILDDIR"), ".config")
+
+ kconfig_map = dict()
+ with open(kconfig_path, "r") as kconfig:
+ for line in kconfig:
+ if not line.startswith("CONFIG"):
+ continue
+
+ cfg_chunks = line.strip().split("=")
+ kconfig_map[cfg_chunks[0]] = cfg_chunks[1]
+
+ pn = d.getVar("PN")
+ for opt in d.getVar("KERNEL_OPTIONS_REQUIRED", "").split():
+ check_kernel_option(pn, opt, kconfig_map, report_opt_fatal)
+
+ for opt in d.getVar("KERNEL_OPTIONS_RECOMMENDED", "").split():
+ check_kernel_option(pn, opt, kconfig_map, report_opt_warn)
+}
+
+# do_shared_workdir moves kernel's .config to STAGING_KERNEL_BUILDDIR,
+# so it must complete before we can run the qa checks above.
+do_package:qa[depends] = "virtual/kernel:do_shared_workdir"
--
2.38.1.431.g37b22c650d-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [OE-core] [PATCH] kernel_dep_check.bbclass: help track kernel depend
2022-11-15 23:44 [PATCH] kernel_dep_check.bbclass: help track kernel depend jebr
@ 2022-11-22 12:45 ` Richard Purdie
0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2022-11-22 12:45 UTC (permalink / raw)
To: jebr, openembedded-core; +Cc: brandonkim, edtanous
On Tue, 2022-11-15 at 15:44 -0800, John Broadbent via
lists.openembedded.org wrote:
> From: John Edward Broadbent <jebr@google.com>
>
> This recipe can be used to identify kernel dependencies, and
> immediately throw build errors if those dependencies are not met.
>
> Signed-off-by: John Edward Broadbent <jebr@google.com>
> ---
> meta/classes-global/kernel_dep_check.bbclass | 81 ++++++++++++++++++++
> 1 file changed, 81 insertions(+)
> create mode 100644 meta/classes-global/kernel_dep_check.bbclass
>
> diff --git a/meta/classes-global/kernel_dep_check.bbclass b/meta/classes-global/kernel_dep_check.bbclass
I was a little puzzled by the way you'd expect this class to be used.
It is placed in class-global and hence you must be using it as an
INHERIT but I'd have expected it to only be used by recipes that need
it on a per recipe basis?
Cheers,
Richard
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-22 12:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-15 23:44 [PATCH] kernel_dep_check.bbclass: help track kernel depend jebr
2022-11-22 12:45 ` [OE-core] " Richard Purdie
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.