@@ -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}"
@@ -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"
@@ -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 () {
@@ -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"
Rename BUILD_MODE and BUILD_DIR with CARGO prefix, then in debug_build.inc, override CARGO_BUILD_MODE and CARGO_BUILD_DIR for target when debug build is enabled (fragment core/yocto/debug-build) Suggested-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> --- meta/classes-recipe/cargo.bbclass | 8 ++++---- meta/conf/distro/include/debug_build.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(-)