Thanks for the patch. One major comment is that you need to consider where .git does not exist. For example, build from a relased tar ball.
Then the BEIGNET_GIT_SHA1 is not defined, and please be careful don't add an empty "()" into the cl version string. beignet 0.9 (git-xxx) # with .git directory. beignet 0.9 # with out .git directory. beignet 0.9 () # incorrect version string. Thanks, Zhigang Gong. On Thu, Oct 23, 2014 at 06:27:08AM +0800, Meng Mengmeng wrote: > From: Meng <[email protected]> > > --- > 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 > > _______________________________________________ > Beignet mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/beignet _______________________________________________ Beignet mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/beignet
