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 <[email protected]> Signed-off-by: Hongxu Jia <[email protected]> --- meta/classes-recipe/cargo.bbclass | 8 ++++---- meta/conf/distro/include/debug-optimize.inc | 4 ++++ meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.9.0.bb | 4 ++-- meta/recipes-devtools/rust/libstd-rs_1.91.1.bb | 4 ++-- 4 files changed, 12 insertions(+), 8 deletions(-) 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.9.0.bb b/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.9.0.bb index 577acfdc86..9de4a07aeb 100644 --- a/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.9.0.bb +++ b/meta/recipes-devtools/rpm-sequoia/rpm-sequoia_1.9.0.bb @@ -27,7 +27,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: # @@ -59,7 +59,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.91.1.bb b/meta/recipes-devtools/rust/libstd-rs_1.91.1.bb index 8af93bec57..30875200e4 100644 --- a/meta/recipes-devtools/rust/libstd-rs_1.91.1.bb +++ b/meta/recipes-devtools/rust/libstd-rs_1.91.1.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" -- 2.34.1
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#228307): https://lists.openembedded.org/g/openembedded-core/message/228307 Mute This Topic: https://lists.openembedded.org/mt/116902152/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
