-
Notifications
You must be signed in to change notification settings - Fork 63
/
dart.sh
executable file
·169 lines (151 loc) · 4.26 KB
/
dart.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/bin/bash
#
DARTURL=http:https://trueta.udg.edu/dart
DARTBOARD="Starviewer"
SITE=`hostname -f`
# Programes necessaris
CTEST=/usr/bin/ctest
QMAKE=/usr/bin/qmake
KWSTYLE=/usr/bin/KWStyle
# Important!!! Sinó ctest no parseja bé els warnings
export LC_ALL=en_US.UTF-8
export LANG=$LC_ALL
export LANGUAGE=$LC_ALL
ARG2=$2
# Funcions
Error() {
echo "Error: $1" >&2
echo >&2
exit $2
}
Usage() {
echo "$0: <tipus_build> [nom_build]" >&2
echo "Tipus de builds possibles:" >&2
echo " style Fa la validació d'estil de tot el codi" >&2
echo " style <fitxers> Fa la validació d'estil dels fitxers indicats" >&2
echo " KWStyle Test d'estil per al Dart" >&2
echo " Experimental Test de compilació al track Experimental" >&2
echo " Nightly Test de compilació diaria" >&2
echo " Continuous Test de compilació continua (recompilació a cada canvi al SVN" >&2
echo " config Generar fitxer de configuració" >&2
echo >&2
exit 1
}
# Verifica l'existència de programes necessaris i la seva versió
CheckRequired() {
[ ! -e $CTEST ] && CTEST=`which ctest`
[ ! -e $QMAKE ] && QMAKE=`which qmake`
[ ! -e $KWSTYLE ] && KWSTYLE=`which KWStyle`
[ -z "$CTEST" ] && Error "CTest not found" 2
[ -z "$QMAKE" ] && Error "QMake not found" 2
[ -z "$KWSTYLE" ] && Error "KWStyle not found" 2
# $QMAKE --version 2>&1 | grep "4.2" || Error "Qt version 4.2" 3
}
# Configura el Buildname amb la release de la distribució i compilador
SetBuildFromOS() {
#DISTRO=`cat /etc/issue | grep -v "^$" | sed 's%\\\\.%%g'`
DISTRO=`cat /etc/*release* | head -1`
GCCRELEASE=`gcc -dumpversion`
BUILDNAME="$DISTRO gcc $GCCRELEASE"
SetBuildFromUserArg
}
# Configura el Buildname amb la revisio SVN del codi
SetBuildFromSVN() {
if svn info &>/dev/null
then
SVN=`svn info | grep URL`
REVISION=`svn info|grep Revision|cut -f2 -d' '`
SVN=${SVN%%/starviewer}
SVN=${SVN##URL: https://trueta.udg.edu/repos/starviewer/}
# Check if tainted source
if [ `svn status src/ | grep "^M" | wc -l` -eq 0 ]
then
TAINTED=""
else
TAINTED="-T"
fi
BUILDNAME=${SVN}-${REVISION}${TAINTED}
fi
SetBuildFromUserArg
}
# Configura el buildname amb l'argument passat per l'usuari si existex
SetBuildFromUserArg() {
[ ! -z "$ARG2" ] && BUILDNAME=$ARG2
}
# Crea fitxer de configuració per fer submit al Dart
# (només necessari per a CTest)
CreateCTestConfig() {
# Per evitar problemes hem de fer 'strip' d'algunes barres
DARTURL=${DARTURL%%/}
DARTBOARD=${DARTBOARD%%/}
DARTBOARD=${DARTBOARD##/}
cat > CTestConfiguration.ini << _EOF_DART_CONFIG
SourceDirectory: .
BuildDirectory: .
Site: $SITE
BuildName: $BUILDNAME
DropMethod: xmlrpc
DropSite: $DARTURL
DropLocation: $DARTBOARD
NightlyStartTime: 00:00:00 CET
ConfigureCommand: qmake
MakeCommand: make
UpdateCommand: /usr/bin/svn
UpdateOptions:
UpdateType: svn
TimeOut: 1500
_EOF_DART_CONFIG
}
### MAIN SCRIPT
CheckRequired
case "$1" in
style)
shift
if [ -z "$1" ]
then
# Fem check complet
$KWSTYLE -xml kws.xml -html KWStyle -lesshtml -D kwsFiles.txt
else
# Fem check dels fitxers indicats com a paràmetres
for glob in $*
do
echo $glob
done > .inlineFiles.txt
$KWSTYLE -xml kws.xml -html KWStyle -lesshtml -D .inlineFiles.txt
rm -f .inlineFiles.txt
fi
;;
Continuous)
# Continuous Test
SetBuildFromOS
CreateCTestConfig
$CTEST -VV -S CTest.cmake,Continuous
;;
Nightly)
# Nightly Test
SetBuildFromOS
CreateCTestConfig
$CTEST -VV -S CTest.cmake,Nightly
;;
KWStyle)
# Style Test
SetBuildFromSVN
BUILDNAME="$BUILDNAME Style"
CreateCTestConfig
$CTEST -VV -S CTest.cmake,Style
;;
config)
# Generar configuració
SetBuildFromSVN
CreateCTestConfig
;;
Experimental)
# Experimental Test
SetBuildFromOS
CreateCTestConfig
$CTEST -VV -S CTest.cmake,Experimental
;;
*|help)
Usage
;;
esac