2012-08-19 23:05:38 +02:00
|
|
|
srcdir="$1"
|
|
|
|
|
|
|
|
# If no git repo try to read from the existing git_version.h, for building from tarballs
|
|
|
|
if ! test -d "${srcdir}/.git"; then
|
2014-03-11 17:42:59 +01:00
|
|
|
version_h_path="${srcdir}/build/git_version.h"
|
2012-08-19 23:05:38 +02:00
|
|
|
if test -f "${version_h_path}"; then
|
|
|
|
while read line; do
|
|
|
|
set -- $line
|
|
|
|
export $2=$(echo $3 | sed 's/"//g')
|
|
|
|
done < "${version_h_path}"
|
|
|
|
if test x$BUILD_GIT_VERSION_NUMBER != x -a x$BUILD_GIT_VERSION_STRING != x; then
|
|
|
|
export VERSION_SOURCE="from cached git_version.h"
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
echo "invalid git_version.h"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "git repo not found and no cached git_version.h"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
last_svn_revision=6962
|
2012-08-27 04:19:44 +02:00
|
|
|
last_svn_hash="16cd907fe7482cb54a7374cd28b8501f138116be"
|
2012-08-19 23:05:38 +02:00
|
|
|
|
|
|
|
git_revision=$(expr $last_svn_revision + $(git log --pretty=oneline $last_svn_hash..HEAD 2>/dev/null | wc -l))
|
2012-08-19 23:33:50 +02:00
|
|
|
git_version_str=$(git describe --exact-match 2> /dev/null)
|
2014-05-06 17:05:06 +02:00
|
|
|
installer_version='0.0.0'
|
2014-05-15 17:17:45 +02:00
|
|
|
resource_version='0, 0, 0'
|
2012-08-19 23:33:50 +02:00
|
|
|
if test x$git_version_str != x; then
|
|
|
|
git_version_str="${git_version_str##v}"
|
|
|
|
tagged_release=1
|
2014-05-06 17:05:06 +02:00
|
|
|
if [ $(echo $git_version_str | grep '\d\.\d\.\d') ]; then
|
|
|
|
installer_version=$git_version_str
|
2014-05-15 17:17:45 +02:00
|
|
|
resource_version=$(echo $git_version_str | sed 's/\./, /g')
|
2014-05-06 17:05:06 +02:00
|
|
|
fi
|
2012-08-19 23:33:50 +02:00
|
|
|
else
|
|
|
|
git_branch="$(git symbolic-ref HEAD 2> /dev/null)" || git_branch="(unnamed branch)"
|
|
|
|
git_branch="${git_branch##refs/heads/}"
|
|
|
|
git_hash=$(git rev-parse --short HEAD)
|
|
|
|
|
|
|
|
git_version_str="${git_revision}-${git_branch}-${git_hash}"
|
|
|
|
tagged_release=0
|
|
|
|
fi
|
2012-08-19 23:05:38 +02:00
|
|
|
|
2014-05-06 17:05:06 +02:00
|
|
|
|
2012-08-19 23:05:38 +02:00
|
|
|
new_version_h="\
|
|
|
|
#define BUILD_GIT_VERSION_NUMBER ${git_revision}
|
2012-08-19 23:33:50 +02:00
|
|
|
#define BUILD_GIT_VERSION_STRING \"${git_version_str}\"
|
2014-05-06 17:05:06 +02:00
|
|
|
#define TAGGED_RELEASE ${tagged_release}
|
2014-05-15 17:17:45 +02:00
|
|
|
#define INSTALLER_VERSION \"${installer_version}\"
|
|
|
|
#define RESOURCE_BASE_VERSION ${resource_version}"
|
2012-08-19 23:05:38 +02:00
|
|
|
|
|
|
|
# may not exist yet for out of tree builds
|
|
|
|
mkdir -p build
|
|
|
|
version_h_path="build/git_version.h"
|
|
|
|
|
|
|
|
# Write it only if it's changed to avoid spurious rebuilds
|
|
|
|
# This bizzare comparison method is due to that newlines in shell variables are very exciting
|
|
|
|
case "$(cat ${version_h_path} 2> /dev/null)"
|
|
|
|
in
|
|
|
|
"${new_version_h}");;
|
|
|
|
*) echo "${new_version_h}" > "${version_h_path}"
|
|
|
|
esac
|
|
|
|
|
|
|
|
export BUILD_GIT_VERSION_NUMBER="${git_revision}"
|
|
|
|
export BUILD_GIT_VERSION_STRING="${git_version_str}"
|
|
|
|
export VERSION_SOURCE="from git"
|
2012-11-22 18:57:59 +01:00
|
|
|
|
|
|
|
cat << EOF > build/git_version.xml
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
|
|
<PropertyGroup>
|
|
|
|
<GitVersionNumber>${git_revision}</GitVersionNumber>
|
|
|
|
<GitVersionString>${git_version_str}</GitVersionString>
|
|
|
|
</PropertyGroup>
|
|
|
|
</Project>
|
|
|
|
EOF
|