diff mbox series

[v8,11/14] module-rust.bbclass: Prepare out-of-tree rust module compilation

Message ID 20260309174346.3384212-12-Harish.Sadineni@windriver.com
State Under Review
Headers show
Series Enable rust support for linux kernel | expand

Commit Message

Harish Sadineni March 9, 2026, 5:43 p.m. UTC
From: Harish Sadineni <Harish.Sadineni@windriver.com>

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>
---
 meta/classes-recipe/module-rust.bbclass | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 meta/classes-recipe/module-rust.bbclass
diff mbox series

Patch

diff --git a/meta/classes-recipe/module-rust.bbclass b/meta/classes-recipe/module-rust.bbclass
new file mode 100644
index 0000000000..1801e72196
--- /dev/null
+++ b/meta/classes-recipe/module-rust.bbclass
@@ -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.to_boolean(d.getVar('KERNEL_RUST_SUPPORT')):
+       raise bb.parse.SkipRecipe("Skipping rust-out-of-tree-module: KERNEL_RUST_SUPPORT is not enabled")
+}