-
Notifications
You must be signed in to change notification settings - Fork 60
/
deploy.sh
executable file
·165 lines (136 loc) · 3.06 KB
/
deploy.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
#!/bin/bash
usage()
{
cat << EOF
OPTIONS:
-h Show this message
-m Build a local model database.
Option "local" to use only local models.
-c Create coarse versions of all models in the local database
-t Generate a thumbnail for each model
EOF
exit
}
MODELS=
LOCAL=
COARSE=
THUMBNAIL=
GetOpts()
{
branch=""
argv=()
while [ $# -gt 0 ]
do
opt=$1
shift
case ${opt} in
-m)
MODELS=true
echo "Build a local model database."
if [ $# -eq 0 -o "${1:0:1}" = "-" ]
then
echo "Download from gazebo_models repository."
fi
if [[ "$1" == "local" ]]
then
LOCAL=true
echo "Only local models."
shift
fi
;;
-c)
COARSE=true
echo "Simplify models on local database."
;;
-t)
THUMBNAIL=true
echo "Thumbnails will be generated"
;;
*)
usage
argv+=(${opt})
;;
esac
done
}
GetOpts $*
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
# Install node modules
npm install
# Assemble javascript files
$DIR/node_modules/.bin/grunt build
# build the c++ server component
rm -rf build
mkdir build
cd build
# Run cmake and check for the exit code
cmake ..
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are cmake errors, exiting.
exit 1
fi
# continue building if cmake is happy
make -j 8
cd ../gzbridge
$DIR/node_modules/.bin/node-gyp rebuild -d
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are node-gyp build errors, exiting.
exit 1
fi
cd $DIR
# build a local model database
if [[ $MODELS ]]
then
# Temporal directory for the repository
TMP_DIR=`mktemp -d`
cd $TMP_DIR
# If no arg given then download from gazebo_models repo
if [[ -z $LOCAL ]]
then
echo -n "Downloading gazebo_models..."
git clone https://github.com/osrf/gazebo_models -b master
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are mercurial clone errors, exiting.
exit 1
fi
echo "Download complete"
cd gazebo_models
mkdir build
cd build
echo -n "Installing gazebo_models..."
cmake .. -DCMAKE_INSTALL_PREFIX=$DIR/http/client && make install > /dev/null 2>&1
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo There are build errors, exiting.
exit 1
fi
echo "Install complete"
# Remove temp dir
rm -rf $TMP_DIR
rm -rf $DIR/http/client/assets
mv $DIR/http/client/models $DIR/http/client/assets
fi
cd $DIR
echo "Gather all models on the local machine"
mkdir -p $DIR/http/client/assets
./get_local_models.py $DIR/http/client/assets
./webify_models_v2.py $DIR/http/client/assets
else
mkdir -p $DIR/http/client/assets
echo "Not cloning the model repo"
fi
if [[ $THUMBNAIL ]]
then
echo "Generating a thumbnail for each model. Make sure gazebo is not running"
./tools/gzthumbnails.sh
fi
# build a local model database
if [[ $COARSE ]]
then
./coarse_meshes.sh 50 http/client/assets/
fi
echo "Done"