Merge of vpd_manager meson script with repo meson

This commit merges meson script of vpd-manager app
into the meson script for openpower-vpd-parser repo.
vpd-manager needs to be build only if we are building
ibm-read-vpd exe.

To enable build of vpd-manager the flag needs to
be enabled.

Test Command:
meson -Dibm-parser=enabled -Dvpd-manager=enabled builddir
ninja -C builddir

Signed-off-by: Sunny Srivastava <sunnsr25@in.ibm.com>
Change-Id: Ib9c8229e54c37c55654b070adb3df616d105af23
diff --git a/const.hpp b/const.hpp
index 13d61af..3d631ee 100644
--- a/const.hpp
+++ b/const.hpp
@@ -44,10 +44,6 @@
 constexpr uint8_t KW_VAL_PAIR_START_TAG = 0x84;
 constexpr uint8_t RECORD_END_TAG = 0x78;
 
-static constexpr auto service = "xyz.openbmc_project.Inventory.Manager";
-static constexpr auto VPD_OBJ_PATH_PREFIX = "/xyz/openbmc_project/inventory";
-static constexpr auto COM_INTERFACE_PREFIX = "com.ibm.ipzvpd";
-
 namespace lengths
 {
 enum Lengths
diff --git a/meson.build b/meson.build
index 8dfed27..ce2830a 100644
--- a/meson.build
+++ b/meson.build
@@ -23,8 +23,11 @@
                        configuration :{
                        'INVENTORY_JSON': '"'+get_option('INVENTORY_JSON')+'"',
                        'INVENTORY_PATH': '"'+get_option('INVENTORY_PATH')+'"',
+		       'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"',
 		       'INVENTORY_MANAGER_SERVICE': '"'+get_option('INVENTORY_MANAGER_SERVICE')+'"',
-		       'IPZ_INTERFACE': '"'+get_option('IPZ_INTERFACE')+'"'
+                       'BUSNAME' : '"' + get_option('BUSNAME') + '"',
+                       'OBJPATH' : '"' + get_option('OBJPATH') + '"',
+                       'IFACE' : '"' + get_option('IFACE') + '"',
                        }
   )
         ibm_read_vpd_SOURCES = ['ibm_vpd_app.cpp',
@@ -60,6 +63,10 @@
                                    ],
                                  install: true,
                                  )
+if get_option('vpd-manager').enabled()
+    subdir('vpd-manager')
+endif
+
 else
         FRUGEN = '$srcdir/extra-properties.py -e' + get_option('FRU_YAML')
         PROPGEN = '$srcdir/extra-properties.py -e' + get_option('PROP_YAML')
diff --git a/meson_options.txt b/meson_options.txt
index b3e2a34..c08c94a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,4 +6,8 @@
 option('INVENTORY_JSON',type: 'string', value: '/usr/share/vpd/vpd_inventory.json',  description: 'JSON file that defines inventory blueprint')
 option('INVENTORY_PATH',type: 'string', value: '/xyz/openbmc_project/inventory', description: 'Prefix for inventory D-Bus objects')
 option('INVENTORY_MANAGER_SERVICE',type: 'string', value: 'xyz.openbmc_project.Inventory.Manager', description: 'Inventory manager service')
-option('IPZ_INTERFACE', type: 'string', value: 'com.ibm.ipzvpd', description: 'IPZ vpd interface')
+option('IPZ_INTERFACE', type: 'string', value: 'com.ibm.ipzvpd', description: 'IPZ VPD interface')
+option('BUSNAME', type : 'string', value : 'com.ibm.VPD.Manager',description : 'BUS NAME FOR THE SERVICE')
+option('OBJPATH', type : 'string', value : '/com/ibm/VPD/Manager', description : 'OBJECT PATH FOT THE SERVICE')
+option('IFACE', type : 'string', value : 'com.ibm.VPD.Manager', description : 'INTERFACE NAME')
+option('vpd-manager', type: 'feature', description: 'ENABLE VPD-MANAGERR APPLICATION')
diff --git a/vpd-manager/editor_impl.cpp b/vpd-manager/editor_impl.cpp
index c9e9847..70eb453 100644
--- a/vpd-manager/editor_impl.cpp
+++ b/vpd-manager/editor_impl.cpp
@@ -1,3 +1,5 @@
+#include "config.h"
+
 #include "editor_impl.hpp"
 
 #include "parser.hpp"
