smbios-mdr: Add custom dbus object path
The patch adds a configurable meson option which when enabled,
customizes the dbus object path.
Earlier efforts where made to have similar functionality and
the some MRs for same were rejected for various reasons
[1] https://gerrit.openbmc.org/c/openbmc/smbios-mdr/+/46129
[2] https://gerrit.openbmc.org/c/openbmc/bmcweb/+/46739
[3] https://gerrit.openbmc.org/c/openbmc/entity-manager/+/44196
Tested:
1) Dbus tree output
```
/xyz/openbmc_project
|-/xyz/openbmc_project/inventory
|`-/xyz/openbmc_project/inventory/system
|`-/xyz/openbmc_project/inventory/system/chassis
||-/xyz/openbmc_project/inventory/system/chassis/Chassis_0
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot0
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot1
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot10
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot11
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot12
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot13
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot14
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot15
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot16
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot17
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot18
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot19
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot2
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot3
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot4
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot5
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot6
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot7
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot8
|||- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/pcieslot9
||`- /xyz/openbmc_project/inventory/system/chassis/Chassis_0/tpm0
```
Change-Id: I765e56a30c3e5712c2f43fc6a8302be5cc9d9a96
Signed-off-by: Prithvi Pai <ppai@nvidia.com>
diff --git a/include/smbios_mdrv2.hpp b/include/smbios_mdrv2.hpp
index c2f1b4b..848e41f 100644
--- a/include/smbios_mdrv2.hpp
+++ b/include/smbios_mdrv2.hpp
@@ -349,3 +349,18 @@
std::string result = target;
return result;
}
+
+static inline std::string getObjectPath(
+ const std::string& smbiosInventoryPath,
+ [[maybe_unused]] const std::string& motherboardPath,
+ const std::string& suffix, const unsigned int& index)
+{
+ std::string path = smbiosInventoryPath + suffix + std::to_string(index);
+#ifdef CUSTOM_DBUS_PATH
+ if (!motherboardPath.empty() && path.starts_with(defaultMotherboardPath))
+ {
+ path.replace(0, strlen(defaultMotherboardPath), motherboardPath);
+ }
+#endif
+ return path;
+}