From 1febc28a1b9b72c805b74c28c8b505e292591fc5 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Wed, 12 Apr 2017 11:33:39 -0500 Subject: Create phosphor-dbus-monitor application Application is created allowing for a log_error action to be performed Change-Id: I6890fff7ace708e80c79607beceedc926c05ec3d Signed-off-by: Matthew Barth --- .gitignore | 1 + Makefile.am | 1 + bootstrap.sh | 18 ++++++++++++++++++ configure.ac | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/Makefile.am | 14 ++++++++++++++ src/main.cpp | 18 ++++++++++++++++++ src/monitor.cpp | 18 ++++++++++++++++++ src/monitor.hpp | 33 +++++++++++++++++++++++++++++++++ 8 files changed, 154 insertions(+) create mode 100644 Makefile.am create mode 100755 bootstrap.sh create mode 100644 configure.ac create mode 100644 src/Makefile.am create mode 100644 src/main.cpp create mode 100644 src/monitor.cpp create mode 100644 src/monitor.hpp diff --git a/.gitignore b/.gitignore index 09a8c5b..0bc0878 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ install-sh ltmain.sh missing stamp-h1 +phosphor-dbus-monitor diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 0000000..af437a6 --- /dev/null +++ b/Makefile.am @@ -0,0 +1 @@ +SUBDIRS = src diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..50b75b7 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +AUTOCONF_FILES="Makefile.in aclocal.m4 ar-lib autom4te.cache compile \ + config.guess config.h.in config.sub configure depcomp install-sh \ + ltmain.sh missing *libtool test-driver" + +case $1 in + clean) + test -f Makefile && make maintainer-clean + for file in ${AUTOCONF_FILES}; do + find -name "$file" | xargs -r rm -rf + done + exit 0 + ;; +esac + +autoreconf -i +echo 'Run "./configure ${CONFIGURE_FLAGS} && make"' diff --git a/configure.ac b/configure.ac new file mode 100644 index 0000000..816882c --- /dev/null +++ b/configure.ac @@ -0,0 +1,51 @@ +# Initialization +AC_PREREQ([2.69]) +AC_INIT([phosphor-dbus-monitor], [1.0], [https://github.com/openbmc/phosphor-dbus-monitor/issues]) +AC_LANG([C++]) +AC_CONFIG_HEADERS([config.h]) +AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign dist-xz]) +AM_SILENT_RULES([yes]) + +# Checks for programs. +AC_PROG_CXX +AM_PROG_AR +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PROG_AWK + +# Checks for libraries. +PKG_CHECK_MODULES([SDBUSPLUS], [sdbusplus],, AC_MSG_ERROR(["Requires sdbusplus package."])) +PKG_CHECK_MODULES([PHOSPHOR_DBUS_INTERFACES], [phosphor-dbus-interfaces],, AC_MSG_ERROR(["Requires phosphor-dbus-interfaces package."])) +PKG_CHECK_MODULES([PHOSPHOR_LOGGING], [phosphor-logging],, AC_MSG_ERROR(["Requires phosphor-logging."])) + +# Checks for typedefs, structures, and compiler characteristics. +AX_CXX_COMPILE_STDCXX_14([noext]) +AX_APPEND_COMPILE_FLAGS([-fpic -Wall -Werror], [CXXFLAGS]) + +# Checks for library functions. +LT_INIT + +# Check/set gtest specific functions. +AX_PTHREAD([GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=1"],[GTEST_CPPFLAGS="-DGTEST_HAS_PTHREAD=0"]) +AC_SUBST(GTEST_CPPFLAGS) + +AC_ARG_ENABLE([oe-sdk], + AS_HELP_STRING([--enable-oe-sdk], [Link testcases absolutely against OE SDK so they can be ran within it.]) +) +AC_ARG_VAR(OECORE_TARGET_SYSROOT, + [Path to the OE SDK SYSROOT]) +AS_IF([test "x$enable_oe_sdk" == "xyes"], + AS_IF([test "x$OECORE_TARGET_SYSROOT" == "x"], + AC_MSG_ERROR([OECORE_TARGET_SYSROOT must be set with --enable-oe-sdk]) + ) + AC_MSG_NOTICE([Enabling OE-SDK at $OECORE_TARGET_SYSROOT]) + [ + testcase_flags="-Wl,-rpath,\${OECORE_TARGET_SYSROOT}/lib" + testcase_flags="${testcase_flags} -Wl,-rpath,\${OECORE_TARGET_SYSROOT}/usr/lib" + testcase_flags="${testcase_flags} -Wl,-dynamic-linker,`find \${OECORE_TARGET_SYSROOT}/lib/ld-*.so | sort -r -n | head -n1`" + ] + AC_SUBST([OESDK_TESTCASE_FLAGS], [$testcase_flags]) +) + +AC_CONFIG_FILES([Makefile src/Makefile]) +AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 0000000..b9c857c --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,14 @@ +AM_DEFAULT_SOURCE_EXT = .cpp +AM_CPPFLAGS = -iquote ${top_srcdir} + +sbin_PROGRAMS = phosphor-dbus-monitor + +phosphor_dbus_monitor_SOURCES = \ + main.cpp \ + monitor.cpp +phosphor_dbus_monitor_LDADD = \ + $(SDBUSPLUS_LIBS) \ + $(PHOSPHOR_LOGGING_LIBS) +phosphor_dbus_monitor_CXXFLAGS = \ + $(SDBUSPLUS_CFLAGS) \ + $(PHOSPHOR_LOGGING_CFLAGS) diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6d1a071 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,18 @@ +#include +#include "monitor.hpp" + +int main(void) +{ + auto bus = sdbusplus::bus::new_default(); + + phosphor::dbus::monitoring::Monitor monitor(bus); + + // Keep application running + while (true) + { + bus.process_discard(); + bus.wait(); + } + + return -1; +} diff --git a/src/monitor.cpp b/src/monitor.cpp new file mode 100644 index 0000000..f734b00 --- /dev/null +++ b/src/monitor.cpp @@ -0,0 +1,18 @@ +#include "monitor.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +Monitor::Monitor(sdbusplus::bus::bus& bus) : + bus(bus) +{ + +} + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor diff --git a/src/monitor.hpp b/src/monitor.hpp new file mode 100644 index 0000000..2fc91b5 --- /dev/null +++ b/src/monitor.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include +#include +#include "events.hpp" + +namespace phosphor +{ +namespace dbus +{ +namespace monitoring +{ + +class Monitor +{ + public: + Monitor() = delete; + Monitor(const Monitor&) = delete; + Monitor(Monitor&&) = default; + Monitor& operator=(const Monitor&) = delete; + Monitor& operator=(Monitor&&) = default; + ~Monitor() = default; + + explicit Monitor(sdbusplus::bus::bus& bus); + + private: + sdbusplus::bus::bus& bus; + +}; + +} // namespace monitoring +} // namespace dbus +} // namespace phosphor -- cgit v1.2.1