diff options
| -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 | ||
