Generate local elog-errors header file
Use elog-gen.py, elog-gen-template.mako.hpp, error yaml files
from SDK to build local elog-errors.hpp file
Change-Id: I9e22633c8b6a8eacc754771883de82e8b476def3
Signed-off-by: Marri Devender Rao <devenrao@in.ibm.com>
diff --git a/Makefile.am b/Makefile.am
index bc4a6e4..8fa2de3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,6 +1,5 @@
AM_DEFAULT_SOURCE_EXT = .cpp
-# For target build
if !INSTALL_ERROR_YAML
sbin_PROGRAMS = checkstop_app \
watchdog_timeout
@@ -8,10 +7,19 @@
nobase_nodist_include_HEADERS = \
org/open_power/Host/error.hpp
+if GEN_ERRORS
+nobase_nodist_include_HEADERS += \
+ phosphor-logging/elog-errors.hpp
+endif
+
BUILT_SOURCES = \
org/open_power/Host/error.cpp \
org/open_power/Host/error.hpp
+if GEN_ERRORS
+BUILT_SOURCES += phosphor-logging/elog-errors.hpp
+endif
+
CLEANFILES = ${BUILT_SOURCES}
checkstop_app_SOURCES = checkstop_app.cpp \
@@ -41,10 +49,24 @@
org/open_power/Host/error.cpp: ${top_srcdir}/org/open_power/Host.errors.yaml
@mkdir -p `dirname $@`
$(SDBUSPLUSPLUS) -r $(srcdir) error exception-cpp org.open_power.Host > $@
-else
-# For native build
+
+endif
# Export error YAML to shared location
yamldir = ${datadir}/phosphor-dbus-yaml/yaml
nobase_yaml_DATA = \
org/open_power/Host.errors.yaml
-endif #INSTALL_ERROR_YAML
+
+# Generate phosphor-logging/elog-errors.hpp
+if GEN_ERRORS
+ELOG_MAKO ?= elog-gen-template.mako.hpp
+ELOG_DIR ?= ${OECORE_NATIVE_SYSROOT}${datadir}/phosphor-logging/elog
+ELOG_GEN_DIR ?= ${ELOG_DIR}/tools/
+ELOG_MAKO_DIR ?= ${ELOG_DIR}/tools/phosphor-logging/templates/
+YAML_DIR ?= ${OECORE_NATIVE_SYSROOT}${datadir}/phosphor-dbus-yaml/yaml
+phosphor-logging/elog-errors.hpp:
+ @mkdir -p ${YAML_DIR}/org/open_power/
+ @cp ${top_srcdir}/org/open_power/Host.errors.yaml ${YAML_DIR}/org/open_power/Host.errors.yaml
+ @mkdir -p `dirname $@`
+ @chmod 777 $(ELOG_GEN_DIR)/elog-gen.py
+ $(AM_V_at)$(PYTHON) $(ELOG_GEN_DIR)/elog-gen.py -y ${YAML_DIR} -t ${ELOG_MAKO_DIR} -m ${ELOG_MAKO} -o $@
+endif
diff --git a/checkstop_app.cpp b/checkstop_app.cpp
index a67499e..b9510c2 100644
--- a/checkstop_app.cpp
+++ b/checkstop_app.cpp
@@ -1,5 +1,5 @@
#include <phosphor-logging/elog.hpp>
-#include "elog-errors.hpp"
+#include "phosphor-logging/elog-errors.hpp"
#include "org/open_power/Host/error.hpp"
int main(int argc, char* argv[])
diff --git a/configure.ac b/configure.ac
index 2802742..ca6d94e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11,9 +11,14 @@
AC_PROG_INSTALL
AC_PROG_MAKE_SET
-# Check for compiler, packages only during target build.
-# As the packages are not available on the host do not
-# perform checks during native build.
+# Generate elog-errors.hpp if gen_errors optional feature is enabled
+AC_ARG_ENABLE([gen_errors],
+ AS_HELP_STRING([--enable-gen_errors], [Enable elog-errors.hpp generation ]),
+ [],[gen_errors=yes])
+AM_CONDITIONAL([GEN_ERRORS], [test "x$enable_gen_errors" != "xno"])
+
+# Check for compiler, packages only when install_error_yaml optional feature
+# is disabled
AC_ARG_ENABLE([install_error_yaml],
AS_HELP_STRING([--enable-install_error_yaml], [Enable installing error yaml file]),
[], [install_error_yaml=no])
diff --git a/elog-errors.hpp b/elog-errors.hpp
deleted file mode 100644
index a1d9316..0000000
--- a/elog-errors.hpp
+++ /dev/null
@@ -1,125 +0,0 @@
-// This file was autogenerated. Do not edit!
-// See elog-gen.py for more details
-#pragma once
-
-#include <string>
-#include <tuple>
-#include <type_traits>
-#include <sdbusplus/exception.hpp>
-#include <phosphor-logging/log.hpp>
-#include <phosphor-logging/elog.hpp>
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Host
-{
-namespace Error
-{
- struct Checkstop;
-} // namespace Error
-} // namespace Host
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-namespace sdbusplus
-{
-namespace org
-{
-namespace open_power
-{
-namespace Host
-{
-namespace Error
-{
- struct WatchdogTimedOut;
-} // namespace Error
-} // namespace Host
-} // namespace open_power
-} // namespace org
-} // namespace sdbusplus
-
-
-namespace phosphor
-{
-
-namespace logging
-{
-
-namespace org
-{
-namespace open_power
-{
-namespace Host
-{
-namespace _Checkstop
-{
-
-
-} // namespace _Checkstop
-
-struct Checkstop
-{
- static constexpr auto L = level::ERR;
- using metadata_types = std::tuple<>;
-
-};
-
-} // namespace Host
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Host::Error::Checkstop>
-{
- using type = org::open_power::Host::Checkstop;
-};
-
-}
-
-namespace org
-{
-namespace open_power
-{
-namespace Host
-{
-namespace _WatchdogTimedOut
-{
-
-
-} // namespace _WatchdogTimedOut
-
-struct WatchdogTimedOut
-{
- static constexpr auto L = level::ERR;
- using metadata_types = std::tuple<>;
-
-};
-
-} // namespace Host
-} // namespace open_power
-} // namespace org
-
-
-namespace details
-{
-
-template <>
-struct map_exception_type<sdbusplus::org::open_power::Host::Error::WatchdogTimedOut>
-{
- using type = org::open_power::Host::WatchdogTimedOut;
-};
-
-}
-
-} // namespace logging
-
-} // namespace phosphor
diff --git a/watchdog_timeout.cpp b/watchdog_timeout.cpp
index 130b79a..bb0d4bc 100644
--- a/watchdog_timeout.cpp
+++ b/watchdog_timeout.cpp
@@ -1,5 +1,5 @@
#include <phosphor-logging/elog.hpp>
-#include "elog-errors.hpp"
+#include "phosphor-logging/elog-errors.hpp"
#include "org/open_power/Host/error.hpp"
int main(int argc, char* argv[])