meson: Switch autoconf build to meson
Summary:
- Add meson build flow.
- Remove the options not being configured from yocto as configure
args and add them as constants/define in settings_manager.hpp
Tested:
- autotools build passes.
- meson build passes with "ninja -C build".
Change-Id: Iaa7704886cdcd5481a04bae77e02df2c6a53aee9
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/configure.ac b/configure.ac
index edaf450..8e1a491 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,26 +21,9 @@
AX_CXX_COMPILE_STDCXX([20], [noext])
AX_APPEND_COMPILE_FLAGS([-Wall -Werror], [CXXFLAGS])
-AC_ARG_VAR(SETTINGS_BUSNAME, [The Dbus busname to own])
-AS_IF([test "x$SETTINGS_BUSNAME" == "x"],\
- [SETTINGS_BUSNAME="xyz.openbmc_project.Settings"])
-AC_DEFINE_UNQUOTED([SETTINGS_BUSNAME], ["$SETTINGS_BUSNAME"],\
- [The DBus busname to own])
-
AS_IF([test "x$SETTINGS_YAML" == "x"], [SETTINGS_YAML="settings_example.yaml"])
SETTINGSGEN="$PYTHON $srcdir/settings.py -i $SETTINGS_YAML"
AC_SUBST(SETTINGSGEN)
-AC_ARG_VAR(SETTINGS_PERSIST_PATH, \
- [Path of directory housing persisted settings.])
-AS_IF([test "x$SETTINGS_PERSIST_PATH" == "x"], \
- [SETTINGS_PERSIST_PATH="/var/lib/phosphor-settings-manager/settings"])
-AC_DEFINE_UNQUOTED([SETTINGS_PERSIST_PATH], ["$SETTINGS_PERSIST_PATH"], \
- [Path of directory housing persisted settings])
-
-AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
-AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=1])
-AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])
-
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..fbd3ec0
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,67 @@
+project('phosphor-settingsd', 'cpp',
+ version: '1.0',
+ meson_version: '>=0.58.0',
+ default_options: [
+ 'warning_level=3',
+ 'werror=true',
+ 'cpp_std=c++20',
+ ]
+)
+cpp = meson.get_compiler('cpp')
+
+python_prog = find_program('python3', native: true)
+
+# Define dependencies
+sdbusplus_dep = dependency('sdbusplus')
+phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
+phosphor_logging_dep = dependency('phosphor-logging')
+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'})
+ 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
+
+# Generate settings_manager.hpp
+settings_gen = custom_target(
+ 'settings_manager.hpp'.underscorify(),
+ input: [
+ 'settings.py',
+ 'settings_manager.mako.hpp',
+ get_option('settings_yaml'),
+ ],
+ output: 'settings_manager.hpp',
+ command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@' ],
+)
+
+# Generate daemon
+settings_manager_sources = [
+ settings_gen,
+]
+
+settings_manager_deps = [
+ cereal_dep,
+ sdbusplus_dep,
+ phosphor_dbus_interfaces_dep,
+ phosphor_logging_dep,
+]
+
+executable(
+ 'phosphor-settings-manager',
+ 'settings_main.cpp',
+ settings_manager_sources,
+ dependencies: [
+ settings_manager_deps,
+ ],
+ install: true,
+)
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..1725883
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,6 @@
+option(
+ 'settings_yaml',
+ type: 'string',
+ value: 'settings_example.yaml',
+ description: 'Path to settings yaml',
+)
diff --git a/settings.py b/settings.py
index 0867fbc..c6df0e0 100755
--- a/settings.py
+++ b/settings.py
@@ -21,7 +21,7 @@
)
args = parser.parse_args()
- with open(os.path.join(script_dir, args.settings_yaml), "r") as fd:
+ with open(args.settings_yaml, "r") as fd:
yamlDict = yaml.safe_load(fd)
# Render the mako template
diff --git a/settings_main.cpp b/settings_main.cpp
index abc28c5..554f260 100644
--- a/settings_main.cpp
+++ b/settings_main.cpp
@@ -1,5 +1,3 @@
-#include "config.h"
-
#include "settings_manager.hpp"
#include <sdbusplus/bus.hpp>
diff --git a/settings_manager.mako.hpp b/settings_manager.mako.hpp
index 4815ee5..367c8aa 100644
--- a/settings_manager.mako.hpp
+++ b/settings_manager.mako.hpp
@@ -42,10 +42,17 @@
#include <phosphor-logging/elog.hpp>
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
-#include "config.h"
#include <xyz/openbmc_project/Common/error.hpp>
using namespace phosphor::logging;
+/* The DBus busname to own */
+#define SETTINGS_BUSNAME "xyz.openbmc_project.Settings"
+/* Path of directory housing persisted settings */
+#define SETTINGS_PERSIST_PATH "/var/lib/phosphor-settings-manager/settings"
+
+/* Class version to register with Cereal */
+static constexpr size_t CLASS_VERSION = 1;
+
% for i in set(sdbusplus_includes):
#include "${i}"
% endfor
diff --git a/subprojects/cereal.wrap b/subprojects/cereal.wrap
new file mode 100644
index 0000000..4897eb3
--- /dev/null
+++ b/subprojects/cereal.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/USCiLab/cereal.git
+revision = HEAD
+
+[provide]
+cereal = cereal_dep
diff --git a/subprojects/phosphor-dbus-interfaces.wrap b/subprojects/phosphor-dbus-interfaces.wrap
new file mode 100644
index 0000000..346aa0c
--- /dev/null
+++ b/subprojects/phosphor-dbus-interfaces.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-dbus-interfaces.git
+revision = HEAD
+
+[provide]
+phosphor-dbus-interfaces = phosphor_dbus_interfaces_dep
diff --git a/subprojects/phosphor-logging.wrap b/subprojects/phosphor-logging.wrap
new file mode 100644
index 0000000..71eee8b
--- /dev/null
+++ b/subprojects/phosphor-logging.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/phosphor-logging.git
+revision = HEAD
+
+[provide]
+phosphor-logging = phosphor_logging_dep
diff --git a/subprojects/sdbusplus.wrap b/subprojects/sdbusplus.wrap
new file mode 100644
index 0000000..7b076d0
--- /dev/null
+++ b/subprojects/sdbusplus.wrap
@@ -0,0 +1,6 @@
+[wrap-git]
+url = https://github.com/openbmc/sdbusplus.git
+revision = HEAD
+
+[provide]
+sdbusplus = sdbusplus_dep