@@ -22,32 +22,34 @@ RUST_BUILD = "${@rust_target(d, 'BUILD')}"
2222
2323# Additional flags passed directly to the "cargo build" invocation
2424EXTRA_CARGO_FLAGS ??= ""
25- EXTRA_RUSTFLAGS ??= ""
26- RUSTFLAGS += "${EXTRA_RUSTFLAGS} "
25+
26+ # Optional RUSTFLAGS
27+ RUSTFLAGS ??= ""
2728
2829# Space-separated list of features to enable
2930CARGO_FEATURES ??= ""
3031
3132# Control the Cargo build type (debug or release)
32- CARGO_BUILD_TYPE ? = "--release"
33+ BUILD_MODE = "${ @ [ ' --release' , '' ][ d . getVar ( 'DEBUG_BUILD' ) == '1' ]} "
3334
3435CARGO_INSTALL_DIR ?= "${D}${bindir} "
3536
36- CARGO_DEBUG_DIR = "${B} /${RUST_TARGET} /debug"
37- CARGO_RELEASE_DIR = "${B} /${RUST_TARGET} /release"
37+ # This is based on the content of CARGO_BUILD_FLAGS and generally will need to
38+ # change if CARGO_BUILD_FLAGS changes.
39+ BUILD_DIR = "${@ ['release' , 'debug' ][d . getVar ('DEBUG_BUILD' ) == '1' ]}"
40+ CARGO_TARGET_SUBDIR = "${RUST_TARGET} /${BUILD_DIR} "
41+
3842WRAPPER_DIR = "${WORKDIR} /wrappers"
3943
4044# Set the Cargo manifest path to the typical location
4145CARGO_MANIFEST_PATH ?= "${S} /Cargo.toml"
4246
43- FILES :${PN} -dev += "${libdir} /*.rlib"
44-
4547CARGO_BUILD_FLAGS = "\
4648 --offline \
4749 --verbose \
4850 --manifest-path ${CARGO_MANIFEST_PATH} \
4951 --target=${RUST_TARGET} \
50- ${CARGO_BUILD_TYPE } \
52+ ${BUILD_MODE } \
5153 ${@ oe . utils . conditional ('CARGO_FEATURES' , '' , '' , '--features "${CARGO_FEATURES} "' , d )} \
5254 ${EXTRA_CARGO_FLAGS} \
5355"
@@ -108,7 +110,6 @@ cargo_bin_do_compile() {
108110 export CARGO_TARGET_APPLIES_TO_HOST = "false"
109111 export CARGO_TARGET_ ${@ rust_target (d , 'TARGET' ). replace ('-' , '_' ). upper ()}_LINKER = "${WRAPPER_DIR} /linker-wrapper.sh"
110112 export CARGO_HOST_LINKER = "${WRAPPER_DIR} /linker-native-wrapper.sh"
111- export CARGO_BUILD_FLAGS = "-C rpath"
112113 export CARGO_PROFILE_RELEASE_DEBUG = "true"
113114
114115 # The CC crate defaults to using CFLAGS when compiling everything. We can
@@ -125,15 +126,9 @@ cargo_bin_do_compile() {
125126}
126127
127128cargo_bin_do_install () {
128- if [ "${CARGO_BUILD_TYPE} " = "--release" ]; then
129- local cargo_bindir = "${CARGO_RELEASE_DIR} "
130- else
131- local cargo_bindir = "${CARGO_DEBUG_DIR} "
132- fi
133-
134- local files_installed = ""
129+ local files_installed = ""
135130
136- for tgt in "${cargo_bindir } " /*; do
131+ for tgt in "${B} / ${RUST_TARGET} / ${CARGO_TARGET_SUBDIR } " /*; do
137132 case $tgt in
138133 *. so |*. rlib )
139134 install -d "${D}${libdir} "
0 commit comments