]> 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>
Mon, 9 Feb 2026 15:25:12 +0000 (07:25 -0800)
committerDeepesh Varatharajan <Deepesh.Varatharajan@windriver.com>
Mon, 2 Mar 2026 08:48:59 +0000 (00:48 -0800)
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 [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..f9cee5e
--- /dev/null
@@ -0,0 +1,21 @@
+#
+# 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() {
+    features = (d.getVar('KERNEL_RUST_SUPPORT') or "").split()
+    if "True" not in features:
+        raise bb.parse.SkipRecipe(
+            "Skipping rust-out-of-tree-module: KERNEL_RUST_SUPPORT is not enabled"
+       )
+}