Attn: Add build info to binary

Build information will be generated and embedded into the binary. This
info will be displayed in the help text when you execute the binary
without any command line options. This change has a libhei dependency.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I8caf1694f5b656557aa862eefb77b88d0b892d41
diff --git a/analyzer/analyzer_main.cpp b/analyzer/analyzer_main.cpp
index c616f7e..e5be60d 100644
--- a/analyzer/analyzer_main.cpp
+++ b/analyzer/analyzer_main.cpp
@@ -190,4 +190,16 @@
     return attnFound;
 }
 
+//------------------------------------------------------------------------------
+
+/**
+ * @brief Get error isolator build information
+ *
+ * @return Pointer to build information
+ */
+const char* getBuildInfo()
+{
+    return libhei::getBuildInfo();
+}
+
 } // namespace analyzer
diff --git a/analyzer/analyzer_main.hpp b/analyzer/analyzer_main.hpp
index dddf0f9..e0c9f47 100644
--- a/analyzer/analyzer_main.hpp
+++ b/analyzer/analyzer_main.hpp
@@ -21,4 +21,11 @@
  */
 bool analyzeHardware();
 
+/**
+ * @brief Get error analyzer build information
+ *
+ * @return Pointer to build information
+ */
+const char* getBuildInfo();
+
 } // namespace analyzer
diff --git a/buildinfo.hpp.in b/buildinfo.hpp.in
new file mode 100644
index 0000000..63bf9f3
--- /dev/null
+++ b/buildinfo.hpp.in
@@ -0,0 +1,5 @@
+#pragma once
+
+// The build process use this file as a teplate to create a file used during
+// compilation. This allows for automatic updating of build information.
+#define BUILDINFO "@BUILDINFO@"
diff --git a/main_nl.cpp b/main_nl.cpp
index b9c168e..3510e8a 100644
--- a/main_nl.cpp
+++ b/main_nl.cpp
@@ -5,6 +5,7 @@
 #include <attn/attn_config.hpp>
 #include <attn/attn_handler.hpp>
 #include <attn/attn_main.hpp>
+#include <buildinfo.hpp>
 #include <cli.hpp>
 
 /**
@@ -31,6 +32,7 @@
         printf("options:\n");
         printf("  --analyze:              Analyze the hardware\n");
         printf("  --daemon:               Start the attn handler daemon\n");
+        printf("hwdiag: %s, hei: %s\n", BUILDINFO, analyzer::getBuildInfo());
     }
     else
     {
diff --git a/meson.build b/meson.build
index 1928783..f2dc48f 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,15 @@
         ])
 
 #-------------------------------------------------------------------------------
+# Versioning
+#-------------------------------------------------------------------------------
+buildinfo = vcs_tag(command: ['git', 'describe', '--always', '--long'],
+                  input: 'buildinfo.hpp.in',
+                  output: 'buildinfo.hpp',
+                  replace_string:'@BUILDINFO@',
+                  fallback: '0')
+
+#-------------------------------------------------------------------------------
 # Compiler
 #-------------------------------------------------------------------------------