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)
diff --git a/meson_options.txt b/meson_options.txt
index d8dcc95..da9cdd3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -19,3 +19,6 @@
'ucd90160-yaml', type: 'string', value: 'example/ucd90160.yaml',
description: 'The sequencer definition file to use.',
)
+option(
+ 'oe-sdk', type: 'feature', description: 'Enable OE SDK'
+)
diff --git a/phosphor-regulators/test/meson.build b/phosphor-regulators/test/meson.build
index c051097..2a41cd1 100644
--- a/phosphor-regulators/test/meson.build
+++ b/phosphor-regulators/test/meson.build
@@ -27,6 +27,8 @@
gmock,
gtest,
],
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
link_with: [
phosphor_regulators_library,
libi2c_dev_mock
diff --git a/power-supply/test/meson.build b/power-supply/test/meson.build
index 8006d63..f7523a0 100644
--- a/power-supply/test/meson.build
+++ b/power-supply/test/meson.build
@@ -11,6 +11,8 @@
],
implicit_include_directories: false,
include_directories: '../..',
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
link_with: [
libpower,
],
diff --git a/test/meson.build b/test/meson.build
index aaa21b4..48233c5 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -6,6 +6,8 @@
gmock,
gtest,
],
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
implicit_include_directories: false,
include_directories: '..',
)
diff --git a/tools/i2c/test/meson.build b/tools/i2c/test/meson.build
index e732a84..1401914 100644
--- a/tools/i2c/test/meson.build
+++ b/tools/i2c/test/meson.build
@@ -6,6 +6,8 @@
dependencies: [
gmock
],
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
include_directories: [
libi2c_inc,
libi2c_dev_mock_inc
diff --git a/tools/power-utils/test/meson.build b/tools/power-utils/test/meson.build
index 1d365c3..9f49857 100644
--- a/tools/power-utils/test/meson.build
+++ b/tools/power-utils/test/meson.build
@@ -10,6 +10,8 @@
],
implicit_include_directories: false,
include_directories: libpower_inc,
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
link_with: [
libpower,
],
@@ -34,6 +36,8 @@
libi2c_inc,
libi2c_dev_mock_inc
],
+ link_args: dynamic_linker,
+ build_rpath: get_option('oe-sdk').enabled() ? rpath : '',
link_with: [
libpower,
libi2c_dev_mock