From: Hongxu Jia Date: Mon, 22 Dec 2025 14:54:01 +0000 (+0800) Subject: debug-optimize.inc: override CARGO_BUILD_MODE and CARGO_BUILD_DIR for target X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad79d92c58c66270233caf0404114e532521d5ed;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git debug-optimize.inc: override CARGO_BUILD_MODE and CARGO_BUILD_DIR for target Rename BUILD_MODE and BUILD_DIR with CARGO prefix, then in debug-optimize.inc, override CARGO_BUILD_MODE and CARGO_BUILD_DIR for target when debug optimization is enabled (fragment core/yocto/debug-optimize) Suggested-by: Richard Purdie Signed-off-by: Hongxu Jia Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/classes-recipe/cargo.bbclass b/meta/classes-recipe/cargo.bbclass index 2dd28e95d3..eff28b323a 100644 --- a/meta/classes-recipe/cargo.bbclass +++ b/meta/classes-recipe/cargo.bbclass @@ -31,18 +31,18 @@ B = "${WORKDIR}/build" export RUST_BACKTRACE = "1" RUSTFLAGS ??= "" -BUILD_MODE = "${@['--release', ''][d.getVar('DEBUG_BUILD') == '1']}" +CARGO_BUILD_MODE ??= "--release" # --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} ${CARGO_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}" +CARGO_BUILD_DIR ??= "release" +CARGO_TARGET_SUBDIR = "${RUST_HOST_SYS}/${CARGO_BUILD_DIR}" oe_cargo_build () { export RUSTFLAGS="${RUSTFLAGS}" bbnote "Using rust targets from ${RUST_TARGET_PATH}" diff --git a/meta/conf/distro/include/debug-optimize.inc b/meta/conf/distro/include/debug-optimize.inc index 3f22aebbab..55f35dd7c6 100644 --- a/meta/conf/distro/include/debug-optimize.inc +++ b/meta/conf/distro/include/debug-optimize.inc @@ -43,3 +43,7 @@ CXXFLAGS:append:pn-vulkan-validation-layers = " -DXXH_NO_INLINE_HINTS=1" # For meson.bbclass MESON_BUILDTYPE:class-target ?= "debug" + +# For cargo.bbclass +CARGO_BUILD_MODE:class-target ?= "" +CARGO_BUILD_DIR:class-target ?= "debug" diff --git a/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.10.0.bb b/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.10.0.bb index a89ae4f2a6..4a954a00c5 100644 --- a/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.10.0.bb +++ b/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.10.0.bb @@ -26,7 +26,7 @@ CARGO_INSTALL_LIBRARIES = "1" do_compile:prepend () { # rpm-sequoia.pc is generated in the source directory # but the target directory does not exist there. - mkdir -p ${S}/target/${BUILD_DIR} + mkdir -p ${S}/target/${CARGO_BUILD_DIR} # From rpm-sequoia's README.md: # @@ -58,7 +58,7 @@ do_install:append () { # rpm-sequoia does not install its pkgconfig file. Do it manually. mkdir -p ${D}${libdir}/pkgconfig - install -m644 ${S}/target/${BUILD_DIR}/rpm-sequoia.pc ${D}${libdir}/pkgconfig + install -m644 ${S}/target/${CARGO_BUILD_DIR}/rpm-sequoia.pc ${D}${libdir}/pkgconfig } do_install_ptest:append () { diff --git a/meta/recipes-devtools/rust/libstd-rs_1.92.0.bb b/meta/recipes-devtools/rust/libstd-rs_1.92.0.bb index 8af93bec57..30875200e4 100644 --- a/meta/recipes-devtools/rust/libstd-rs_1.92.0.bb +++ b/meta/recipes-devtools/rust/libstd-rs_1.92.0.bb @@ -44,8 +44,8 @@ do_install () { # With the incremental build support added in 1.24, the libstd deps directory also includes dependency # files that get installed. Those are really only needed to incrementally rebuild the libstd library # itself and don't need to be installed. - rm -f ${B}/target/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/*.d - cp ${B}/target/${RUST_TARGET_SYS}/${BUILD_DIR}/deps/* ${D}${rustlibdir} + rm -f ${B}/target/${RUST_TARGET_SYS}/${CARGO_BUILD_DIR}/deps/*.d + cp ${B}/target/${RUST_TARGET_SYS}/${CARGO_BUILD_DIR}/deps/* ${D}${rustlibdir} } BBCLASSEXTEND = "nativesdk"