/
build_vsfilter.sh
97 lines (85 loc) · 2.44 KB
/
build_vsfilter.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
function Usage()
{
echo "Usage:"
echo -e "\t$1 [-conf "'"Release"|"Debug"'"] [-plat platform "'"Win32"|"x64"'"] [-action build|clean|rebuild] [-proj project] [-voff|--versioning-off] [-solution sln_file]"
echo "Default:"
echo -e '-conf\t\t"Release"'
echo -e '-plat\t\t"Win32"'
echo -e '-action\t\tbuild'
echo -e '-project\tvsfilter_2010'
echo -e '-solution\tsrc/filters/transform/vsfilter/VSFilter_vs2010.sln'
}
script_dir=`dirname $0`
cd $script_dir
solution="src/filters/transform/vsfilter/VSFilter_vs2010.sln"
action="build"
configuration="Release"
platform="Win32"
project="vsfilter_2010"
update_version=1
while [ "$1"x != ""x ]
do
if [ "$flag"x == ""x ]; then
if [ "$1"x == "-conf"x ]; then
flag="configuration"
elif [ "$1"x == "-plat"x ]; then
flag="platform"
elif [ "$1"x == "-action"x ]; then
flag="action"
elif [ "$1"x == "-proj"x ]; then
flag="project"
elif [ "$1"x == "-solution"x ]; then
flag="solution"
elif [ "$1"x == "--versioning-off"x ] || [ "$1"x == "-voff"x ]; then
update_version=0
flag=""
else
echo "Invalid arguments"
Usage $0
exit -1
fi
else
if [ "${1:0:1}"x == "-"x ]; then
echo "Invalid arguments"
Usage $0
exit -1
fi
eval $flag='"'$1'"'
flag=""
fi
shift
done
if [ "$flag"x != ""x ]; then
echo "Invalid arguments"
Usage $0
exit -1
fi
if [ "$update_version"x == "1"x ]; then
echo "Updating version info"
#update version info
cur_rev_num=`git rev-list HEAD | wc -l | awk '{print $1}'`
base_rev_num=`git rev-list 3.0.0.4 | wc -l | awk '{print $1}'`
((rev_num=$cur_rev_num-$base_rev_num+4))
rev_sha1=`git rev-parse HEAD`
rev_tag=`git describe --tag --abbrev=0`
ver_major=`echo $rev_tag | awk -F$'.' '{print $1}'`
ver_minor=`echo $rev_tag | awk -F$'.' '{print $2}'`
ver_patch=`echo $rev_tag | awk -F$'.' '{print $3}'`
echo "#define XY_VSFILTER_VERSION_MAJOR $ver_major
#define XY_VSFILTER_VERSION_MINOR $ver_minor
#define XY_VSFILTER_VERSION_PATCH $ver_patch
#define XY_VSFILTER_VERSION_COMMIT $rev_num
#define XY_VSFILTER_VERSION_COMMIT_SHA1 \"$rev_sha1\"" > src/filters/transform/vsfilter/version_in.h
fi
platform_type="x86"
if [ "$platform"x = "x64"x ]; then
platform_type="x86_amd64"
fi
configuration=$configuration"|"$platform
#build
echo '
CALL "%VS100COMNTOOLS%../../VC/vcvarsall.bat" '$platform_type'
devenv "'$solution'" /'$action' "'$configuration'" /project "'$project'"
exit
' | cmd