build: meson support for phosphor-log-manager
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I5400d21d59b3c1ff8bde61d80eaec1cb6701a8cb
diff --git a/config.h.meson b/config.h.meson
index 0e71553..8618a4b 100644
--- a/config.h.meson
+++ b/config.h.meson
@@ -1,11 +1,32 @@
#pragma once
+#include <cstddef>
+
+#define PROCESS_META 1
// @TODO(stwcx): These values are currently configured in autoconf but never
// modified by anyone, nor could I see why they ever would be.
// Once autoconf is removed, they should be switched over to
// a constant in a header file.
+#define BMC_VERSION_FILE "/etc/os-release"
#define BUSNAME_LOGGING "xyz.openbmc_project.Logging"
+#define CALLOUT_FWD_ASSOCIATION "callout"
+#define CALLOUT_REV_ASSOCIATION "fault"
+#define INVENTORY_ROOT "/xyz/openbmc_project/inventory"
+#define OBJ_ENTRY "/xyz/openbmc_project/logging/entry"
#define OBJ_INTERNAL "/xyz/openbmc_project/logging/internal/manager"
+#define OBJ_LOGGING "/xyz/openbmc_project/logging"
+#define SYSTEMD_BUSNAME "org.freedesktop.systemd1"
+#define SYSTEMD_INTERFACE "org.freedesktop.systemd1.Manager"
+#define SYSTEMD_PATH "/org/freedesktop/systemd1"
+
+#define ERRLOG_PERSIST_PATH "/var/lib/phosphor-logging/errors" // TODO: need /tmp/errors in some cases?
+
+static constexpr size_t ERROR_CAP = @error_cap@;
+static constexpr size_t ERROR_INFO_CAP = @error_info_cap@;
+
+static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_FWLEVEL = "2";
+static constexpr auto FIRST_CEREAL_CLASS_VERSION_WITH_UPDATE_TS = "3";
+static constexpr size_t CLASS_VERSION = 3;
// vim: ft=cpp
diff --git a/elog_meta.hpp b/elog_meta.hpp
index 81d8e58..a4ace76 100644
--- a/elog_meta.hpp
+++ b/elog_meta.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "config.h"
+
#include "callouts-gen.hpp"
#include "elog_entry.hpp"
diff --git a/gen/README b/gen/README
new file mode 100644
index 0000000..71182b5
--- /dev/null
+++ b/gen/README
@@ -0,0 +1,2 @@
+This directory contains generated meson.build files from sdbus++-gen-meson.
+Do not edit them by hand.
diff --git a/gen/meson.build b/gen/meson.build
new file mode 100644
index 0000000..af850f2
--- /dev/null
+++ b/gen/meson.build
@@ -0,0 +1,14 @@
+# Generated file; do not modify.
+sdbuspp_gen_meson_ver = run_command(
+ sdbuspp_gen_meson_prog,
+ '--version',
+).stdout().strip().split('\n')[0]
+
+if sdbuspp_gen_meson_ver != 'sdbus++-gen-meson version 2'
+ warning('Generated meson files from wrong version of sdbus++-gen-meson.')
+ warning(
+ 'Expected "sdbus++-gen-meson version 2", got:',
+ sdbuspp_gen_meson_ver
+ )
+endif
+
diff --git a/gen/regenerate-meson b/gen/regenerate-meson
new file mode 100755
index 0000000..56bc2c6
--- /dev/null
+++ b/gen/regenerate-meson
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+REPO_ROOT=$(git rev-parse --show-toplevel)
+
+# Find sdbus++-gen-meson
+# 1. Check $SDBUSPP_GEN_MESON
+# 2. Check in $PATH
+# 3. Check in subprojects/sdbusplus
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$(which sdbus++-gen-meson 2> /dev/null)"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ SDBUSPP_GEN_MESON="$REPO_ROOT/subprojects/sdbusplus/tools/sdbus++-gen-meson"
+fi
+if [ ! -x "$SDBUSPP_GEN_MESON" ]; then
+ echo "Cannot find sdbus++-gen-meson ($SDBUSPP_GEN_MESON)."
+ exit 1
+fi
+
+$SDBUSPP_GEN_MESON \
+ --command meson \
+ --directory "$REPO_ROOT" \
+ --output "$REPO_ROOT/gen"
diff --git a/gen/xyz/meson.build b/gen/xyz/meson.build
new file mode 100644
index 0000000..e4991ad
--- /dev/null
+++ b/gen/xyz/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('openbmc_project')
diff --git a/gen/xyz/openbmc_project/Logging/Internal/Manager/meson.build b/gen/xyz/openbmc_project/Logging/Internal/Manager/meson.build
new file mode 100644
index 0000000..230448b
--- /dev/null
+++ b/gen/xyz/openbmc_project/Logging/Internal/Manager/meson.build
@@ -0,0 +1,14 @@
+# Generated file; do not modify.
+generated_sources += custom_target(
+ 'xyz/openbmc_project/Logging/Internal/Manager__cpp'.underscorify(),
+ input: [ meson.project_source_root() / 'xyz/openbmc_project/Logging/Internal/Manager.interface.yaml', ],
+ output: [ 'server.cpp', 'server.hpp', 'client.hpp', ],
+ command: [
+ sdbuspp_gen_meson_prog, '--command', 'cpp',
+ '--output', meson.current_build_dir(),
+ '--tool', sdbusplusplus_prog,
+ '--directory', meson.project_source_root(),
+ 'xyz/openbmc_project/Logging/Internal/Manager',
+ ],
+)
+
diff --git a/gen/xyz/openbmc_project/Logging/Internal/meson.build b/gen/xyz/openbmc_project/Logging/Internal/meson.build
new file mode 100644
index 0000000..aaa5ce8
--- /dev/null
+++ b/gen/xyz/openbmc_project/Logging/Internal/meson.build
@@ -0,0 +1,16 @@
+# Generated file; do not modify.
+subdir('Manager')
+generated_others += custom_target(
+ 'xyz/openbmc_project/Logging/Internal/Manager__markdown'.underscorify(),
+ input: [ meson.project_source_root() / 'xyz/openbmc_project/Logging/Internal/Manager.interface.yaml', ],
+ output: [ 'Manager.md' ],
+ command: [
+ sdbuspp_gen_meson_prog, '--command', 'markdown',
+ '--output', meson.current_build_dir(),
+ '--tool', sdbusplusplus_prog,
+ '--directory', meson.project_source_root(),
+ 'xyz/openbmc_project/Logging/Internal/Manager',
+ ],
+ build_by_default: true,
+)
+
diff --git a/gen/xyz/openbmc_project/Logging/meson.build b/gen/xyz/openbmc_project/Logging/meson.build
new file mode 100644
index 0000000..6421d35
--- /dev/null
+++ b/gen/xyz/openbmc_project/Logging/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('Internal')
diff --git a/gen/xyz/openbmc_project/meson.build b/gen/xyz/openbmc_project/meson.build
new file mode 100644
index 0000000..1b45c9d
--- /dev/null
+++ b/gen/xyz/openbmc_project/meson.build
@@ -0,0 +1,2 @@
+# Generated file; do not modify.
+subdir('Logging')
diff --git a/meson.build b/meson.build
index 64931d9..f448b39 100644
--- a/meson.build
+++ b/meson.build
@@ -35,6 +35,15 @@
fallback: ['sdeventplus', 'sdeventplus_dep' ],
)
+# Get Cereal dependency.
+cereal_dep = dependency('cereal', required: false)
+if not cereal_dep.found()
+ subproject('cereal', required: false)
+ cereal_dep = declare_dependency(
+ include_directories: [ 'subprojects/cereal/include' ],
+ )
+endif
+
# Find the installed YAML directory, either from a configure option or
# by pulling it from the PDI dependency.
yamldir = get_option('yamldir')
@@ -44,12 +53,20 @@
# Create config.h with constants that use to come from autoconf.
conf_data = configuration_data()
+conf_data.set('error_cap', get_option('error_cap'))
+conf_data.set('error_info_cap', get_option('error_info_cap'))
configure_file(
input: 'config.h.meson',
output: 'config.h',
configuration: conf_data,
)
+# Generate sdbus++ files.
+generated_sources = []
+generated_others = []
+subdir('gen')
+subdir('gen/xyz')
+
# Generate callouts-gen.hpp.
callouts_gen = custom_target('callouts-gen.hpp'.underscorify(),
input: [
@@ -60,6 +77,38 @@
output: 'callouts-gen.hpp',
command: [ python_prog, '@INPUT0@', '-i', '@INPUT2@', '-o', '@OUTPUT0@' ],
)
+# Generate elog-lookup.cpp
+elog_lookup_gen = custom_target('elog-lookup.cpp'.underscorify(),
+ input: files(
+ 'tools/elog-gen.py',
+ 'tools/phosphor-logging/templates/elog-lookup-template.mako.cpp',
+ ),
+ output: 'elog-lookup.cpp',
+ command: [
+ python_prog, '@INPUT0@',
+ '-t', '',
+ '-m', '@INPUT1@',
+ '-y', yamldir,
+ '-u', meson.current_source_dir() / '../tools/',
+ '-o', '@OUTPUT0@',
+ ],
+)
+# Generate elog-process-metadata.cpp
+elog_process_gen = custom_target('elog-process-metadata.cpp'.underscorify(),
+ input: files(
+ 'tools/elog-gen.py',
+ 'tools/phosphor-logging/templates/elog-process-metadata.mako.cpp',
+ ),
+ output: 'elog-process-metadata.cpp',
+ command: [
+ python_prog, '@INPUT0@',
+ '-t', '',
+ '-m', '@INPUT1@',
+ '-y', yamldir,
+ '-u', meson.current_source_dir() / '../tools/',
+ '-o', '@OUTPUT0@',
+ ],
+)
subdir('phosphor-logging')
@@ -97,3 +146,27 @@
sources: [ callouts_gen, elog_errors_gen ],
dependencies: [ sdbusplus_dep, pdi_dep, sdeventplus_dep],
)
+
+# Generate daemon.
+executable('phosphor-log-manager',
+ generated_sources,
+ elog_lookup_gen,
+ elog_process_gen,
+ 'elog_entry.cpp',
+ 'elog_meta.cpp',
+ 'elog_serialize.cpp',
+ 'extensions.cpp',
+ 'log_manager.cpp',
+ 'log_manager_main.cpp',
+ 'sdjournal.cpp',
+ 'util.cpp',
+ include_directories: include_directories('gen'),
+ link_with: libphosphor_logging,
+ dependencies: [
+ cereal_dep,
+ pdi_dep,
+ sdbusplus_dep,
+ sdeventplus_dep
+ ],
+ install: true,
+)
diff --git a/meson_options.txt b/meson_options.txt
index 0a8c744..5f3bd2f 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -5,3 +5,16 @@
value: 'callouts/callouts-example.yaml',
description: 'Path to Callout YAML',
)
+
+option(
+ 'error_cap',
+ type: 'integer',
+ value: 200,
+ description: 'Max number of error enttries allowed for commit',
+)
+option(
+ 'error_info_cap',
+ type: 'integer',
+ value: 10,
+ description: 'Cap on informational (and below) severity errors',
+)
diff --git a/subprojects/cereal.wrap b/subprojects/cereal.wrap
new file mode 100644
index 0000000..a4cb7ec
--- /dev/null
+++ b/subprojects/cereal.wrap
@@ -0,0 +1,4 @@
+[wrap-git]
+url = https://github.com/USCiLab/cereal.git
+revision = HEAD
+# need at least for C++20 fixes 3e4d1b84cab4891368d2179a61a7ba06a5693e7f