Add associations::Manager class
This class will handle creating the org.openbmc.Associations
D-Bus interfaces on inventory paths if it has been told to
by a JSON configuration file.
Every time PIM creates a new inventory path, this class will
check to see if any associations need to be created.
This functionality is optional, and is off by default. To
enable it, the --enable-associations configure option needs to
be used.
This commit just introduces the class.
Change-Id: I70045b768f3db683bcfac0c7d4bc9798eb10a5c5
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/configure.ac b/configure.ac
index 482fa5b..e159549 100644
--- a/configure.ac
+++ b/configure.ac
@@ -90,6 +90,28 @@
AC_DEFINE_UNQUOTED([PIM_PERSIST_PATH], ["$PIM_PERSIST_PATH"], \
[Path of directory housing persisted inventory])
+AC_ARG_ENABLE([associations],
+ AS_HELP_STRING([--enable-associations], [Enable creating D-Bus associations from a JSON definition.])
+)
+
+AC_ARG_VAR(CREATE_ASSOCIATIONS, [If associations should be created from a JSON definition.])
+
+AS_IF([test "x$enable_associations" == "xyes"],
+ [CREATE_ASSOCIATIONS="yes"]
+ AC_DEFINE_UNQUOTED([CREATE_ASSOCIATIONS], ["$CREATE_ASSOCIATIONS"],
+ [If associations should be created from a JSON definition.])
+ AC_CHECK_HEADER(nlohmann/json.hpp, ,
+ [AC_MSG_ERROR([Could not find nlohmann/json.hpp... nlohmann/json package required])])
+)
+
+AM_CONDITIONAL([CREATE_INV_ASSOCIATIONS], [test "x$enable_associations" == "xyes"])
+
+AC_ARG_VAR(ASSOCIATIONS_FILE_PATH, [Path of associations JSON file.])
+AS_IF([test "x$ASSOCIATIONS_FILE_PATH" == "x"], \
+ [ASSOCIATIONS_FILE_PATH="/usr/share/phosphor-inventory-manager/associations.json"])
+AC_DEFINE_UNQUOTED([ASSOCIATIONS_FILE_PATH], ["$ASSOCIATIONS_FILE_PATH"], \
+ [Path of associations JSON file])
+
AC_ARG_VAR(CLASS_VERSION, [Class version to register with Cereal])
AS_IF([test "x$CLASS_VERSION" == "x"], [CLASS_VERSION=1])
AC_DEFINE_UNQUOTED([CLASS_VERSION], [$CLASS_VERSION], [Class version to register with Cereal])