diff options
| author | Randy MacLeod <Randy.MacLeod@windriver.com> | 2021-08-10 13:52:19 -0400 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-08-26 22:09:43 +0100 |
| commit | 61e1570c6a09c1984e919e8c0a82a74c1a08d821 (patch) | |
| tree | accab4b08aa3c62f098c9bb19399efb46906256a /meta/classes/cargo.bbclass | |
| parent | 705b1d757fa221614f4f72cabf0fac5884cb6bfd (diff) | |
| download | poky-61e1570c6a09c1984e919e8c0a82a74c1a08d821.tar.gz | |
rust: initial merge of most of meta-rust
In the meta-rust repo at commit:
448047c Upgrade to 1.54.0 (#359)
Make the required directories:
mkdir ../oe-core/meta/recipes-devtools/rust
mkdir ../oe-core/meta/recipes-devtools/cargo
mkdir ../oe-core/meta/recipes-example
and then:
cp recipes-devtools/rust/* ../oe-core/meta/recipes-devtools/rust
cp recipes-devtools/cargo/* ../oe-core/meta/recipes-devtools/cargo
cp lib/crate.py ../oe-core/meta/lib
cp recipes-example/* ../oe-core/meta/recipes-example
cp conf/distro/include/rust_* ../oe-core/meta/conf/distro/include/
cp classes/* ../oe-core/meta/classes/
cp recipes-core/packagegroups/packagegroup-rust-cross-canadian.bb ../oe-core/meta/recipes-core/packagegroups
(From OE-Core rev: 3ed57578cca93ff1ba4e0bf3f25566e10659a2f9)
Signed-off-by: Randy MacLeod <Randy.MacLeod@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/cargo.bbclass')
| -rw-r--r-- | meta/classes/cargo.bbclass | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/meta/classes/cargo.bbclass b/meta/classes/cargo.bbclass new file mode 100644 index 0000000000..0ca38143c0 --- /dev/null +++ b/meta/classes/cargo.bbclass | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | ## | ||
| 2 | ## Purpose: | ||
| 3 | ## This class is used by any recipes that are built using | ||
| 4 | ## Cargo. | ||
| 5 | |||
| 6 | inherit cargo_common | ||
| 7 | |||
| 8 | # the binary we will use | ||
| 9 | CARGO = "cargo" | ||
| 10 | |||
| 11 | # We need cargo to compile for the target | ||
| 12 | BASEDEPENDS:append = " cargo-native" | ||
| 13 | |||
| 14 | # Ensure we get the right rust variant | ||
| 15 | DEPENDS:append:class-target = " virtual/${TARGET_PREFIX}rust ${RUSTLIB_DEP}" | ||
| 16 | DEPENDS:append:class-native = " rust-native" | ||
| 17 | |||
| 18 | # Enable build separation | ||
| 19 | B = "${WORKDIR}/build" | ||
| 20 | |||
| 21 | # In case something fails in the build process, give a bit more feedback on | ||
| 22 | # where the issue occured | ||
| 23 | export RUST_BACKTRACE = "1" | ||
| 24 | |||
| 25 | # The directory of the Cargo.toml relative to the root directory, per default | ||
| 26 | # assume there's a Cargo.toml directly in the root directory | ||
| 27 | CARGO_SRC_DIR ??= "" | ||
| 28 | |||
| 29 | # The actual path to the Cargo.toml | ||
| 30 | MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml" | ||
| 31 | |||
| 32 | RUSTFLAGS ??= "" | ||
| 33 | BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" | ||
| 34 | CARGO_BUILD_FLAGS = "-v --target ${HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}" | ||
| 35 | |||
| 36 | # This is based on the content of CARGO_BUILD_FLAGS and generally will need to | ||
| 37 | # change if CARGO_BUILD_FLAGS changes. | ||
| 38 | BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}" | ||
| 39 | CARGO_TARGET_SUBDIR="${HOST_SYS}/${BUILD_DIR}" | ||
| 40 | oe_cargo_build () { | ||
| 41 | export RUSTFLAGS="${RUSTFLAGS}" | ||
| 42 | export RUST_TARGET_PATH="${RUST_TARGET_PATH}" | ||
| 43 | bbnote "cargo = $(which ${CARGO})" | ||
| 44 | bbnote "rustc = $(which ${RUSTC})" | ||
| 45 | bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@" | ||
| 46 | "${CARGO}" build ${CARGO_BUILD_FLAGS} "$@" | ||
| 47 | } | ||
| 48 | |||
| 49 | do_compile[progress] = "outof:\s+(\d+)/(\d+)" | ||
| 50 | cargo_do_compile () { | ||
| 51 | oe_cargo_fix_env | ||
| 52 | oe_cargo_build | ||
| 53 | } | ||
| 54 | |||
| 55 | cargo_do_install () { | ||
| 56 | local have_installed=false | ||
| 57 | for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do | ||
| 58 | case $tgt in | ||
| 59 | *.so|*.rlib) | ||
| 60 | install -d "${D}${rustlibdir}" | ||
| 61 | install -m755 "$tgt" "${D}${rustlibdir}" | ||
| 62 | have_installed=true | ||
| 63 | ;; | ||
| 64 | *examples) | ||
| 65 | if [ -d "$tgt" ]; then | ||
| 66 | for example in "$tgt/"*; do | ||
| 67 | if [ -f "$example" ] && [ -x "$example" ]; then | ||
| 68 | install -d "${D}${bindir}" | ||
| 69 | install -m755 "$example" "${D}${bindir}" | ||
| 70 | have_installed=true | ||
| 71 | fi | ||
| 72 | done | ||
| 73 | fi | ||
| 74 | ;; | ||
| 75 | *) | ||
| 76 | if [ -f "$tgt" ] && [ -x "$tgt" ]; then | ||
| 77 | install -d "${D}${bindir}" | ||
| 78 | install -m755 "$tgt" "${D}${bindir}" | ||
| 79 | have_installed=true | ||
| 80 | fi | ||
| 81 | ;; | ||
| 82 | esac | ||
| 83 | done | ||
| 84 | if ! $have_installed; then | ||
| 85 | die "Did not find anything to install" | ||
| 86 | fi | ||
| 87 | } | ||
| 88 | |||
| 89 | EXPORT_FUNCTIONS do_compile do_install | ||
