summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMeng Mengmeng <mengmeng.meng@intel.com>2014-10-23 09:09:21 +0800
committerZhigang Gong <zhigang.gong@intel.com>2014-10-23 09:44:01 +0800
commit1ea7977ee84df4c7607c82f0846307c63f8364df (patch)
treed3beead485d6e08d22e86b84f526cd1572742e66
parent5417a7e2afb3f2043dbb8abbaebca5115b87ab70 (diff)
add beignet GIT_HAL1 if there is .git directory
Reviewed-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/cl_platform_id.h10
-rwxr-xr-xsrc/git_sha1.sh20
3 files changed, 35 insertions, 2 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 218420a5..0d225897 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -109,6 +109,13 @@ SET(CMAKE_CXX_FLAGS "-DHAS_OCLIcd ${CMAKE_CXX_FLAGS}")
SET(CMAKE_C_FLAGS "-DHAS_OCLIcd ${CMAKE_C_FLAGS}")
endif (OCLIcd_FOUND)
+set(GIT_SHA1 "git_sha1.h")
+add_custom_command(OUTPUT ${GIT_SHA1}
+ COMMAND chmod +x ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.sh
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/git_sha1.sh ${CMAKE_CURRENT_SOURCE_DIR} ${GIT_SHA1}
+ )
+add_custom_target(GIT_SHA1 ALL DEPENDS ${GIT_SHA1})
+
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic,--allow-shlib-undefined")
link_directories (${LLVM_LIBRARY_DIR} ${DRM_LIBDIR})
diff --git a/src/cl_platform_id.h b/src/cl_platform_id.h
index 61b8eab5..a7a3e81e 100644
--- a/src/cl_platform_id.h
+++ b/src/cl_platform_id.h
@@ -25,6 +25,7 @@
#include "cl_extensions.h"
#include "cl_khr_icd.h"
#include "src/OCLConfig.h"
+#include "src/git_sha1.h"
struct _cl_platform_id {
DEFINE_ICD(dispatch)
@@ -62,10 +63,15 @@ extern cl_int cl_get_platform_info(cl_platform_id platform,
#define _JOINT(x, y) _STR(x) "." _STR(y)
#define _JOINT3(x, y, z) _STR(x) "." _STR(y) "." _STR(z)
+#ifdef BEIGNET_GIT_SHA1
+ #define BEIGNET_GIT_SHA1_STRING " (" BEIGNET_GIT_SHA1 ")"
+#else
+ #define BEIGNET_GIT_SHA1_STRING
+#endif
#define LIBCL_DRIVER_VERSION_STRING _JOINT(LIBCL_DRIVER_VERSION_MAJOR, LIBCL_DRIVER_VERSION_MINOR)
-#define LIBCL_VERSION_STRING "OpenCL " _JOINT(LIBCL_C_VERSION_MAJOR, LIBCL_C_VERSION_MINOR) " beignet " LIBCL_DRIVER_VERSION_STRING
-#define LIBCL_C_VERSION_STRING "OpenCL C " _JOINT(LIBCL_C_VERSION_MAJOR, LIBCL_C_VERSION_MINOR) " beignet " LIBCL_DRIVER_VERSION_STRING
+#define LIBCL_VERSION_STRING "OpenCL " _JOINT(LIBCL_C_VERSION_MAJOR, LIBCL_C_VERSION_MINOR) " beignet " LIBCL_DRIVER_VERSION_STRING BEIGNET_GIT_SHA1_STRING
+#define LIBCL_C_VERSION_STRING "OpenCL C " _JOINT(LIBCL_C_VERSION_MAJOR, LIBCL_C_VERSION_MINOR) " beignet " LIBCL_DRIVER_VERSION_STRING BEIGNET_GIT_SHA1_STRING
#endif /* __CL_PLATFORM_ID_H__ */
diff --git a/src/git_sha1.sh b/src/git_sha1.sh
new file mode 100755
index 00000000..4f6f972c
--- /dev/null
+++ b/src/git_sha1.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+SOURCE_DIR=$1
+FILE=$2
+
+touch ${SOURCE_DIR}/${FILE}_tmp
+if test -d $1/../.git; then
+ if which git > /dev/null; then
+ git --git-dir=$1/../.git log -n 1 --oneline | \
+ sed 's/^\([^ ]*\) .*/#define BEIGNET_GIT_SHA1 "git-\1"/' \
+ > ${SOURCE_DIR}/${FILE}_tmp
+ fi
+fi
+
+#updating ${SOURCE_DIR}/${FILE}
+if ! cmp -s ${SOURCE_DIR}/${FILE}_tmp ${SOURCE_DIR}/${FILE}; then
+ mv ${SOURCE_DIR}/${FILE}_tmp ${SOURCE_DIR}/${FILE}
+else
+ rm ${SOURCE_DIR}/${FILE}_tmp
+fi