@@ -253,8 +255,9 @@
                               const std::variant<T>& data)
 {
     auto bus = sdbusplus::bus::new_default();
-    auto properties = bus.new_method_call(
-        service, object.c_str(), "org.freedesktop.DBus.Properties", "Set");
+    auto properties =
+        bus.new_method_call(INVENTORY_MANAGER_SERVICE, object.c_str(),
+                            "org.freedesktop.DBus.Properties", "Set");
     properties.append(interface);
     properties.append(property);
     properties.append(data);
@@ -284,9 +287,9 @@
                     std::string kwdData(thisRecord.kwdUpdatedData.begin(),
                                         thisRecord.kwdUpdatedData.end());
 
-                    makeDbusCall<std::string>(
-                        (VPD_OBJ_PATH_PREFIX + objectPath),
-                        commonInterface.key(), ciPropertyList.key(), kwdData);
+                    makeDbusCall<std::string>((INVENTORY_PATH + objectPath),
+                                              commonInterface.key(),
+                                              ciPropertyList.key(), kwdData);
                 }
             }
         }
@@ -313,8 +316,8 @@
                         std::string kwdData(thisRecord.kwdUpdatedData.begin(),
                                             thisRecord.kwdUpdatedData.end());
                         makeDbusCall<std::string>(
-                            (VPD_OBJ_PATH_PREFIX + objPath),
-                            extraInterface.key(), eiPropertyList.key(),
+                            (INVENTORY_PATH + objPath), extraInterface.key(),
+                            eiPropertyList.key(),
                             encodeKeyword(kwdData, eiPropertyList.value().value(
                                                        "encoding", "")));
                     }
@@ -344,9 +347,9 @@
         {
             // update com interface
             makeDbusCall<Binary>(
-                (VPD_OBJ_PATH_PREFIX +
+                (INVENTORY_PATH +
                  singleInventory["inventoryPath"].get<std::string>()),
-                (COM_INTERFACE_PREFIX + (std::string) "." + thisRecord.recName),
+                (IPZ_INTERFACE + (std::string) "." + thisRecord.recName),
                 thisRecord.recKWd, thisRecord.kwdUpdatedData);
 
             // process Common interface
diff --git a/vpd-manager/meson.build b/vpd-manager/meson.build
index da736d7..44b34aa 100644
--- a/vpd-manager/meson.build
+++ b/vpd-manager/meson.build
@@ -1,25 +1,6 @@
-project('vpd-manager',
-        'cpp',
-        'c',
-        default_options : ['cpp_std=c++17'],
-        version : '1.0')
-sdbusplus = dependency('sdbusplus')
-phosphor_logging = dependency('phosphor-logging')
 systemd = dependency('libsystemd', version : '>= 221')
 phosphor_dbus_interfaces = dependency('phosphor-dbus-interfaces')
 
-compiler = meson.get_compiler('cpp')
-compiler.has_header('nlohmann/json.hpp')
-
-configure_file( output: 'config.h',
-                        configuration: {
-                        'BUSNAME' : '"' + get_option('BUSNAME') + '"',
-                        'OBJPATH' : '"' + get_option('OBJPATH') + '"',
-                        'IFACE' : '"' + get_option('IFACE') + '"',
-                        'INVENTORY_JSON' : '"' + get_option('INVENTORY_JSON') + '"'
-                        }
-                )
-
 configuration_inc = include_directories('.', '../')
 
 vpd_manager_SOURCES =[
@@ -31,16 +12,20 @@
                         '../impl.cpp',
                         '../parser.cpp',
                         '../utils.cpp',
-                        '../vpdecc/vpdecc.c'
+                        '../vpdecc/vpdecc.c',
+                        '../vpdecc/vpdecc_support.c'
                         ]
 
+vpd_manager_dependencies =[sdbusplus,
+                           phosphor_logging,
+                           systemd,
+                           phosphor_dbus_interfaces,
+                          ]
+
 vpd_manager_exe = executable('vpd-manager',
-                                 vpd_manager_SOURCES,
-                                 include_directories : configuration_inc,
-                                 dependencies :[
-                                                 sdbusplus,
-                                                 phosphor_logging,
-                                                 systemd,
-                                                 phosphor_dbus_interfaces,
-                                             ],
-                              )
+                              vpd_manager_SOURCES,
+                              include_directories : configuration_inc,
+                              dependencies :[vpd_manager_dependencies,
+                                            ],
+                              install: true
+                            )