meson: Enable unit tests from x86
Enable running the unit tests from an x86 sdk.
Tested: Raun unit tests with:
meson -Doe-sdk=enabled -Dtests=enabled build
ninja -C build test
Change-Id: Ifc05946cbc30d37de89326e9095e98d9a9fdcec5
Signed-off-by: Adriana Kobylak <anoo@us.ibm.com>
diff --git a/meson.build b/meson.build
index 5104a7c..1aca29a 100644
--- a/meson.build
+++ b/meson.build
@@ -232,6 +232,21 @@
install_dir: dbus_policy_dir)
if not get_option('tests').disabled()
+ oe_sdk = get_option('oe-sdk')
+ if oe_sdk.enabled()
+ # Setup OE SYSROOT
+ OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
+ if OECORE_TARGET_SYSROOT == ''
+ error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
+ endif
+ message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
+ rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
+ ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
+ dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
+ else
+ dynamic_linker = []
+ endif
+
test(
'utest',
executable(
diff --git a/meson_options.txt b/meson_options.txt
index c6a640a..65638ca 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,4 +1,5 @@
option('tests', type: 'feature', description: 'Build tests.')
+option('oe-sdk', type: 'feature', description: 'Enable OE SDK')
option('device-type', type: 'combo', choices: ['static', 'ubi', 'mmc'], description: 'Select which device type to support')
option('vpnor', type: 'feature', description: 'Enable virtual PNOR support')
option('verify-signature', type: 'feature', description: 'Enable image signature validation')