summaryrefslogtreecommitdiffstats
path: root/meta/classes-recipe/cargo_c.bbclass
diff options
context:
space:
mode:
authorFrederic Martinsons <frederic.martinsons@gmail.com>2023-08-17 07:04:14 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-08-21 16:15:35 +0100
commitc318d1914e0b65e04b945f67651a56c2699eb969 (patch)
tree92fe38929544e450843db35caad1687ba66de491 /meta/classes-recipe/cargo_c.bbclass
parented5702223b31d86eabe3b0616dc3e495a2a95b7b (diff)
downloadpoky-c318d1914e0b65e04b945f67651a56c2699eb969.tar.gz
classes-recipe: add cargo_c.bbclass
This class can be used inside rust recipe to generate a rust library that can be called by C/C++ code. The rust recipe which uses this class has to only replace "inherit cargo" by "inherit cargo_c". (From OE-Core rev: 1e4862db1d6293872b76b62acee1e4a5e2597367) Signed-off-by: Frederic Martinsons <frederic.martinsons@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes-recipe/cargo_c.bbclass')
-rw-r--r--meta/classes-recipe/cargo_c.bbclass41
1 files changed, 41 insertions, 0 deletions
diff --git a/meta/classes-recipe/cargo_c.bbclass b/meta/classes-recipe/cargo_c.bbclass
new file mode 100644
index 0000000000..ef431634a2
--- /dev/null
+++ b/meta/classes-recipe/cargo_c.bbclass
@@ -0,0 +1,41 @@
1#
2# Copyright OpenEmbedded Contributors
3#
4# SPDX-License-Identifier: MIT
5#
6
7##
8## Purpose:
9## This class is used by any recipes that want to compile a C ABI compatible
10## library with header and pkg config file
11
12inherit cargo pkgconfig
13
14# the binaries we will use
15CARGO_C_BUILD = "cargo-cbuild"
16CARGO_C_INSTALL = "cargo-cinstall"
17
18# We need cargo-c to compile for the target
19BASEDEPENDS:append = " cargo-c-native"
20
21do_compile[progress] = "outof:\s+(\d+)/(\d+)"
22cargo_c_do_compile() {
23 oe_cargo_fix_env
24 export RUSTFLAGS="${RUSTFLAGS}"
25 bbnote "Using rust targets from ${RUST_TARGET_PATH}"
26 bbnote "cargo-cbuild = $(which ${CARGO_C_BUILD})"
27 bbnote "${CARGO_C_BUILD} cbuild ${CARGO_BUILD_FLAGS}"
28 "${CARGO_C_BUILD}" cbuild ${CARGO_BUILD_FLAGS}
29}
30
31cargo_c_do_install() {
32 oe_cargo_fix_env
33 export RUSTFLAGS="${RUSTFLAGS}"
34 bbnote "cargo-cinstall = $(which ${CARGO_C_INSTALL})"
35 "${CARGO_C_INSTALL}" cinstall ${CARGO_BUILD_FLAGS} \
36 --destdir ${D} \
37 --prefix ${prefix} \
38 --library-type cdylib
39}
40
41EXPORT_FUNCTIONS do_compile do_install