mirror of
git://git.yoctoproject.org/poky.git
synced 2025-08-22 00:42:05 +02:00

* PACKAGECONFIG_CONFARGS was added in: https://git.openembedded.org/openembedded-core/commit/?id=16745b20452de60ae2474433cc1a2fb1ed9f6a64 but it wasn't added in bbnote above which might lead to confusing errors like I got now: NOTE: cargo build -v --frozen --target aarch64-webos-linux-gnu --release --manifest-path=.../git//Cargo.toml error: unexpected argument '--cfg' found Usage: cargo build --verbose... --frozen --target [<TRIPLE>] --release --manifest-path <PATH> and was wondering where --cfg came from. * it was from recipe where we already use: RUSTFLAGS:append = " ${PACKAGECONFIG_CONFARGS}" it will be difficult to use PACKAGECONFIG for RUSTFLAGS and prevent them to be used here for cargo as well, what about the recipes which need them to explicitly append them to CARGO_BUILD_FLAGS ? (From OE-Core rev: 38d953b2ffd4e0cee9e77f97988e44be105023c6) Signed-off-by: Martin Jansa <martin.jansa@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
96 lines
2.7 KiB
Plaintext
96 lines
2.7 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"
|
|
|
|
RUSTFLAGS ??= ""
|
|
BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}"
|
|
# --frozen flag will prevent network access (which is required since only
|
|
# the do_fetch step is authorized to access network)
|
|
# and will require an up to date Cargo.lock file.
|
|
# This force the package being built to already ship a Cargo.lock, in the end
|
|
# this is what we want, at least, for reproducibility of the build.
|
|
CARGO_BUILD_FLAGS = "-v --frozen --target ${RUST_HOST_SYS} ${BUILD_MODE} --manifest-path=${CARGO_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} ${PACKAGECONFIG_CONFARGS} $@"
|
|
"${CARGO}" build ${CARGO_BUILD_FLAGS} ${PACKAGECONFIG_CONFARGS} "$@"
|
|
}
|
|
|
|
do_compile[progress] = "outof:\s+(\d+)/(\d+)"
|
|
cargo_do_compile () {
|
|
oe_cargo_build
|
|
}
|
|
|
|
cargo_do_install () {
|
|
local have_installed=false
|
|
for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do
|
|
case $tgt in
|
|
*.so|*.rlib)
|
|
if [ -n "${CARGO_INSTALL_LIBRARIES}" ]; then
|
|
install -d "${D}${rustlibdir}"
|
|
install -m755 "$tgt" "${D}${rustlibdir}"
|
|
have_installed=true
|
|
fi
|
|
;;
|
|
*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
|