diff mbox series

[17/29] cargo_common: Handle build SYS as well as HOST/TARGET

Message ID 20220805131252.3706794-17-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 0dc9635c28c269f782ad4ed6ea06b4e4de1beb8e
Headers show
Series [01/29] nativesdk: Clear TUNE_FEATURES | expand

Commit Message

Richard Purdie Aug. 5, 2022, 1:12 p.m. UTC
Improve the common class to handle BUILD_SYS as well as host and target,
removing the need to a workaround in the rust recipe.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes/cargo_common.bbclass   | 9 +++++++++
 meta/recipes-devtools/rust/rust.inc | 3 ---
 2 files changed, 9 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes/cargo_common.bbclass b/meta/classes/cargo_common.bbclass
index dcd0afd9801..4a419cdd0a3 100644
--- a/meta/classes/cargo_common.bbclass
+++ b/meta/classes/cargo_common.bbclass
@@ -82,6 +82,15 @@  cargo_common_do_configure () {
 		EOF
 	fi
 
+	if [ "${RUST_TARGET_SYS}" != "${RUST_BUILD_SYS}" -a "${RUST_TARGET_SYS}" != "${RUST_HOST_SYS}"]; then
+		cat <<- EOF >> ${CARGO_HOME}/config
+
+		# TARGET_SYS
+		[target.${RUST_TARGET_SYS}]
+		linker = "${RUST_TARGET_CCLD}"
+		EOF
+	fi
+
 	# Put build output in build directory preferred by bitbake instead of
 	# inside source directory unless they are the same
 	if [ "${B}" != "${S}" ]; then
diff --git a/meta/recipes-devtools/rust/rust.inc b/meta/recipes-devtools/rust/rust.inc
index 5730887411a..12c86e02c4a 100644
--- a/meta/recipes-devtools/rust/rust.inc
+++ b/meta/recipes-devtools/rust/rust.inc
@@ -29,9 +29,6 @@  setup_cargo_environment () {
     # x86_64-unknown-linux-gnu.
     # Later stages are build for the native target (i.e. target.x86_64-linux)
     cargo_common_do_configure
-
-    printf '[target.%s]\n' "${RUST_BUILD_SYS}" >> ${CARGO_HOME}/config
-    printf "linker = '%s'\n" "${RUST_BUILD_CCLD}" >> ${CARGO_HOME}/config
 }
 
 inherit rust-target-config