The cargo integration is split into two classes so that recipes can inherit cargo_common if they can't use cargo directly to build, for example when using meson+cargo or building rust itself.
However, a number of variables where in cargo.bbclass when they should really be in cargo_common.bbclass: move the assignments so that the cargo.bbclass simply inherits cargo_common, sets B, and implements the compile/install tasks. Signed-off-by: Ross Burton <[email protected]> --- meta/classes-recipe/cargo.bbclass | 27 ---------------------- meta/classes-recipe/cargo_common.bbclass | 29 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass index b34f3ce0cd7..31e655650cc 100644 --- a/meta/classes-recipe/cargo.bbclass +++ b/meta/classes-recipe/cargo.bbclass @@ -26,33 +26,6 @@ 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 ??= "" - -# The cargo profile to use. Defaults to release or dev based on DEBUG_BUILD, but -# can be set to any valid profile. -# https://doc.rust-lang.org/cargo/reference/profiles.html -CARGO_PROFILE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'dev', 'release', d)}" - -# --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} --profile=${CARGO_PROFILE} --manifest-path=${CARGO_MANIFEST_PATH}" - -# The build directory is named after the profile, apart from the dev profile -# which uses 'debug'. -def cargo_build_directory(d): - profile = d.getVar("CARGO_PROFILE") - return "debug" if profile == "dev" else profile -BUILD_DIR = "${@cargo_build_directory(d)}" - -CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}" - oe_cargo_build () { export RUSTFLAGS="${RUSTFLAGS}" bbnote "Using rust targets from ${RUST_TARGET_PATH}" diff --git a/meta/classes-recipe/cargo_common.bbclass b/meta/classes-recipe/cargo_common.bbclass index 95739122a59..0fb6844d932 100644 --- a/meta/classes-recipe/cargo_common.bbclass +++ b/meta/classes-recipe/cargo_common.bbclass @@ -17,6 +17,35 @@ # add crate fetch support inherit rust-common +# In case something fails in the build process, give a bit more feedback on +# where the issue occured +export RUST_BACKTRACE = "1" + +# Flags passed to all invocations of rustc +# https://doc.rust-lang.org/cargo/reference/config.html#buildrustflags +RUSTFLAGS ??= "" + +# The cargo profile to use. Defaults to release or dev based on DEBUG_BUILD, but +# can be set to any valid profile. +# https://doc.rust-lang.org/cargo/reference/profiles.html +CARGO_PROFILE ?= "${@oe.utils.vartrue('DEBUG_BUILD', 'dev', 'release', d)}" + +# --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} --profile=${CARGO_PROFILE} --manifest-path=${CARGO_MANIFEST_PATH}" + +# The build directory is named after the profile, apart from the dev profile +# which uses 'debug'. +def cargo_build_directory(d): + profile = d.getVar("CARGO_PROFILE") + return "debug" if profile == "dev" else profile +BUILD_DIR = "${@cargo_build_directory(d)}" + +CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${BUILD_DIR}" + # Where we download our registry and dependencies to export CARGO_HOME = "${UNPACKDIR}/cargo_home" -- 2.43.0
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#242783): https://lists.openembedded.org/g/openembedded-core/message/242783 Mute This Topic: https://lists.openembedded.org/mt/120596988/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
