pldm: change utils.cpp to a shared library
pldmtool is a separate executable that depends on utils.cpp.
Compile utils.cpp to a shared libaray so that it could be linked against
by components.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I25086d543746a220ff257b0b53101f4e61e28b95
diff --git a/libpldmresponder/meson.build b/libpldmresponder/meson.build
index fc47454..2a2705e 100644
--- a/libpldmresponder/meson.build
+++ b/libpldmresponder/meson.build
@@ -1,7 +1,8 @@
deps = [
dependency('phosphor-dbus-interfaces'),
dependency('sdbusplus'),
- libpldm
+ libpldm,
+ libpldmutils
]
sources = [
@@ -12,7 +13,6 @@
'pdr.cpp',
'effecters.cpp',
'platform.cpp',
- '../utils.cpp'
]
if get_option('oem-ibm').enabled()
diff --git a/meson.build b/meson.build
index 1af27f6..52af1d9 100644
--- a/meson.build
+++ b/meson.build
@@ -29,8 +29,25 @@
)
subdir('libpldm')
+
+libpldmutils_headers = ['.']
+libpldmutils = library(
+ 'pldmutils',
+ 'utils.cpp',
+ version: meson.project_version(),
+ dependencies: [
+ libpldm,
+ dependency('phosphor-dbus-interfaces'),
+ dependency('sdbusplus'),
+ ],
+ install: true,
+ include_directories: include_directories(libpldmutils_headers),
+)
+
+libpldmutils = declare_dependency(
+ include_directories: include_directories(libpldmutils_headers),
+ link_with: libpldmutils)
subdir('libpldmresponder')
-subdir('tool')
deps = [
libpldm,
@@ -50,6 +67,8 @@
install: true,
install_dir: get_option('bindir'))
+subdir('tool')
+
if get_option('tests').enabled()
subdir('test')
endif
diff --git a/test/meson.build b/test/meson.build
index 4366a2b..567ac34 100644
--- a/test/meson.build
+++ b/test/meson.build
@@ -14,7 +14,7 @@
gtest = dependency('gtest', main: true, disabler: true, required: true)
gmock = dependency('gmock', disabler: true, required: true)
-pldmd = declare_dependency(sources: ['../instance_id.cpp', '../utils.cpp'])
+pldmd = declare_dependency(sources: '../instance_id.cpp')
tests = [
'libpldm_base_test',
@@ -48,6 +48,7 @@
dependencies: [
libpldm,
libpldmresponder,
+ libpldmutils,
gtest,
gmock,
pldmd,
diff --git a/tool/meson.build b/tool/meson.build
index 1c55710..95f746c 100644
--- a/tool/meson.build
+++ b/tool/meson.build
@@ -9,6 +9,6 @@
'pldmtool',
sources,
implicit_include_directories: false,
- dependencies: libpldm,
+ dependencies: [libpldm, libpldmutils],
install: true,
install_dir: get_option('bindir'))