Fix local meson build
Provide all the missing dependencies for the local meson build.
Tested:
"meson setup build && cd build && meson compile" finishes successfully.
Change-Id: If1d20df64610e47d2be813a8ffbe7602b6d00181
Signed-off-by: Konstantin Aladyshev <aladyshev22@gmail.com>
diff --git a/meson.build b/meson.build
index fde65e4..9c8b0d5 100644
--- a/meson.build
+++ b/meson.build
@@ -18,12 +18,38 @@
conf_data.set('CLASS_VERSION', 1)
conf_data.set('MAX_EVENTS', 20)
-sdbusplus_dep = dependency('sdbusplus')
+cpp = meson.get_compiler('cpp')
+# Get Cereal dependency.
+cereal_dep = dependency('cereal', required: false)
+has_cereal = cpp.has_header_symbol(
+ 'cereal/cereal.hpp',
+ 'cereal::specialize',
+ dependencies: cereal_dep,
+ required: false)
+if not has_cereal
+ cereal_opts = import('cmake').subproject_options()
+ cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
+ cereal_proj = import('cmake').subproject(
+ 'cereal',
+ options: cereal_opts,
+ required: false)
+ assert(cereal_proj.found(), 'cereal is required')
+ cereal_dep = cereal_proj.dependency('cereal')
+endif
+
+sdbusplus_dep = dependency('sdbusplus', required : false)
sdeventplus_dep = dependency('sdeventplus')
phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
phosphor_logging_dep = dependency('phosphor-logging')
phosphor_snmp_dep = dependency('phosphor-snmp')
+sdbusplus_python_env = {}
+if not sdbusplus_dep.found()
+ sdbusplus_proj = subproject('sdbusplus')
+ sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep')
+ sdbusplus_python_env = {'PYTHONPATH': meson.current_source_dir() / 'subprojects' / 'sdbusplus' / 'tools'}
+endif
+
prog_python = find_program('python3', required: true)
realpath_prog = find_program('realpath')
diff --git a/src/meson.build b/src/meson.build
index 76b8ef8..bd3a2cb 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -32,6 +32,7 @@
'generate-cpp'
],
depend_files: templates_depends,
+ env: sdbusplus_python_env,
output: 'generated.hpp',
)
@@ -49,6 +50,7 @@
]
deps = [
+ cereal_dep,
sdbusplus_dep,
sdeventplus_dep,
phosphor_dbus_interfaces_dep,
diff --git a/src/test/meson.build b/src/test/meson.build
index a1ae8e3..ba4ff6e 100644
--- a/src/test/meson.build
+++ b/src/test/meson.build
@@ -36,6 +36,7 @@
'yaml/pathgentest/groupone.yaml',
'yaml/pathgentest/grouptwo.yaml',
],
+ env: sdbusplus_python_env,
output: 'pathgentest.hpp',
)
@@ -50,7 +51,7 @@
pathgentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -71,6 +72,7 @@
'yaml/propertygentest/groupone.yaml',
'yaml/propertygentest/grouptwo.yaml',
],
+ env: sdbusplus_python_env,
output: 'propertygentest.hpp',
)
@@ -85,7 +87,7 @@
propertygentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -106,6 +108,7 @@
'yaml/propertywatchgentest/watchone.yaml',
'yaml/propertywatchgentest/watchtwo.yaml',
],
+ env: sdbusplus_python_env,
output: 'propertywatchgentest.hpp',
)
@@ -120,7 +123,7 @@
propertywatchgentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -141,6 +144,7 @@
'yaml/callbackgentest/one.yaml',
'yaml/callbackgentest/two.yaml',
],
+ env: sdbusplus_python_env,
output: 'callbackgentest.hpp',
)
@@ -155,7 +159,7 @@
callbackgentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -175,6 +179,7 @@
'templates/callbackgroupgentest.mako.hpp',
'yaml/callbackgroupgentest/test.yaml',
],
+ env: sdbusplus_python_env,
output: 'callbackgroupgentest.hpp',
)
@@ -189,7 +194,7 @@
callbackgroupgentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -209,6 +214,7 @@
'templates/conditiongentest.mako.hpp',
'yaml/conditiongentest/test.yaml',
],
+ env: sdbusplus_python_env,
output: 'conditiongentest.hpp',
)
@@ -223,7 +229,7 @@
conditiongentest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep]
))
@@ -238,6 +244,7 @@
]
callbacktest_deps = [
+ cereal_dep,
sdbusplus_dep,
sdeventplus_dep,
phosphor_dbus_interfaces_dep,
@@ -272,6 +279,7 @@
'templates/interfaceaddtest.mako.hpp',
'yaml/interfaceaddtest/one.yaml',
],
+ env: sdbusplus_python_env,
output: 'interfaceaddtest.hpp',
)
@@ -286,5 +294,5 @@
interfaceaddtest_sources,
build_by_default: false,
include_directories: ['..'],
- dependencies: [gtest_dep, gmock_dep]
+ dependencies: [gtest_dep, gmock_dep, phosphor_dbus_interfaces_dep, sdeventplus_dep]
))