Develop and Download Open Source Software

Browse CVS Repository

Contents of /samurai-graph/samurai-graph/tools/ant.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Tue Aug 18 08:02:49 2009 UTC (14 years, 7 months ago) by orrisroot
Branch: MAIN
CVS Tags: RELENG_2_BP, RELEASE_2_0_0, RELENG_3_BP, HEAD
Branch point for: RELENG_2, RELENG_3
Changes since 1.5: +319 -38 lines
File MIME type: text/x-sh
reconstruct 'Ant' build environment for Windows and Unix/Linux.

1 #! /bin/sh
2
3 # Licensed to the Apache Software Foundation (ASF) under one or more
4 # contributor license agreements. See the NOTICE file distributed with
5 # this work for additional information regarding copyright ownership.
6 # The ASF licenses this file to You under the Apache License, Version 2.0
7 # (the "License"); you may not use this file except in compliance with
8 # the License. You may obtain a copy of the License at
9 #
10 # http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17
18 ANT_HOME=`dirname $0`
19
20 # Extract launch and ant arguments, (see details below).
21 ant_exec_args=
22 no_config=true
23 # no_config=false
24 use_jikes_default=false
25 ant_exec_debug=false
26 show_help=false
27 for arg in "$@" ; do
28 if [ "$arg" = "--noconfig" ] ; then
29 no_config=true
30 elif [ "$arg" = "--usejikes" ] ; then
31 use_jikes_default=true
32 elif [ "$arg" = "--execdebug" ] ; then
33 ant_exec_debug=true
34 elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
35 show_help=true
36 ant_exec_args="$ant_exec_args -h"
37 else
38 if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
39 show_help=true
40 fi
41 ant_exec_args="$ant_exec_args \"$arg\""
42 fi
43 done
44
45 # Source/default ant configuration
46 if $no_config ; then
47 rpm_mode=false
48 usejikes=$use_jikes_default
49 else
50 # load system-wide ant configuration (ONLY if ANT_HOME has NOT been set)
51 if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; then
52 if [ -f "/etc/ant.conf" ] ; then
53 . /etc/ant.conf
54 fi
55 fi
56
57 # load user ant configuration
58 if [ -f "$HOME/.ant/ant.conf" ] ; then
59 . $HOME/.ant/ant.conf
60 fi
61 if [ -f "$HOME/.antrc" ] ; then
62 . "$HOME/.antrc"
63 fi
64
65 # provide default configuration values
66 if [ -z "$rpm_mode" ] ; then
67 rpm_mode=false
68 fi
69 if [ -z "$usejikes" ] ; then
70 usejikes=$use_jikes_default
71 fi
72 fi
73
74 # Setup Java environment in rpm mode
75 if $rpm_mode ; then
76 if [ -f /usr/share/java-utils/java-functions ] ; then
77 . /usr/share/java-utils/java-functions
78 set_jvm
79 set_javacmd
80 fi
81 fi
82
83 # OS specific support. $var _must_ be set to either true or false.
84 cygwin=false;
85 darwin=false;
86 case "`uname`" in
87 CYGWIN*) cygwin=true ;;
88 Darwin*) darwin=true
89 if [ -z "$JAVA_HOME" ] ; then
90 JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
91 fi
92 ;;
93 esac
94
95 if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then
96 ## resolve links - $0 may be a link to ant's home
97 PRG="$0"
98 progname=`basename "$0"`
99
100 # need this for relative symlinks
101 while [ -h "$PRG" ] ; do
102 ls=`ls -ld "$PRG"`
103 link=`expr "$ls" : '.*-> \(.*\)$'`
104 if expr "$link" : '/.*' > /dev/null; then
105 PRG="$link"
106 else
107 PRG=`dirname "$PRG"`"/$link"
108 fi
109 done
110
111 ANT_HOME=`dirname "$PRG"`/..
112
113 # make it fully qualified
114 ANT_HOME=`cd "$ANT_HOME" > /dev/null && pwd`
115 fi
116
117 # For Cygwin, ensure paths are in UNIX format before anything is touched
118 if $cygwin ; then
119 [ -n "$ANT_HOME" ] &&
120 ANT_HOME=`cygpath --unix "$ANT_HOME"`
121 [ -n "$JAVA_HOME" ] &&
122 JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
123 fi
124
125 # set ANT_LIB location
126 #ANT_LIB="${ANT_HOME}/lib"
127 # for samurai-graph
128 ANT_LIB="${ANT_HOME}/ant"
129
130 if [ -z "$JAVACMD" ] ; then
131 if [ -n "$JAVA_HOME" ] ; then
132 # IBM's JDK on AIX uses strange locations for the executables
133 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
134 JAVACMD="$JAVA_HOME/jre/sh/java"
135 elif [ -x "$JAVA_HOME/jre/bin/java" ] ; then
136 JAVACMD="$JAVA_HOME/jre/bin/java"
137 else
138 JAVACMD="$JAVA_HOME/bin/java"
139 fi
140 else
141 JAVACMD=`which java 2> /dev/null `
142 if [ -z "$JAVACMD" ] ; then
143 JAVACMD=java
144 fi
145 fi
146 fi
147
148 if [ ! -x "$JAVACMD" ] ; then
149 echo "Error: JAVA_HOME is not defined correctly."
150 echo " We cannot execute $JAVACMD"
151 exit 1
152 fi
153
154 # Build local classpath using just the launcher in non-rpm mode or
155 # use the Jpackage helper in rpm mode with basic and default jars
156 # specified in the ant.conf configuration. Because the launcher is
157 # used, libraries linked in ANT_HOME/lib will also be included, but this
158 # is discouraged as it is not java-version safe. A user should
159 # request optional jars and their dependencies via the OPT_JAR_LIST
160 # variable
161 if $rpm_mode && [ -x /usr/bin/build-classpath ] ; then
162 LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"
163
164 # If no optional jars have been specified then build the default list
165 if [ -z "$OPT_JAR_LIST" ] ; then
166 for file in /etc/ant.d/*; do
167 if [ -f "$file" ]; then
168 case "$file" in
169 *~) ;;
170 *#*) ;;
171 *.rpmsave) ;;
172 *.rpmnew) ;;
173 *)
174 for dep in `cat "$file"`; do
175 case "$OPT_JAR_LIST" in
176 *"$dep"*) ;;
177 *) OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep"
178 esac
179 done
180 esac
181 fi
182 done
183 fi
184
185 # If the user requested to try to add some other jars to the classpath
186 if [ -n "$OPT_JAR_LIST" ] ; then
187 _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
188 if [ -n "$_OPTCLASSPATH" ] ; then
189 LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
190 fi
191 fi
192
193 # Explicitly add javac path to classpath, assume JAVA_HOME set
194 # properly in rpm mode
195 if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
196 LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
197 fi
198 if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
199 LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
200 fi
201
202 # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be
203 # user CLASSPATH first and ant-found jars after.
204 # In that case, the user CLASSPATH will override ant-found jars
205 #
206 # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
207 # with ant-found jars first and user CLASSPATH after
208 if [ -n "$CLASSPATH" ] ; then
209 # merge local and specified classpath
210 if [ -z "$LOCALCLASSPATH" ] ; then
211 LOCALCLASSPATH="$CLASSPATH"
212 elif [ -n "$CLASSPATH_OVERRIDE" ] ; then
213 LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
214 else
215 LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
216 fi
217
218 # remove class path from launcher -cp option
219 CLASSPATH=""
220 fi
221 else
222 # not using rpm_mode; use launcher to determine classpaths
223 if [ -z "$LOCALCLASSPATH" ] ; then
224 LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
225 else
226 LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
227 fi
228 fi
229
230 if [ -n "$JAVA_HOME" ] ; then
231 # OSX hack to make Ant work with jikes
232 if $darwin ; then
233 OSXHACK="${JAVA_HOME}/../Classes"
234 if [ -d "${OSXHACK}" ] ; then
235 for i in "${OSXHACK}"/*.jar
236 do
237 JIKESPATH="$JIKESPATH:$i"
238 done
239 fi
240 fi
241 fi
242
243 # Allow Jikes support (off by default)
244 if $usejikes; then
245 ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
246 fi
247
248 # For Cygwin, switch paths to appropriate format before running java
249 # For PATHs convert to unix format first, then to windows format to ensure
250 # both formats are supported. Probably this will fail on directories with ;
251 # in the name in the path. Let's assume that paths containing ; are more
252 # rare than windows style paths on cygwin.
253 if $cygwin; then
254 if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
255 format=mixed
256 else
257 format=windows
258 fi
259 ANT_HOME=`cygpath --$format "$ANT_HOME"`
260 ANT_LIB=`cygpath --$format "$ANT_LIB"`
261 JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
262 LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
263 LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
264 if [ -n "$CLASSPATH" ] ; then
265 CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
266 CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
267 fi
268 CYGHOME=`cygpath --$format "$HOME"`
269 fi
270
271 # Show script help if requested
272 if $show_help ; then
273 echo $0 '[script options] [options] [target [target2 [target3] ..]]'
274 echo 'Script Options:'
275 echo ' --help, --h print this message and ant help'
276 echo ' --noconfig suppress sourcing of /etc/ant.conf,'
277 echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'
278 echo ' configuration files'
279 echo ' --usejikes enable use of jikes by default, unless'
280 echo ' set explicitly in configuration files'
281 echo ' --execdebug print ant exec line generated by this'
282 echo ' launch script'
283 echo ' '
284 fi
285 # add a second backslash to variables terminated by a backslash under cygwin
286 if $cygwin; then
287 case "$ANT_HOME" in
288 *\\ )
289 ANT_HOME="$ANT_HOME\\"
290 ;;
291 esac
292 case "$CYGHOME" in
293 *\\ )
294 CYGHOME="$CYGHOME\\"
295 ;;
296 esac
297 case "$JIKESPATH" in
298 *\\ )
299 JIKESPATH="$JIKESPATH\\"
300 ;;
301 esac
302 case "$LOCALCLASSPATH" in
303 *\\ )
304 LOCALCLASSPATH="$LOCALCLASSPATH\\"
305 ;;
306 esac
307 case "$CLASSPATH" in
308 *\\ )
309 CLASSPATH="$CLASSPATH\\"
310 ;;
311 esac
312 fi
313 # Execute ant using eval/exec to preserve spaces in paths,
314 # java options, and ant args
315 ant_sys_opts=
316 if [ -n "$CYGHOME" ]; then
317 if [ -n "$JIKESPATH" ]; then
318 ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""
319 else
320 ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""
321 fi
322 else
323 if [ -n "$JIKESPATH" ]; then
324 ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
325 fi
326 fi
327 ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" $ant_exec_args"
328 if $ant_exec_debug ; then
329 echo $ant_exec_command
330 fi
331 eval $ant_exec_command

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26