classes/cargo: fix indentation
PATCH 1/2 classes/cargo: fix indentation
Fix mismatching indentation.
--- meta/classes-recipe/cargo.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes-recipe/cargo.bbclass +1 -1
@@ -61,7 +61,7 @@ cargo_do_install () { for tgt in "${B}/target/${CARGO_TARGET_SUBDIR}/"*; do case $tgt in *.so|*.rlib) - if [ -n "${CARGO_INSTALL_LIBRARIES}" ]; then + if [ -n "${CARGO_INSTALL_LIBRARIES}" ]; then install -d "${D}${rustlibdir}" install -m755 "$tgt" "${D}${rustlibdir}" have_installed=true
Signature · 1 line
2.43.0
PATCH 2/2 classes/cargo: remove BUILD_MODE, replace with CARGO_PROFILE
The BUILD_MODE variable appears to be a way to select the Cargo build profile that is used, but it can't be assigned because it and other pieces of code base their logic on the value of DEBUG_BUILD.
Instead of a BUILD_MODE variable that is "--release" or "" depending on the value of DEBUG_BUILD, replace it with a clear CARGO_PROFILE variable that selects the profile to use. The default has the same behaviour as before:
either "release" or "dev" based on DEBUG_BUILD.
This profile is then passed to cargo, and used to construct paths in the build tree (with the caveat that the "dev" profile puts files in "debug").
[1] https://doc.rust-lang.org/cargo/reference/profiles.html
--- meta/classes-recipe/cargo.bbclass | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
meta/classes-recipe/cargo.bbclass +15 -5
@@ -31,18 +31,28 @@ B = "${WORKDIR}/build" export RUST_BACKTRACE = "1" RUSTFLAGS ??= "" -BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" + +# 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} ${BUILD_MODE} --manifest-path=${CARGO_MANIFEST_PATH}" +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)}" -# 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}"
Signature · 1 line
2.43.0