-
Notifications
You must be signed in to change notification settings - Fork 22
/
build.sh
executable file
·186 lines (156 loc) · 4.04 KB
/
build.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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#!/bin/bash
PROG=$0
target=install
jcctarget="javacc:javacc install"
TIMESTAMP=`date +'%Y%m%d%H%M'`
VERSION=$TIMESTAMP
SKIPTESTS=""
DEPLOYMENT=""
zip="zip -r"
zipsuffix=""
function usage () {
echo "Usage $PROG [-s] [-z] [-p rainbow-dir] -d deployment-dir [-t target] [-v version] [command]"
echo " -d -the deployment that you want included in the build, either relative or in the dir deployments"
echo " -t -the comma separated list of targets to include in the build, either relative or in the targets dir"
echo " -v -the version label to give the release"
echo " -s -skip tests in the build"
echo " -p -the path containing the rainbow source code"
echo " -z -use gzip rather than zip"
echo "command -the build command to give"
}
while getopts :p:d:t:v:shz opt; do
case $opt in
p)
if [ -d "$OPTARG" ]; then
echo "Setting working directory to '$OPTARG'"
cd "$OPTARG"
else
echo "'$OPTARG' is not a valid directory"
usage
exit 1
fi
;;
z)
$zip="tar zcf"
$zipsuffix=".tgz"
;;
d)
if [ -d "$OPTARG" ]; then
DEPLOYMENT=$OPTARG
elif [ -d "deployments/$OPTARG" ]; then
DEPLOYMENT="deployments/$OPTARG"
else
echo "'$OPTARG' not found either relative or in deployments directory"
usage
exit 1
fi
;;
t)
IFS=, read -r -a targets <<< $OPTARG
TARGETS=()
for i in "${targets[@]}"; do
if [ -d "$i" ]; then
TARGETS+=($i)
elif [ -d "targets/$i" ]; then
TARGETS+=("targets/$i")
else
echo "'$i' was not found as a target (even in targets/)"
fi
done
if [ ${#TARGETS[@]} -eq 0 ]; then
echo "None of the targets specified as an argument to -t exist; presuming error!"
usage
exit 1
fi
;;
v)
VERSION=$OPTARG"-$TIMESTAMP"
;;
s)
SKIPTESTS="-DskipTests"
;;
\?)
usage
exit 1
;;
:)
usage
exit 1
;;
esac
done
shift $((OPTIND-1))
if [ ! -d "rainbow" -o ! -d "libs" ]; then
echo "FATAL: Could not find the rainbow directory containing source for the core Rainbow components and libraries!"
exit 1
fi
if [[ "$#" == 1 ]]; then
if [[ "$1" != "install" ]]; then
target=$1
jcctarget=$1
fi
fi
echo "Doing $target"
mkdir -p bin/lib
cd libs/
echo "Doing $target for auxtestlib"
cd auxtestlib
mvn $SKIPTESTS $target || exit 1
echo "Doing $target for incubator"
cd ../incubator
mvn $SKIPTESTS $target || exit 1
echo "Doing $target for parsec"
cd ../parsec
mvn -DskipTests $jcctarget || exit 1
echo "Doing $target for typelib"
cd ../typelib
mvn $SKIPTESTS $jcctarget || exit 1
echo "Doing $target for eselib"
cd ../eseblib
mvn -DskipTests $target || exit 1
cd ../../rainbow
echo "Doing $target for rainbow-core"
cd rainbow-core
mvn -DskipTests $target || exit 1
echo "Doing $target for rainbow-gui"
cd ../rainbow-gui
mvn -DskipTests $target || exit 1
echo "Doing $target for rainbow-acme-model"
cd ../rainbow-acme-model
mvn -DskipTests $target || exit 1
echo "Doing $target for rainbow-utility-model"
cd ../rainbow-utility-model || exit 1
mvn $target
echo "Doing $target for rainbow-stitch"
cd ../rainbow-stitch
mvn $SKIPTESTS $target || exit 1
echo "Doing $target for rainbow-gui"
cd ../rainbow-gui
mvn $SKIPTESTS $target || exit 1
cd ../..
BUILDDIR=`pwd`
cd $DEPLOYMENT
echo "Doing $target in $(pwd)"
mvn $SKIPTESTS $target || exit 1
if [[ "$target" == "install" ]]; then
mkdir -p $BUILDDIR/bin/lib
cp target/*.jar $BUILDDIR/bin/lib
cp target/lib/* $BUILDDIR/bin/lib
cd $BUILDDIR
mkdir -p bin/targets
for i in $TARGETS; do
cp -r $i bin/targets
done
cp scripts/* bin/
cp license.html bin/
mv bin Rainbow-$VERSION
$zip Rainbow-$VERSION$zipsuffix Rainbow-$VERSION
rm -f Rainbow-build
ln -s Rainbow-$VERSION Rainbow-build
elif [[ "$target" == "clean" ]]; then
cd $BUILDDIR
rm -rf bin
rm -rf Rainbow-$VERSION
rm Rainbow-$VERSION.tgz
echo "Build is in Rainbow-$VERSION and Rainbow-$VERSION.zip"
fi