-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_plugins
executable file
·350 lines (325 loc) · 9.88 KB
/
build_plugins
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#!/bin/sh
#
# @file build_plugins
# @brief rtmtools plugins build script
# @author Noriaki Ando <n-ando@aist.go.jp>
#
# * How to build rtmtools
#
# ** Required environment
#
# The following development environment and tools are required to
# build rtmtools.
#
# - jdk
# - ant
# - Eclipse SDK (3.4 or later is required.)
#
# ** Before build tools
#
# Please edit "version" text to set version number of the tools. This
# is a kind of bash script.
#
# Example:
# -------
# VERSION=1.1.0
# PROJECT_VERSION=${VERSION}.rc7v$(date +%Y%m%d)
#
# ** Environment variables
#
# To build rtmtools, some environmental variables can be set. In most
# case, these variables are automatically set.
#
# - ECLIPSE_HOME: A directory path to an Eclipse SDK. Under this
# directory, .eclipseproduct, eclipse.ini, plugins and
# eclipse executable should exist. If this
# env.variable is not set, this script tries to search
# eclipse directory under some directories that is set
# in a env.variable ECLIPSE_DIRS written in the head
# of this script.
#
# - JAVA_HOME: A directory JDK installed. If this variable is not set,
# this script tries to estimate JDK directory to
# resolve symbolic link of javac executable.
#
# - VERSION: A simple version number for the tools like 1.1.1. This is
# used for actual bundles' version number with
# PROJECT_VERSION number.
#
# - PROJECT_VERSION: Project version number is full version string
# with simple version and suffix like
# rc120121212. This version string is used actual jar
# file name.
#
# - JARDIR: A directory to store jar files. Default directory is "jar".
# This directory is temporary jar files store place.
#
# - DISTDIR: A directory to be archived for distribution package.
# This directory name becomes archive package name.
# Default name is openrtm-x.y.z. x, y, z are version
# number which is defined in version text file.
#
#---------------------------------------------------------------------------
# Global variables
#---------------------------------------------------------------------------
# Default build taget
TARGET="buildAll"
# Default
JARDIR_DEFAULT="jar"
# target projects
PROJECTS="jp.go.aist.rtm.toolscommon.profiles
jp.go.aist.rtm.toolscommon.profiles.nl1
jp.go.aist.rtm.toolscommon
jp.go.aist.rtm.toolscommon.nl1
jp.go.aist.rtm.rtcbuilder
jp.go.aist.rtm.rtcbuilder.nl1
jp.go.aist.rtm.rtcbuilder.java
jp.go.aist.rtm.rtcbuilder.python
jp.go.aist.rtm.rtcbuilder.lua
jp.go.aist.rtm.repositoryView
jp.go.aist.rtm.repositoryView.nl1
jp.go.aist.rtm.nameserviceview
jp.go.aist.rtm.nameserviceview.nl1
jp.go.aist.rtm.systemeditor
jp.go.aist.rtm.systemeditor.nl1"
# Eclipse search directories
ECLIPSE_DIRS="$HOME/eclipse ../ ../../ ../../ $HOME /usr/lib/ /usr/share"
#============================================================
# functions
#============================================================
#------------------------------------------------------------
# getopt
#
# This function gets command line options
# ------------------------------------------------------------
getopt()
{
if test $# = 1 ; then
arg=$1
if test "x$arg" = "xclean" ; then
TARGET=$1
return 0
fi
if test "x$arg" = "xrevert" ; then
echo "Reverting updated MANIFEST.MF..."
mf=`svn status | grep '^M' | grep MANIFEST.MF | awk '{print $2;}'`
for m in $mf; do
rm $m
svn update $m
done
exit 0
fi
fi
}
#------------------------------------------------------------
# get_version
#
# This function gets version number and project version string
# from version text file.
# ------------------------------------------------------------
get_version()
{
if test "x$VERSION" = "x" || test "x$PROJECT_VERSION" = "x" ; then
echo "Environment variable VERSION/PROJECT_VERSION is not set."
echo "Getting from ./version text."
. ./version
fi
export VERSION
export PROJECT_VERSION
if test "x$DISTDIR" = "x" ; then
DISTDIR=openrtp-$PROJECT_VERSION
fi
if test "x$JARDIR" = "x" ; then
JARDIR=$JARDIR_DEFAULT
fi
if test -f version.txt ; then
rm -f version.txt
fi
echo "VERSION=$VERSION" >> version.txt
echo "PROJECT_VERSION=$PROJECT_VERSION" >> version.txt
}
#------------------------------------------------------------
# find_eclipsehome
#
# This function checks ECLIPSE_HOME env variable and if it is
# not set, it searches an eclipse directory under ECLIPSE_DIRS,
# and set ECLIPSE_HOME env variable.
# ------------------------------------------------------------
find_eclipsehome()
{
if test ! "x$ECLIPSE_HOME" = "x" ; then
if test -d $ECLIPSE_HOME ; then
return 0
fi
echo "ECLIPSE_HOME $ECLIPSE_HOME does not exist."
fi
echo "Environment variable ECLIPSE_HOME is not set. Seaching..."
for d in $ECLIPSE_DIRS ; do
if test ! -d $d ; then
continue
fi
tmp=`find -L $d -name .eclipseproduct`
if test "x$tmp" = "x" ; then
continue
fi
for e in $tmp ; do
edir=`dirname $e`
if test -f $edir/eclipse.ini && test -d $edir/plugins ; then
export ECLIPSE_HOME="$edir"
return 0
fi
done
done
echo "eclipse not found. Please install eclipse and set ECLIPSE_HOME."
exit 1
}
#------------------------------------------------------------
# find_javahome
#
# This function estimate JAVA_HOME from javac, which usually
# is a symbolic link to $JAVA_HOME/bin/javac.
#------------------------------------------------------------
find_javahome()
{
if test ! "x$JAVA_HOME" = "x" ; then
if test -d $JAVA_HOME && test -f $JAVA_HOME/bin/javac ; then
return 0
fi
echo "JDK cannot be found under JAVA_HOME: $JAVA_HOME"
fi
echo "Valid Environment variable JAVA_HOME is not set. Searching..."
tmp=`readlink -e $(which javac)`
jdk_path=`dirname $tmp | sed 's/\/bin$//'`
if test "x$jdk_path" = "x" ; then
echo "JDK not found. Please install JDK and set JAVA_HOME."
exit 1
fi
export JAVA_HOME=$jdk_path
return 0
}
#------------------------------------------------------------
# check_plugins
#------------------------------------------------------------
check_plugins()
{
if test "x$JARDIR" = "x" ; then
echo "Env variable JARDIR is not set. Aborting."
exit 1
fi
echo "Checking plugin jar files..."
for p in $PROJECTS ; do
tmp="${p}_${PROJECT_VERSION}.jar"
if test ! -f $JARDIR/$tmp ; then
echo "[ERROR] $tmp not found"
return 1
fi
echo "[OK] $tmp found"
done
}
#------------------------------------------------------------
# cleanup_jardir
#
# Cleanup jar directory
#------------------------------------------------------------
cleanup_jardir()
{
if test -f $DISTDIR.zip ; then
rm -f $DISTDIR.zip
fi
if test -d $DISTDIR; then
rm -rf $DISTDIR
fi
if test -d $JARDIR; then
rm -rf $JARDIR
fi
mkdir $DISTDIR
mkdir $JARDIR
}
#------------------------------------------------------------
# do_ant <TARGET>
#
# Invoke Ant build by buildAll target for each projects.
#------------------------------------------------------------
do_ant()
{
git clone https://github.com/Nobu19800/jp.go.aist.rtm.rtcbuilder.lua
target=$TARGET
echo "Do ant target=$TARGET libs=$LIBS"
for project in $PROJECTS; do
if test -d $project; then
echo "- Starting ant build of project: $project"
cd $project
echo "target : $TARGET libs:$LIBS"
ant $target $LIBS
if test $? -ne 0; then
echo "[ERROR] build failed: " $project
echo "Aborting..."
exit 1
fi
echo "Copying created jar file into $DISTDIR..."
cp jar/*aist*.jar ../$DISTDIR
cp jar/*aist*.jar ../$JARDIR
cd ..
else
echo "Project: $project does not exist"
echo "Skipping..."
fi
done
}
#------------------------------------------------------------
# create_zip
#
# Create ZIP archive of built plugin files.
#------------------------------------------------------------
create_zip()
{
echo "Creating ZIP archive of plugins jar files."
zipfile=$DISTDIR.zip
if test -f $zipfile ; then
rm $zipfile
fi
zip $zipfile -r ./$DISTDIR
if test $? -ne 0 ; then
echo "Faild to create ZIP file: $zipfile created"
exit 1
else
echo "ZIP file: $zipfile created"
fi
}
#==============================
# main
#==============================
export LC_ALL=C
cd `dirname $0`
getopt $*
get_version
find_eclipsehome
find_javahome
echo "------------------------------------------------------------"
echo "Environment variables:"
echo "ECLIPSE_HOME: $ECLIPSE_HOME"
echo "JAVA_HOME: $JAVA_HOME"
echo "VERSION: $VERSION"
echo "PROJECT_VERSION: $PROJECT_VERSION"
echo "------------------------------------------------------------"
#LIBS="-lib ../lib -lib $ECLIPSE_HOME/plugins"
LIBS="-lib ../lib -lib ../lib/a4e-2137 -lib ../lib/a4e-2137/libs -lib $ECLIPSE_HOME/plugins"
cleanup_jardir
do_ant $TARGET
# Check and finalize Ant results
if test "x$TARGET" = "xclean" ; then
# cleanup jar directories
rm -rf $DISTDIR
rm -rf $JARDIR
rm -f version.txt
exit 0
elif test "x$TARGET" = "xbuildAll" ; then
check_plugins
if test $? -ne 0 ;then
echo "Build failed? Some jar files are not found. Aborting..."
exit 1
fi
create_zip
fi
exit 0
# end of script