Get PSU version from vendor specific tool

The code was getting the version from PSU inventory object.
This commit changes the behavior to use a vendor-specific tool to get
the version directly, where the tool is expected to be configured during
build time.

Add an example get_version app that shows the expected behavior of the
tool:
* It accepts an argument of PSU inventory object;
* It outputs the version to stdout.

Tested: 1. Put and configure to use the example get_version on witherspoon,
        verify that PSU software objects are created with the version
        returned by the exmaple tool.
        2. With the Witherspoon specific tool in
        https://gerrit.openbmc-project.xyz/c/openbmc/witherspoon-pfault-analysis/+/24811,
        verify the version is correctly got from the PSU inventory path
        and the software objects are created.

Signed-off-by: Lei YU <mine260309@gmail.com>
Change-Id: I5195cb6fc8998a76b09abcfe0b107364cb180c01
diff --git a/vendor-example/get_version.cpp b/vendor-example/get_version.cpp
new file mode 100644
index 0000000..c0e3033
--- /dev/null
+++ b/vendor-example/get_version.cpp
@@ -0,0 +1,25 @@
+#include <cstdio>
+#include <string>
+
+// Get the version string for a PSU and output to stdout
+// In this example, it just returns the last 8 bytes as the version
+constexpr int NUM_OF_BYTES = 8;
+
+int main(int argc, char** argv)
+{
+    if (argc != 2)
+    {
+        printf("Usage: %s <psu-inventory-path>\n", argv[0]);
+        return 1;
+    }
+
+    std::string psu = argv[1];
+    if (psu.size() < NUM_OF_BYTES)
+    {
+        psu.append(NUM_OF_BYTES - psu.size(), '0'); //"0", 8 - psu.size());
+    }
+
+    printf("%s", psu.substr(psu.size() - NUM_OF_BYTES).c_str());
+
+    return 0;
+}
diff --git a/vendor-example/meson.build b/vendor-example/meson.build
new file mode 100644
index 0000000..73e30c2
--- /dev/null
+++ b/vendor-example/meson.build
@@ -0,0 +1,26 @@
+oe_sdk = get_option('oe-sdk')
+if oe_sdk.enabled()
+  # Setup OE SYSROOT
+  OECORE_TARGET_SYSROOT = run_command('sh', '-c', 'echo $OECORE_TARGET_SYSROOT').stdout().strip()
+  if OECORE_TARGET_SYSROOT == ''
+      error('Unable to get $OECORE_TARGET_SYSROOT, check your environment.')
+  endif
+  message('OE_SYSROOT: ' + OECORE_TARGET_SYSROOT)
+  rpath = ':'.join([OECORE_TARGET_SYSROOT + '/lib', OECORE_TARGET_SYSROOT + '/usr/lib'])
+  ld_so = run_command('sh', '-c', 'find ' + OECORE_TARGET_SYSROOT + '/lib/ld-*.so | sort -r -n | head -n1').stdout().strip()
+  dynamic_linker = ['-Wl,-dynamic-linker,' + ld_so]
+else
+  dynamic_linker = []
+endif
+
+examples = [
+  'get_version',
+]
+
+foreach example : examples
+  executable(example, example + '.cpp',
+             implicit_include_directories: false,
+             link_args: dynamic_linker,
+             build_rpath: oe_sdk.enabled() ? rpath : '')
+endforeach
+