diff mbox series

[4/6] toolchain-scripts: export the target endianism and word size

Message ID 20240520101833.1798907-4-ross.burton@arm.com
State Accepted, archived
Commit c2fee816cae6dbedcb40f15be4a1b9ee91757a64
Headers show
Series [1/6] oeqa/sdk: rename test cases | expand

Commit Message

Ross Burton May 20, 2024, 10:18 a.m. UTC
Some build systems (notably, Meson) like to be told when cross-compiling
what the target endian and word size is.  We don't have these exported
via the variables, so add them using siteinfo as a source of data.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 meta/classes-recipe/toolchain-scripts.bbclass | 9 +++++++++
 1 file changed, 9 insertions(+)
diff mbox series

Patch

diff --git a/meta/classes-recipe/toolchain-scripts.bbclass b/meta/classes-recipe/toolchain-scripts.bbclass
index 6bfe0b6de0d..cbef412e796 100644
--- a/meta/classes-recipe/toolchain-scripts.bbclass
+++ b/meta/classes-recipe/toolchain-scripts.bbclass
@@ -16,6 +16,13 @@  DEBUG_PREFIX_MAP = ""
 
 EXPORT_SDK_PS1 = "${@ 'export PS1=\\"%s\\"' % d.getVar('SDK_PS1') if d.getVar('SDK_PS1') else ''}"
 
+def siteinfo_with_prefix(d, prefix):
+    # Return a prefixed value from siteinfo
+    for item in siteinfo_data_for_machine(d.getVar("TARGET_ARCH"), d.getVar("TARGET_OS"), d):
+        if item.startswith(prefix):
+            return item.replace(prefix, "")
+    raise KeyError
+
 # This function creates an environment-setup-script for use in a deployable SDK
 toolchain_create_sdk_env_script () {
 	# Create environment setup script.  Remember that $SDKTARGETSYSROOT should
@@ -63,6 +70,8 @@  toolchain_create_sdk_env_script () {
 	echo 'export OECORE_BASELIB="${baselib}"' >> $script
 	echo 'export OECORE_TARGET_ARCH="${TARGET_ARCH}"' >>$script
 	echo 'export OECORE_TARGET_OS="${TARGET_OS}"' >>$script
+	echo 'export OECORE_TARGET_BITS="${@siteinfo_with_prefix(d, 'bit-')}"' >>$script
+	echo 'export OECORE_TARGET_ENDIAN="${@siteinfo_with_prefix(d, 'endian-')}"' >>$script
 
 	echo 'unset command_not_found_handle' >> $script