mirror of
https://git.yoctoproject.org/poky
synced 2026-02-12 03:33:02 +01:00
* RUSTC is normally defined in rust.bbclass, but rust-target-config doesn't inherit rust.bbclass and RUSTC is then undefined when calling 'which' in oe_cargo_build * causes which help text ending in log.do_compile, e.g.: | DEBUG: Executing shell function do_compile | NOTE: Using rust targets from /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/rust-targets/ | NOTE: cargo = /OE/build/oe-core/tmp-glibc/work/core2-64-oe-linux/openssl-sys/0.9.77-r0/recipe-sysroot-native/usr/bin/cargo | Usage: which [options] [--] COMMAND [...] | Write the full path of COMMAND(s) to standard output. | | --version, -[vV] Print version and exit successfully. | --help, Print this help and exit successfully. | --skip-dot Skip directories in PATH that start with a dot. | --skip-tilde Skip directories in PATH that start with a tilde. | --show-dot Don't expand a dot to current directory in output. | --show-tilde Output a tilde for HOME directory for non-root. | --tty-only Stop processing options on the right if not on tty. | --all, -a Print all matches in PATH, not just the first | --read-alias, -i Read list of aliases from stdin. | --skip-alias Ignore option --read-alias; don't read stdin. | --read-functions Read shell functions from stdin. | --skip-functions Ignore option --read-functions; don't read stdin. | | Recommended use is to write the output of (alias; declare -f) to standard | input, so that which can show aliases and shell functions. See which(1) for | examples. | | If the options --read-alias and/or --read-functions are specified then the | output can be a full alias or function definition, optionally followed by | the full path of each command used inside of those. | | Report bugs to <which-bugs@gnu.org>. | NOTE: rustc = (From OE-Core rev: 0068e82f02354729b953e622889f96ca52468d6c) Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
97 lines
2.5 KiB
Plaintext
97 lines
2.5 KiB
Plaintext
#
|
|
# Copyright OpenEmbedded Contributors
|
|
#
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
|
|
##
|
|
## Purpose:
|
|
## This class is used by any recipes that are built using
|
|
## Cargo.
|
|
|
|
inherit cargo_common
|
|
inherit rust-target-config
|
|
|
|
# the binary we will use
|
|
CARGO = "cargo"
|
|
|
|
# We need cargo to compile for the target
|
|
BASEDEPENDS:append = " cargo-native"
|
|
|
|
# Ensure we get the right rust variant
|
|
DEPENDS:append:class-target = " rust-native ${RUSTLIB_DEP}"
|
|
DEPENDS:append:class-nativesdk = " rust-native ${RUSTLIB_DEP}"
|
|
DEPENDS:append:class-native = " rust-native"
|
|
|
|
# Enable build separation
|
|
B = "${WORKDIR}/build"
|
|
|
|
# In case something fails in the build process, give a bit more feedback on
|
|
# where the issue occured
|
|
export RUST_BACKTRACE = "1"
|
|
|
|
# The directory of the Cargo.toml relative to the root directory, per default
|
|
# assume there's a Cargo.toml directly in the root directory
|
|
CARGO_SRC_DIR ??= ""
|
|
|
|
# The actual path to the Cargo.toml
|
|
MANIFEST_PATH ??= "${S}/${CARGO_SRC_DIR}/Cargo.toml"
|
|
|
|
RUSTFLAGS ??= ""
|
|
BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
|
|
CARGO_BUILD_FLAGS = "-v --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${MANIFEST_PATH}"
|
|
|
|
# This is based on the content of CARGO_BUILD_FLAGS and generally will need to
|
|
# change if CARGO_BUILD_FLAGS changes.
|
|
BUILD_DIR = "${@['release', 'debug'][d.getVar('DEBUG_BUILD') == '1']}"
|
|
CARGO_TARGET_SUBDIR="${RUST_HOST_SYS}/${BUILD_DIR}"
|
|
oe_cargo_build () {
|
|
export RUSTFLAGS="${RUSTFLAGS}"
|
|
bbnote "Using rust targets from ${RUST_TARGET_PATH}"
|
|
bbnote "cargo = $(which ${CARGO})"
|
|
bbnote "${CARGO} build ${CARGO_BUILD_FLAGS} $@"
|
|
"${CARGO}" build ${CARGO_BUILD_FLAGS} "$@"
|
|
}
|
|
|
|
do_compile[progress] = "outof:\s+(\d+)/(\d+)"
|
|
cargo_do_compile () {
|
|
oe_cargo_fix_env
|
|
oe_cargo_build
|
|
}
|
|
|
|
cargo_do_install () {
|
|
local have_installed=false
|
|
for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do
|
|
case $tgt in
|
|
*.so|*.rlib)
|
|
install -d "${D}${rustlibdir}"
|
|
install -m755 "$tgt" "${D}${rustlibdir}"
|
|
have_installed=true
|
|
;;
|
|
*examples)
|
|
if [ -d "$tgt" ]; then
|
|
for example in "$tgt/"*; do
|
|
if [ -f "$example" ] && [ -x "$example" ]; then
|
|
install -d "${D}${bindir}"
|
|
install -m755 "$example" "${D}${bindir}"
|
|
have_installed=true
|
|
fi
|
|
done
|
|
fi
|
|
;;
|
|
*)
|
|
if [ -f "$tgt" ] && [ -x "$tgt" ]; then
|
|
install -d "${D}${bindir}"
|
|
install -m755 "$tgt" "${D}${bindir}"
|
|
have_installed=true
|
|
fi
|
|
;;
|
|
esac
|
|
done
|
|
if ! $have_installed; then
|
|
die "Did not find anything to install"
|
|
fi
|
|
}
|
|
|
|
EXPORT_FUNCTIONS do_compile do_install
|