Add build information to binary
Build information will be compiled into the binary. An associated
function was added to retrieve this information for displaying in
applications that consume this library.
Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: I68e467c714ea11c0f5639670396617bc0ff51334
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/meson.build b/meson.build
index 48834c1..02cd994 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')
+
+#-------------------------------------------------------------------------------
# libhei library
#-------------------------------------------------------------------------------
@@ -23,7 +32,7 @@
]
libhei_dep = declare_dependency(include_directories : incdir,
- sources : libhei_src)
+ sources : [libhei_src, buildinfo])
# build static library libhei.a (note that the libray name is hei, the
# resulting filename will be libhei.a)
diff --git a/src/hei_main.hpp b/src/hei_main.hpp
index 9c484fe..7135f50 100644
--- a/src/hei_main.hpp
+++ b/src/hei_main.hpp
@@ -91,4 +91,11 @@
*/
void isolate(const std::vector<Chip>& i_chipList, IsolationData& o_isoData);
+/**
+ * @brief Return build information string
+ *
+ * @return Build information string
+ */
+const char* getBuildInfo();
+
} // end namespace libhei
diff --git a/src/isolator/hei_isolator.cpp b/src/isolator/hei_isolator.cpp
index f431cb3..ef74b2e 100644
--- a/src/isolator/hei_isolator.cpp
+++ b/src/isolator/hei_isolator.cpp
@@ -1,4 +1,5 @@
+#include <buildinfo.hpp>
#include <isolator/hei_isolation_node.hpp>
#include <isolator/hei_isolator.hpp>
#include <register/hei_operator_register.hpp>
@@ -73,4 +74,9 @@
}
}
+const char* getBuildInfo()
+{
+ return BUILDINFO;
+}
+
} // end namespace libhei