blob: ef431634a2d3c415f4e5bd6c8602e72e75e09408 [file] [log] [blame]
Andrew Geissler5082cc72023-09-11 08:41:39 -04001#
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