summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am6
-rwxr-xr-xsrc/gen-group-defs.py33
-rw-r--r--src/generated.mako.cpp25
3 files changed, 64 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c57553..233b610 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,3 +14,9 @@ phosphor_dbus_monitor_LDADD = \
phosphor_dbus_monitor_CXXFLAGS = \
$(SDBUSPLUS_CFLAGS) \
$(PHOSPHOR_LOGGING_CFLAGS)
+
+BUILT_SOURCES = generated.cpp
+CLEANFILES = generated.cpp
+
+generated.cpp:
+ $(AM_V_GEN)$(PYTHON) ${srcdir}/gen-group-defs.py -y ${srcdir}/example/monitoring_defs.yaml -o ${builddir}
diff --git a/src/gen-group-defs.py b/src/gen-group-defs.py
new file mode 100755
index 0000000..56ac00f
--- /dev/null
+++ b/src/gen-group-defs.py
@@ -0,0 +1,33 @@
+#!/usr/bin/env python
+
+import os
+import sys
+import yaml
+from argparse import ArgumentParser
+from mako.template import Template
+
+
+def generate(yaml_file, output_file):
+ with open(yaml_file, 'r') as yaml_input:
+ yaml_data = yaml.safe_load(yaml_input) or {}
+
+ with open(output_file, 'w') as gen_out:
+ gen_out.write(Template(filename='generated.mako.cpp').render(
+ events=yaml_data))
+
+
+if __name__ == '__main__':
+ parser = ArgumentParser()
+ # Groups of items and how they should be monitored yaml file
+ parser.add_argument(
+ "-y", "--yaml", dest="input_yaml",
+ default="example/monitoring_defs.yaml",
+ help="Input item monitoring definition yaml to parse")
+ parser.add_argument(
+ "-o", "--outdir", dest="output_dir",
+ default=os.path.abspath('.'),
+ help="Output directory for source files generated")
+ args = parser.parse_args(sys.argv[1:])
+
+ yaml_file = os.path.abspath(args.input_yaml)
+ generate(yaml_file, os.path.join(args.output_dir, "generated.cpp"))
diff --git a/src/generated.mako.cpp b/src/generated.mako.cpp
new file mode 100644
index 0000000..a8f6d60
--- /dev/null
+++ b/src/generated.mako.cpp
@@ -0,0 +1,25 @@
+## This file is a template, the comment below is emitted into the generated file
+/* This is an auto generated file. Do not edit. */
+#include "data_types.hpp"
+#include "monitor.hpp"
+#include "functor.hpp"
+#include "conditions.hpp"
+#include "actions.hpp"
+
+namespace phosphor
+{
+namespace dbus
+{
+namespace monitoring
+{
+
+const std::vector<std::tuple<std::vector<std::shared_ptr<Event>>,
+ std::vector<Action>>>
+ Monitor::events
+{
+
+};
+
+} // namespace monitoring
+} // namespace dbus
+} // namespace phosphor
OpenPOWER on IntegriCloud