From 37733062aab87ef051afb7f5257ae5b19b927c61 Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Tue, 5 Mar 2024 22:10:22 +0000 Subject: [PATCH] correctly handle dev, bench, test profiles From https://doc.rust-lang.org/cargo/guide/build-cache.html > For historical reasons, the dev and test profiles are stored in the > debug directory, and the release and bench profiles are stored in the > release directory. User-defined profiles are stored in a directory with > the same name as the profile. Fixes #167 Signed-off-by: Paul Osborne --- classes/cargo_bin.bbclass | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/classes/cargo_bin.bbclass b/classes/cargo_bin.bbclass index 04d9d9f..b280dda 100644 --- a/classes/cargo_bin.bbclass +++ b/classes/cargo_bin.bbclass @@ -33,7 +33,17 @@ CARGO_BUILD_PROFILE ?= "release" CARGO_INSTALL_DIR ?= "${D}${bindir}" -CARGO_BINDIR = "${B}/${RUST_TARGET}/${CARGO_BUILD_PROFILE}" +def cargo_profile_to_builddir(profile): + # See https://doc.rust-lang.org/cargo/guide/build-cache.html + # for the special cases mapped here. + return { + 'dev': 'debug', + 'test': 'debug', + 'release': 'release', + 'bench': 'release', + }.get(profile, profile) + +CARGO_BINDIR = "${B}/${RUST_TARGET}/${@cargo_profile_to_builddir(d.getVar('CARGO_BUILD_PROFILE'))}" WRAPPER_DIR = "${WORKDIR}/wrappers" # Set the Cargo manifest path to the typical location