get tag from git

This commit is contained in:
Pavel Kartavyy 2014-02-04 21:38:03 +04:00
parent fb8ffc9d96
commit 6b6b880bf0
2 changed files with 12 additions and 8 deletions

View File

@ -3,5 +3,5 @@
namespace Revision
{
unsigned get() { return SVN_REVISION; }
unsigned get() { return REVISION; }
}

View File

@ -1,14 +1,18 @@
#!/bin/bash
mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/src
echo "#ifndef SVN_REVISION" > ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h
echo -n "#define SVN_REVISION " >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h
echo "#ifndef REVISION" > ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h
echo -n "#define REVISION " >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h
cd ${CMAKE_CURRENT_SOURCE_DIR};
echo && (LC_ALL=C svn info ${PROJECT_SOURCE_DIR}/ 2>/dev/null || echo Revision 1) | grep Revision | cut -d " " -f 2 >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h;
echo -n "#define SVN_PATH " >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h
SVN_PATH="$( (LC_ALL=C svn info ${PROJECT_SOURCE_DIR}/ 2>/dev/null || echo URL: unknown) | grep URL | cut -d ' ' -f 2 | sed 's/https:\/\/.yandex-team.ru\/conv\///g')"
echo '"'$SVN_PATH'"' >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h;
git rev-parse --is-inside-work-tree &> /dev/null
if [ $? -eq 0 ]
then
# GIT
( git describe --tags || echo 1 ) | cut -d "-" -f 1 >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h;
else
#SVN
echo && (LC_ALL=C svn info ${PROJECT_SOURCE_DIR}/ 2>/dev/null || echo Revision 1) | grep Revision | cut -d " " -f 2 >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h;
fi
echo "#endif" >> ${CMAKE_CURRENT_BINARY_DIR}/src/revision.h