2018-08-09 11:45:43 +08:00
|
|
|
#!/bin/bash
|
2018-01-11 01:36:41 +08:00
|
|
|
|
|
|
|
# version for configure, make dist and FW etc
|
|
|
|
# usage "version.sh dir"
|
|
|
|
# Where dir is the top level directory path.
|
|
|
|
|
|
|
|
# use pwd is no path argument is given
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
DIR=`pwd`
|
|
|
|
else
|
|
|
|
DIR=$1
|
|
|
|
fi
|
|
|
|
|
2018-03-21 17:42:02 +08:00
|
|
|
# get version from git tag
|
2018-08-09 11:45:43 +08:00
|
|
|
GIT_TAG=`git describe --abbrev=4 2>/dev/null`
|
|
|
|
|
|
|
|
# may fail to get git describe in some case, add this fallback to handle error
|
2018-11-22 01:15:14 +08:00
|
|
|
if [[ "x$GIT_TAG" == "x" ]]
|
|
|
|
then
|
|
|
|
GIT_TAG="v0.0-0-g0000"
|
2018-08-09 11:45:43 +08:00
|
|
|
fi
|
2018-03-21 17:42:02 +08:00
|
|
|
|
|
|
|
# Some releases have a SOF_FW_XXX_ prefix on the tag and this prefix
|
|
|
|
# must be stripped for usage in version.h. i.e. we just need the number.
|
2018-11-22 01:15:14 +08:00
|
|
|
if [ $(expr match $GIT_TAG 'SOF_FW_[A-Z]+_' ) -lt 15 ]; then
|
2018-03-21 17:42:02 +08:00
|
|
|
VER=`echo $GIT_TAG | cut -d_ -f4`
|
|
|
|
else
|
|
|
|
VER=$GIT_TAG
|
|
|
|
fi
|
|
|
|
|
2018-01-11 20:10:03 +08:00
|
|
|
# create git version if we are a git repo or git worktree
|
|
|
|
if [ -e $DIR/.git -o -d $DIR/.git ]; then
|
2018-01-11 01:36:41 +08:00
|
|
|
# version for make dist
|
2018-03-21 17:42:02 +08:00
|
|
|
echo $VER > $DIR/.version
|
|
|
|
echo $VER > $DIR/.tarball-version
|
2018-01-11 01:36:41 +08:00
|
|
|
|
|
|
|
# git commit for IPC
|
2018-04-05 07:46:50 +08:00
|
|
|
echo "#define SOF_TAG \"`git log --pretty=format:\"%h\" -1 | cut -c1-5`\"" > $DIR/src/include/version.h
|
2018-01-11 01:36:41 +08:00
|
|
|
else
|
2018-04-05 07:46:50 +08:00
|
|
|
echo "#define SOF_TAG \"0\"" > $DIR/src/include/version.h
|
2018-01-11 01:36:41 +08:00
|
|
|
fi
|
|
|
|
|
|
|
|
# build counter
|
|
|
|
if [ -e $DIR/.build ]; then
|
|
|
|
num=$((`cat $DIR/.build` + 1))
|
|
|
|
else
|
|
|
|
num=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# save and insert build counter
|
|
|
|
echo $num > $DIR/.build
|
2018-04-05 07:46:50 +08:00
|
|
|
echo "#define SOF_BUILD $num" >> $DIR/src/include/version.h
|
2018-01-11 01:36:41 +08:00
|
|
|
|
|
|
|
#echo version for AC_INIT
|
|
|
|
if [ -e $DIR/.version ]; then
|
2018-01-11 04:26:08 +08:00
|
|
|
echo -n `cat $DIR/.version | cut -dv -f2 | cut -d. -f1`.`cat $DIR/.version | cut -d. -f2 | cut -d- -f1`.`cat $DIR/.version | cut -d. -f3 | cut -d- -f1`
|
2018-01-11 01:36:41 +08:00
|
|
|
fi
|