build: Enabled meson build infrastructure
In this commit enabled meson build infrastructure which is taking less
time than autotools to build.
Changes:
- Same default value used for all build time configure option.
- All external library checks are added into meson as well.
- In meson, no need to mention list of files which are not required
to install because, by default nothing will be installed.
- Auto generated files are added into custom target and that will
trigger when some target dependent with that.
- In meson, enabled to treat warning as error so, modified few sources
which are producing un-used variables.
- Fixes made by removing those function parameters identifier alone.
By using meson, can able to see below built improvement time between meson
and autotools.
meson:
- time sh -c 'meson builddir -Dhost-dump-offload-transport=pldm
-Dubifs-workaround=enabled; ninja -C builddir/'
real 0m12.244s
user 0m57.575s
sys 0m7.793s
autotools:
- time sh -c 'autoreconf -i;
./configure ${CONFIGURE_FLAGS} --enable-ubifs-workaround
--with-host-dump-offload-transport=pldm; make'
real 1m16.539s
user 1m2.738s
sys 0m9.645s
TestedBy:
- meson builddir
ninja -C builddir
- meson builddir -Dubifs-workaround=enabled
ninja -C builddir
- meson builddir -Dubifs-workaround=disabled
ninja -C builddir
- meson builddir -Dhost-dump-offload-transport=pldm
ninja -C builddir
- meson builddir -Dhost-dump-offload-transport=pldm \
-Dubifs-workaround=enabled
ninja -C builddir
Note: Need to update openbmc phosphor-debug-collector recipe to use meson
instead autotools, this will be updated once this patch got merged
and also autotools build infrastructure will be removed as well.
Change-Id: Iadf2d3542dc2556377e7b2f91f01b04d5f8d7218
Signed-off-by: Ramesh Iyyar <rameshi1@in.ibm.com>
diff --git a/README.md b/README.md
index 0d75b40..e6d1b39 100644
--- a/README.md
+++ b/README.md
@@ -12,3 +12,12 @@
To clean the repository run `./bootstrap.sh clean`.
```
+
+## To Build with meson
+To build this package with meson, do the following steps:
+```
+ 1. meson builddir
+ 2. ninja -C builddir
+```
+To clean the built files run `ninja -C builddir clean`.
+
diff --git a/core_manager_main.cpp b/core_manager_main.cpp
index e680c12..aca772b 100644
--- a/core_manager_main.cpp
+++ b/core_manager_main.cpp
@@ -7,7 +7,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <sdbusplus/bus.hpp>
-int main(int argc, char* argv[])
+int main()
{
using namespace phosphor::logging;
using InternalFailure =
diff --git a/dump_manager.cpp b/dump_manager.cpp
index a42fce2..3fd03ee 100644
--- a/dump_manager.cpp
+++ b/dump_manager.cpp
@@ -241,7 +241,7 @@
return size;
}
-void Manager::notify(NewDump::DumpType dumpType, uint32_t dumpId, uint64_t size)
+void Manager::notify(NewDump::DumpType, uint32_t dumpId, uint64_t size)
{
// Get the timestamp
auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(
diff --git a/dump_manager.hpp b/dump_manager.hpp
index 4b5005d..40f62fb 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -139,7 +139,7 @@
*
* @returns 0 on success, -1 on fail
*/
- static int callback(sd_event_source* s, const siginfo_t* si, void* userdata)
+ static int callback(sd_event_source*, const siginfo_t*, void*)
{
// No specific action required in
// the sd_event_add_child callback.
diff --git a/dump_manager_main.cpp b/dump_manager_main.cpp
index 787bd12..cd76742 100644
--- a/dump_manager_main.cpp
+++ b/dump_manager_main.cpp
@@ -9,7 +9,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <sdbusplus/bus.hpp>
-int main(int argc, char* argv[])
+int main()
{
using namespace phosphor::logging;
using InternalFailure =
diff --git a/elog_watch.cpp b/elog_watch.cpp
index 7144281..cbcfa3c 100644
--- a/elog_watch.cpp
+++ b/elog_watch.cpp
@@ -13,7 +13,7 @@
#include <sdbusplus/exception.hpp>
// Register class version with Cereal
-CEREAL_CLASS_VERSION(phosphor::dump::elog::Watch, CLASS_VERSION);
+CEREAL_CLASS_VERSION(phosphor::dump::elog::Watch, CLASS_VERSION)
namespace phosphor
{
diff --git a/meson.build b/meson.build
new file mode 100644
index 0000000..8bbed76
--- /dev/null
+++ b/meson.build
@@ -0,0 +1,155 @@
+# SPDX-License-Identifier: Apache-2.0
+
+project('phosphor-debug-collector',
+ 'cpp',
+ default_options: [
+ 'cpp_std=c++17',
+ 'warning_level=3',
+ 'werror=true'
+ ],
+ version: '1.0',
+ license: 'Apache-2.0'
+ )
+
+# Checking dependency external library
+
+cppfs = meson.get_compiler('cpp').find_library('stdc++fs')
+libsystemd = dependency('libsystemd', version : '>=221')
+phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
+sdbusplus = dependency('sdbusplus')
+phosphor_logging = dependency('phosphor-logging')
+
+# Configuration header file(config.h) generation
+
+conf_data = configuration_data()
+
+conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'),
+ description : 'The Dbus busname to own'
+ )
+conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'),
+ description : 'The Dump manager Dbus root'
+ )
+conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'),
+ description : 'Directory where core dumps are placed'
+ )
+conf_data.set_quoted('OBJ_INTERNAL', get_option('OBJ_INTERNAL'),
+ description : 'Internal Dump manager Dbus object path'
+ )
+conf_data.set_quoted('OBJ_ENTRY', get_option('OBJ_ENTRY'),
+ description : 'The dump entry DBus object path'
+ )
+conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'),
+ description : 'Directory where bmc dumps are placed')
+conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'),
+ description : 'Maximum size of one bmc dump in kilo bytes'
+ )
+conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'),
+ description : 'Minimum space required for one bmc dump in kilo bytes'
+ )
+conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'),
+ description : 'Total size of the dump in kilo bytes'
+ )
+conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging',
+ description : 'The log manager DBus object path'
+ )
+conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'),
+ description : 'Path of file for storing elog id\'s, which have associated dumps'
+ )
+conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'),
+ description : 'Class version to register with Cereal'
+ )
+conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'),
+ description : 'YAML filepath containing error object paths'
+ )
+conf_data.set('UBI_CORE_FILE_WORKAROUND', get_option('ubifs-workaround').enabled(),
+ description : 'Turn on ubi workaround for core file'
+ )
+
+configure_file(configuration : conf_data,
+ output : 'config.h'
+ )
+
+subdir('xyz/openbmc_project/Dump/Internal/Create')
+
+python = find_program('python3')
+errors_map_gen_file_loc = meson.source_root()
+errors_map_gen_file_loc += '/errors_map_gen.py'
+
+errors_map_hpp = custom_target(
+ 'errors_map.hpp',
+ command : [
+ python,
+ errors_map_gen_file_loc,
+ '-i',
+ get_option('ERROR_MAP_YAML')
+ ],
+ depend_files : [ 'errors_map.mako.hpp',
+ 'errors_map_gen.py',
+ get_option('ERROR_MAP_YAML')
+ ],
+ output : 'errors_map.hpp'
+ )
+
+phosphor_dump_manager_sources = [
+ 'dump_entry.cpp',
+ 'dump_manager.cpp',
+ 'dump_manager_main.cpp',
+ 'dump_serialize.cpp',
+ 'elog_watch.cpp',
+ errors_map_hpp,
+ server_hpp,
+ server_cpp,
+ 'watch.cpp',
+ 'bmc_dump_entry.cpp',
+ 'dump_utils.cpp',
+ 'system_dump_entry.cpp',
+ 'dump_offload.cpp'
+ ]
+
+phosphor_dump_manager_dependency = [
+ phosphor_dbus_interfaces,
+ sdbusplus,
+ phosphor_logging,
+ cppfs
+ ]
+
+phosphor_dump_manager_install = true
+
+# To get host dump offload transport source files and dependency list
+# for phosphor_dump_manager
+subdir('offload-extensions')
+
+phosphor_dump_monitor_sources = [
+ 'core_manager.cpp',
+ 'core_manager_main.cpp',
+ 'watch.cpp'
+ ]
+
+phosphor_dump_monitor_dependency = [
+ phosphor_dbus_interfaces,
+ phosphor_logging,
+ cppfs
+ ]
+
+phosphor_dump_monitor_install = true
+
+executables = [[ 'phosphor-dump-manager',
+ phosphor_dump_manager_sources,
+ phosphor_dump_manager_dependency,
+ phosphor_dump_manager_install
+ ],
+ [ 'phosphor-dump-monitor',
+ phosphor_dump_monitor_sources,
+ phosphor_dump_monitor_dependency,
+ phosphor_dump_monitor_install
+ ]
+ ]
+
+foreach executable : executables
+ binary = executable(
+ executable[0],
+ executable[1],
+ dependencies: executable[2],
+ install : executable[3]
+ )
+endforeach
diff --git a/meson_options.txt b/meson_options.txt
new file mode 100644
index 0000000..da8d8e7
--- /dev/null
+++ b/meson_options.txt
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: Apache-2.0
+
+option('ubifs-workaround', type: 'feature',
+ description : 'Turn on ubi workaround for core file'
+ )
+
+option('DUMP_BUSNAME', type : 'string',
+ value : 'xyz.openbmc_project.Dump.Manager',
+ description : 'The Dbus busname to own'
+ )
+
+option('DUMP_OBJPATH', type : 'string',
+ value : '/xyz/openbmc_project/dump',
+ description : 'The Dump manager Dbus root'
+ )
+
+option('CORE_FILE_DIR', type : 'string',
+ value : '/var/lib/systemd/coredump',
+ description : 'Directory where core dumps are placed'
+ )
+
+option('OBJ_INTERNAL', type : 'string',
+ value : '/xyz/openbmc_project/dump/internal/manager',
+ description : 'Internal Dump manager Dbus object path'
+ )
+
+option('OBJ_ENTRY', type : 'string',
+ value : '/xyz/openbmc_project/dump/entry',
+ description : 'The dump entry DBus object path'
+ )
+
+option('BMC_DUMP_PATH', type : 'string',
+ value : '/var/lib/phosphor-debug-collector/dumps/',
+ description : 'Directory where bmc dumps are placed'
+ )
+
+option('BMC_DUMP_MAX_SIZE', type : 'integer',
+ value : 200,
+ description : 'Maximum size of one bmc dump in kilo bytes'
+ )
+
+option('BMC_DUMP_MIN_SPACE_REQD', type : 'integer',
+ value : 20,
+ description : 'Minimum space required for one bmc dump in kilo bytes'
+ )
+
+option('BMC_DUMP_TOTAL_SIZE', type : 'integer',
+ value : 1024,
+ description : 'Total size of the dump in kilo bytes'
+ )
+
+option('ELOG_ID_PERSIST_PATH', type : 'string',
+ value : '/var/lib/phosphor-debug-collector/elogid',
+ description : 'Path of file for storing elog id\'s, which have associated dumps'
+ )
+
+option('CLASS_VERSION', type : 'integer',
+ value : 1,
+ description : 'Class version to register with Cereal'
+ )
+
+option('ERROR_MAP_YAML', type : 'string',
+ value : 'example_errors_watch.yaml',
+ description : 'YAML filepath containing error object paths'
+ )
+
+option('host-dump-offload-transport', type : 'string',
+ value : 'default',
+ description : 'To specify the host dump transport protocol')
diff --git a/offload-extensions/default/default.cpp b/offload-extensions/default/default.cpp
index 6a14fdc..9eb2bfe 100644
--- a/offload-extensions/default/default.cpp
+++ b/offload-extensions/default/default.cpp
@@ -7,7 +7,7 @@
{
namespace host
{
-void requestOffload(uint32_t id)
+void requestOffload(uint32_t)
{
throw std::runtime_error("Hostdump offload method not specified");
}
diff --git a/offload-extensions/default/meson.build b/offload-extensions/default/meson.build
new file mode 100644
index 0000000..ca615b2
--- /dev/null
+++ b/offload-extensions/default/meson.build
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: Apache-2.0
+
+phosphor_dump_manager_sources += [
+ 'offload-extensions/default/default.cpp'
+ ]
diff --git a/offload-extensions/meson.build b/offload-extensions/meson.build
new file mode 100644
index 0000000..20b1f3b
--- /dev/null
+++ b/offload-extensions/meson.build
@@ -0,0 +1,9 @@
+# SPDX-License-Identifier: Apache-2.0
+
+hostDumpOffloadTransport = get_option('host-dump-offload-transport')
+
+if hostDumpOffloadTransport == 'default'
+ subdir('default')
+elif hostDumpOffloadTransport == 'pldm'
+ subdir('pldm')
+endif
diff --git a/offload-extensions/pldm/meson.build b/offload-extensions/pldm/meson.build
new file mode 100644
index 0000000..d3ae2ac
--- /dev/null
+++ b/offload-extensions/pldm/meson.build
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: Apache-2.0
+
+phosphor_dump_manager_sources += [
+ 'offload-extensions/pldm/pldm_interface.cpp'
+ ]
+
+phosphor_dump_manager_dependency += [ dependency('libpldm') ]
diff --git a/watch.cpp b/watch.cpp
index dfee3b3..659320a 100644
--- a/watch.cpp
+++ b/watch.cpp
@@ -72,8 +72,7 @@
return fd;
}
-int Watch::callback(sd_event_source* s, int fd, uint32_t revents,
- void* userdata)
+int Watch::callback(sd_event_source*, int fd, uint32_t revents, void* userdata)
{
auto userData = static_cast<Watch*>(userdata);
diff --git a/xyz/openbmc_project/Dump/Internal/Create/meson.build b/xyz/openbmc_project/Dump/Internal/Create/meson.build
new file mode 100644
index 0000000..52294fa
--- /dev/null
+++ b/xyz/openbmc_project/Dump/Internal/Create/meson.build
@@ -0,0 +1,32 @@
+# SPDX-License-Identifier: Apache-2.0
+
+sdbuscpp = find_program('sdbus++')
+
+server_hpp = custom_target(
+ 'server.hpp',
+ command : [
+ sdbuscpp, '-r', meson.source_root(),
+ 'interface',
+ 'server-header',
+ 'xyz.openbmc_project.Dump.Internal.Create',
+ ],
+ input : '../Create.interface.yaml',
+ capture : true,
+ output : 'server.hpp',
+ install : true,
+ install_dir: get_option('includedir') / 'xyz/openbmc_project/Dump/Internal/Create'
+ )
+
+server_cpp = custom_target(
+ 'server.cpp',
+ command : [
+ sdbuscpp, '-r', meson.source_root(),
+ 'interface',
+ 'server-cpp',
+ 'xyz.openbmc_project.Dump.Internal.Create'
+ ],
+ input : '../Create.interface.yaml',
+ depends : server_hpp,
+ capture : true,
+ output : 'server.cpp'
+ )