diff mbox

linux-generic/odp_impl: add implementation version details

Message ID 1430945559-4596-1-git-send-email-mike.holmes@linaro.org
State Superseded
Headers show

Commit Message

Mike Holmes May 6, 2015, 8:52 p.m. UTC
Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
---
 configure.ac                      |  1 +
 platform/Makefile.inc             |  3 +++
 platform/linux-generic/odp_impl.c | 14 ++++++++++++--
 scripts/git_hash.sh               |  9 +++++++++
 4 files changed, 25 insertions(+), 2 deletions(-)
 create mode 100755 scripts/git_hash.sh
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index d20bad2..9038761 100644
--- a/configure.ac
+++ b/configure.ac
@@ -262,6 +262,7 @@  ODP_CFLAGS="$ODP_CFLAGS -Wmissing-declarations -Wold-style-definition -Wpointer-
 ODP_CFLAGS="$ODP_CFLAGS -Wcast-align -Wnested-externs -Wcast-qual -Wformat-nonliteral"
 ODP_CFLAGS="$ODP_CFLAGS -Wformat-security -Wundef -Wwrite-strings"
 ODP_CFLAGS="$ODP_CFLAGS -std=c99"
+ODP_CFLAGS="$ODP_CFLAGS -DPLATFORM=${with_platform}"
 
 ##########################################################################
 # Default include setup
diff --git a/platform/Makefile.inc b/platform/Makefile.inc
index 9e73fc4..b05c2bc 100644
--- a/platform/Makefile.inc
+++ b/platform/Makefile.inc
@@ -11,3 +11,6 @@  VPATH = $(srcdir) $(builddir)
 lib_LTLIBRARIES = $(LIB)/libodp.la
 
 AM_LDFLAGS += -version-number '$(ODP_LIBSO_VERSION)'
+
+GIT_DESC !=$(top_builddir)/scripts/git_hash.sh
+AM_CFLAGS += "-DGIT_HASH=$(GIT_DESC)"
diff --git a/platform/linux-generic/odp_impl.c b/platform/linux-generic/odp_impl.c
index ca3224d..46d0e40 100644
--- a/platform/linux-generic/odp_impl.c
+++ b/platform/linux-generic/odp_impl.c
@@ -20,8 +20,18 @@  extern "C" {
 
 #include <odp/version.h>
 
-#define  ODP_VERSION_IMPL 0
-#define  ODP_VERSION_IMPL_STR ODP_VERSION_TO_STR(ODP_VERSION_IMPL)
+#define ODP_VERSION_IMPL 0
+#define ODP_VERSION_IMPL_STR \
+	ODP_VERSION_TO_STR(PLATFORM) " " \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) "." \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) "." \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR) "-" \
+	ODP_VERSION_TO_STR(ODP_VERSION_IMPL) " (v" \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) "." \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) "." \
+	ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR) ") " \
+	__DATE__ " " __TIME__ " " \
+	ODP_VERSION_TO_STR(GIT_HASH)
 
 const char *odp_version_impl_str(void)
 {
diff --git a/scripts/git_hash.sh b/scripts/git_hash.sh
new file mode 100755
index 0000000..c9f1faf
--- /dev/null
+++ b/scripts/git_hash.sh
@@ -0,0 +1,9 @@ 
+#!/bin/bash
+
+repo=https://git.linaro.org/lng/odp.git
+hash=$(git describe | tr -d "\n")
+if git diff-index --name-only HEAD &>/dev/null ; then
+	dirty=-dirty
+fi
+
+echo -n "'${repo}' (${hash}${dirty})"