-
Notifications
You must be signed in to change notification settings - Fork 8
/
build_features
executable file
·352 lines (331 loc) · 10.1 KB
/
build_features
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
351
352
#!/bin/sh
#
# @file build_features
# @brief rtmtools feature 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.
#
# - PLUGINS_DIR: A directory rtmtools plugins stored. Plugin versions
# should be same as versions which obtained from
# version text file. Usually this variable can be set
# automatically as $JARDIR.
#
# - ANT_DiR: Eclipse ant plugin directory. This variable would be set
# automatically as
# ECLIPSE_HOME/org.apache.ant.<something>.
#
# Eclipse search directories
ECLIPSE_DIRS="$HOME/eclipse $HOME ../ ../../ ../..//usr/lib/ /usr/share"
# Ant eclipse plugin location
ANT_HOME_DEFAULT="${ECLIPSE_HOME}/plugins/org.apache.ant_1.7.0.v200803061910/"
# 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"
#============================================================
# 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 site.xml"
rm sitetool/openrtp_site/site.xml
svn update sitetool/openrtp_site/site.xml
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."
if test ! -f version.txt ; then
echo "version.txt not found. Plugins should be built at first."
echo "Aborting."
exit 1
fi
. ./version.txt
fi
export VERSION
export PROJECT_VERSION
if test "x$DISTDIR" = "x" ; then
DISTDIR=openrtp-$VERSION
fi
if test "x$JARDIR" = "x" ; then
JARDIR=$JARDIR_DEFAULT
fi
}
#------------------------------------------------------------
# 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. Searching..."
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
}
#------------------------------------------------------------
# find_antplugin
#
# This function find Eclipse's and plugin under ECLIPSE_HOME.
#------------------------------------------------------------
find_antplugin()
{
if test ! "x$ANT_HOME" = "x" ; then
echo "ANT_HOME: $ANT_HOME is set."
if test -d $ANT_HOME ; then
echo "ANT_HOME: $ANT_HOME exists. Contents are the following."
ls $ANT_HOME
return 0
fi
echo "ANT_HOME directory $ANT_HOME not found. Searching other Ant..."
else
echo "Environment variable ANT_HOME does not exist. Searching..."
fi
other_ant=`find $ECLIPSE_HOME/plugins -maxdepth 1 -type d -name 'org.apache.ant*'`
echo "Found: $other_ant"
if test "x$other_ant" = "x" ; then
echo "Ant plugin was not found."
echo "Please install eclipse with ant plugin such as org.apache.ant.*"
echo "Aborting."
return 1
fi
for a in $other_ant ; do
ANT_HOME=$other_ant
echo "ANT_HOME: $ANT_HOME is set."
return 0
done
}
#------------------------------------------------------------
# check_plugins
#------------------------------------------------------------
check_plugins()
{
if test ! "x$PLUGINS_DIR" = "x" ; then
JARDIR=$PLUGINS_DIR
fi
echo "Checking plugin jar files..."
for p in $PROJECTS ; do
tmp="${p}_${PROJECT_VERSION}.jar"
if test ! -f `pwd`/$JARDIR/$tmp ; then
echo "[ERROR] $tmp not found"
echo "Please build plugins at first."
exit 1
fi
echo "[OK] $tmp found"
done
PLUGINS_DIR=`pwd`/$JARDIR
echo "PLUGINS_DIR: $JARDIR is set."
return 0
}
#------------------------------------------------------------
# build_features
#
# Building features:
# - copying plugins
# - signing plugins
# - building features
# - copying features
#------------------------------------------------------------
build_features()
{
echo "Getting plugins (get.plugins)"
ant -lib lib get.plugins
if test $? -ne 0 ; then
echo "Error in get.plugins target. Aborting..."
exit 1
fi
echo "Signing features (feature.sign.gen)"
ant -lib lib feature.sign.gen
if test $? -ne 0 ; then
echo "Error in feature.sign.gen target. Aborting..."
exit 1
fi
echo "Building features (build.features)"
ant -lib lib build.features
if test $? -ne 0 ; then
echo "Error in build.features target. Aborting..."
exit 1
fi
echo "Deploying features to site (deploy.site)"
ant -lib lib deploy.site
if test $? -ne 0 ; then
echo "Error in deploy.site target. Aborting..."
exit 1
fi
}
clean_features()
{
echo "Cleaning features."
ant -lib lib clean
if test $? -ne 0 ; then
echo "Cleaning features failed. Aborting..."
exit 1
fi
return 0
}
#==============================
# main
#==============================
export LC_ALL=C
cd `dirname $0`
getopt $*
get_version
# [clean] case
if test "x$TARGET" = "xclean" ; then
echo "Starting to clean features."
cd sitetool
clean_features
else
# [build] case
echo "Starting to build features."
find_eclipsehome
find_antplugin
check_plugins
export ANT_HOME
export PLUGINS_DIR
export PATH=${PATH}:${ANT_HOME}/bin
echo "ANT_HOME=${ANT_HOME}"
echo "PLUGINS_DIR=${PLUGINS_DIR}"
echo "PATH=${PATH}"
cd sitetool
build_features
fi
exit 0
# EOF