forked from uavs3/uavs3d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
version.sh
executable file
·61 lines (54 loc) · 2.96 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
58
59
60
61
#!/bin/bash
# ============================================================================
# File:
# version.sh
# - get version of repository and generate the file version.h
# ============================================================================
# get version of remote and local repository
shell_dir=""
if [ ! -n "$1" ]; then
shell_dir="."
else
shell_dir=$1
fi
VER_R=`git rev-list origin/master | sort | wc -l | awk '{print $1}'`
VER_L=`git rev-list HEAD | sort | wc -l | awk '{print $1}'`
VER_SHA1=`git log -n 1 | head -n 1 | cut -d ' ' -f 2`
major_version="1"
minor_version="2"
type_version="release"
# generate the file version.h
echo "// ===========================================================================" > $shell_dir/version.h
echo "// version.h" >> $shell_dir/version.h
echo "// - collection of version numbers" >> $shell_dir/version.h
echo "// ===========================================================================" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#ifndef __VERSION_H__" >> $shell_dir/version.h
echo "#define __VERSION_H__" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#define VER_MAJOR $major_version // major version number" >> $shell_dir/version.h
echo "#define VER_MINOR $minor_version // minor version number" >> $shell_dir/version.h
echo "#define VER_BUILD $VER_L // build number" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#define VERSION_TYPE \"$type_version\"" >> $shell_dir/version.h
echo "#define VERSION_STR \"$major_version.$minor_version.$VER_L\"" >> $shell_dir/version.h
echo "#define VERSION_SHA1 \"$VER_SHA1\"" >> $shell_dir/version.h
echo "" >> $shell_dir/version.h
echo "#endif // __VERSION_H__" >> $shell_dir/version.h
# show version informations
echo " "
echo " GIT VERSION TOOLS"
echo " ====================="
echo " "
echo " get the code version number of remote & local repository."
echo " "
echo " remote: $VER_R"
echo " local: $VER_L"
echo " SHA-1: $VER_SHA1"
echo " "
echo " remote version $VER_L is added to file version.h, such as:"
echo " "
echo " #define VER_BUILD $VER_L"
echo " "
echo " #define VERSION_SHA1 $VER_SHA1"
echo " "