diff options
| author | Frederic Martinsons <frederic.martinsons@gmail.com> | 2023-08-17 07:04:14 +0200 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-08-21 16:15:35 +0100 |
| commit | c318d1914e0b65e04b945f67651a56c2699eb969 (patch) | |
| tree | 92fe38929544e450843db35caad1687ba66de491 /meta | |
| parent | ed5702223b31d86eabe3b0616dc3e495a2a95b7b (diff) | |
| download | poky-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')
| -rw-r--r-- | meta/classes-recipe/cargo_c.bbclass | 41 |
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 | |||
| 12 | inherit cargo pkgconfig | ||
| 13 | |||
| 14 | # the binaries we will use | ||
| 15 | CARGO_C_BUILD = "cargo-cbuild" | ||
| 16 | CARGO_C_INSTALL = "cargo-cinstall" | ||
| 17 | |||
| 18 | # We need cargo-c to compile for the target | ||
| 19 | BASEDEPENDS:append = " cargo-c-native" | ||
| 20 | |||
| 21 | do_compile[progress] = "outof:\s+(\d+)/(\d+)" | ||
| 22 | cargo_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 | |||
| 31 | cargo_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 | |||
| 41 | EXPORT_FUNCTIONS do_compile do_install | ||
