]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
module-rust.bbclass: Prepare out-of-tree rust module compilation
authorHarish Sadineni <Harish.Sadineni@windriver.com>
Fri, 13 Mar 2026 15:59:17 +0000 (08:59 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 16 Mar 2026 10:16:08 +0000 (10:16 +0000)
Add support for rust-out-of-tree module compilation:
- Add dependency to rust-native
- Remap ${S} in compiled output to avoid buildpath errors
- Added check to skip rust out-of-ree-module compilation,
  if rust kernel support is not enabled

Co-developed-by:Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/classes-recipe/module-rust.bbclass [new file with mode: 0644]

diff --git a/meta/classes-recipe/module-rust.bbclass b/meta/classes-recipe/module-rust.bbclass
new file mode 100644 (file)
index 0000000..a043361
--- /dev/null
@@ -0,0 +1,18 @@
+#
+# Copyright OpenEmbedded Contributors
+#
+# SPDX-License-Identifier: MIT
+#
+
+inherit module
+
+DEPENDS += " rust-native"
+
+RUST_DEBUG_REMAP = "--remap-path-prefix=${S}=${TARGET_DBGSRC_DIR} "
+KRUSTFLAGS = " ${RUST_DEBUG_REMAP}"
+EXTRA_OEMAKE:append = " KRUSTFLAGS='${KRUSTFLAGS}'"
+
+python __anonymous() {
+    if not bb.utils.contains('KERNEL_FEATURES', 'rust', True, False, d):
+       raise bb.parse.SkipRecipe("Skipping rust-out-of-tree-module: 'rust' is not enabled in KERNEL_FEATURES")
+}