[Beignet] [PATCH] build beignet with GIT_HAL1
Meng Mengmeng
mengmeng.meng at intel.com
Wed Oct 22 15:27:08 PDT 2014
From: Meng <mengmeng.meng at intel.com>
---
src/CMakeLists.txt | 8 ++++++++
src/cl_platform_id.h | 5 +++--
src/git_sha1.sh | 13 +++++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
create mode 100644 src/git_sha1.sh
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 218420a..0e5969b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -109,6 +109,14 @@ 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 61b8eab..e40d3a9 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)
@@ -64,8 +65,8 @@ extern cl_int cl_get_platform_info(cl_platform_id platform,
#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 ")"
+#define LIBCL_C_VERSION_STRING "OpenCL C " _JOINT(LIBCL_C_VERSION_MAJOR, LIBCL_C_VERSION_MINOR) " beignet " LIBCL_DRIVER_VERSION_STRING " (" BEIGNET_GIT_SHA1 ")"
#endif /* __CL_PLATFORM_ID_H__ */
diff --git a/src/git_sha1.sh b/src/git_sha1.sh
new file mode 100644
index 0000000..ef6dd66
--- /dev/null
+++ b/src/git_sha1.sh
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+SOURCE_DIR=$1
+FILE=$2
+touch ${SOURCE_DIR}/${FILE}
+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} ; \
+ fi \
+fi
+
--
1.9.3
More information about the Beignet
mailing list