forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·57 lines (47 loc) · 1.46 KB
/
version.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# 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
# get version from git tag
GIT_TAG=`git describe --abbrev=4 2>/dev/null`
# may fail to get git describe in some case, add this fallback to handle error
if [[ "x$GIT_TAG" == "x" ]]
then
GIT_TAG="v0.0-0-g0000"
fi
# 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.
if [ $(expr match $GIT_TAG 'SOF_FW_[A-Z]+_' ) -lt 15 ]; then
VER=`echo $GIT_TAG | cut -d_ -f4`
else
VER=$GIT_TAG
fi
# create git version if we are a git repo or git worktree
if [ -e $DIR/.git -o -d $DIR/.git ]; then
# version for make dist
echo $VER > $DIR/.version
echo $VER > $DIR/.tarball-version
# git commit for IPC
echo "#define SOF_TAG \"`git log --pretty=format:\"%h\" -1 | cut -c1-5`\"" > $DIR/src/include/version.h
else
echo "#define SOF_TAG \"0\"" > $DIR/src/include/version.h
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
echo "#define SOF_BUILD $num" >> $DIR/src/include/version.h
#echo version for AC_INIT
if [ -e $DIR/.version ]; then
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`
fi