Add OE-SDK option to Meson

Add option to enable oe-sdk which will setup linker arguments to allow
for building and running tests with the x86 SDK.

Signed-off-by: Brandon Wyman <bjwyman@gmail.com>
Change-Id: I8279b7d862e29235d2d4eae39405cc35a51b762f
diff --git a/meson.build b/meson.build
index bc697ff..e4e8aa2 100644
--- a/meson.build
+++ b/meson.build
@@ -13,6 +13,21 @@
 
 build_tests = get_option('tests')
 
+if get_option('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
+
+
 cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
 gmock = dependency('gmock', disabler: true, required: build_tests)
 gtest = dependency('gtest', main: true, disabler: true, required: build_tests)