2015-04-04 16:44:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-01-21 09:04:59 +00:00
|
|
|
CODEROOT=$1
|
|
|
|
|
|
|
|
if [ -z "$CODEROOT" ]
|
|
|
|
then
|
|
|
|
CODEROOT=../../code
|
|
|
|
fi
|
2015-04-04 16:44:26 +00:00
|
|
|
|
|
|
|
VERSION_FILE=$CODEROOT/CMakeLists.txt
|
|
|
|
|
|
|
|
if [ ! -f $VERSION_FILE ]
|
|
|
|
then
|
|
|
|
echo "Unable to find $VERSION_FILE"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
parse_version()
|
|
|
|
{
|
2016-01-21 09:04:59 +00:00
|
|
|
PREFIX=$1
|
|
|
|
FILE=$2
|
|
|
|
VAR=$3
|
2015-04-04 16:44:26 +00:00
|
|
|
|
2016-01-21 09:04:59 +00:00
|
|
|
V=$(egrep -o $PREFIX"_$VAR [0-9]+" $FILE | awk '{print $2}' | head -n 1)
|
2015-04-04 16:44:26 +00:00
|
|
|
|
|
|
|
if [ -z "$V" ]
|
|
|
|
then
|
|
|
|
echo "Can't parse $VAR from $FILE, aborting..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
export $VAR=$V
|
|
|
|
}
|
|
|
|
|
2016-01-21 09:04:59 +00:00
|
|
|
parse_version NL $VERSION_FILE VERSION_MAJOR
|
|
|
|
parse_version NL $VERSION_FILE VERSION_MINOR
|
|
|
|
parse_version NL $VERSION_FILE VERSION_PATCH
|
2015-04-04 16:44:26 +00:00
|
|
|
|
|
|
|
VERSION=$VERSION_MAJOR.$VERSION_MINOR.$VERSION_PATCH
|
|
|
|
|
|
|
|
echo $VERSION
|
|
|
|
|
|
|
|
exit 0
|