| 6803 |
buildadm |
1 |
@echo off
|
|
|
2 |
|
|
|
3 |
REM Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
4 |
REM contributor license agreements. See the NOTICE file distributed with
|
|
|
5 |
REM this work for additional information regarding copyright ownership.
|
|
|
6 |
REM The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
7 |
REM (the "License"); you may not use this file except in compliance with
|
|
|
8 |
REM the License. You may obtain a copy of the License at
|
|
|
9 |
REM
|
|
|
10 |
REM http://www.apache.org/licenses/LICENSE-2.0
|
|
|
11 |
REM
|
|
|
12 |
REM Unless required by applicable law or agreed to in writing, software
|
|
|
13 |
REM distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
14 |
REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
15 |
REM See the License for the specific language governing permissions and
|
|
|
16 |
REM limitations under the License.
|
|
|
17 |
|
|
|
18 |
REM This is an inordinately troublesome piece of code, particularly because it
|
|
|
19 |
REM tries to work on both Win9x and WinNT-based systems. If we could abandon '9x
|
|
|
20 |
REM support, things would be much easier, but sadly, it is not yet time.
|
|
|
21 |
REM Be cautious about editing this, and only add WinNT specific stuff in code that
|
|
|
22 |
REM only runs on WinNT.
|
|
|
23 |
|
|
|
24 |
if "%HOME%"=="" goto homeDrivePathPre
|
|
|
25 |
if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"
|
|
|
26 |
|
|
|
27 |
:homeDrivePathPre
|
|
|
28 |
if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePre
|
|
|
29 |
if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePre
|
|
|
30 |
if exist "%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat" call "%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat"
|
|
|
31 |
|
|
|
32 |
:userProfilePre
|
|
|
33 |
if "%USERPROFILE%"=="" goto alpha
|
|
|
34 |
if "%USERPROFILE%"=="%HOME%" goto alpha
|
|
|
35 |
if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto alpha
|
|
|
36 |
if exist "%USERPROFILE%\antrc_pre.bat" call "%USERPROFILE%\antrc_pre.bat"
|
|
|
37 |
|
|
|
38 |
:alpha
|
|
|
39 |
|
|
|
40 |
if "%OS%"=="Windows_NT" @setlocal
|
|
|
41 |
if "%OS%"=="WINNT" @setlocal
|
|
|
42 |
|
|
|
43 |
if "%ANT_HOME%"=="" goto setDefaultAntHome
|
|
|
44 |
|
|
|
45 |
:stripAntHome
|
|
|
46 |
if not _%ANT_HOME:~-1%==_\ goto checkClasspath
|
|
|
47 |
set ANT_HOME=%ANT_HOME:~0,-1%
|
|
|
48 |
goto stripAntHome
|
|
|
49 |
|
|
|
50 |
:setDefaultAntHome
|
|
|
51 |
rem %~dp0 is expanded pathname of the current script under NT
|
|
|
52 |
set ANT_HOME=%~dp0..
|
|
|
53 |
|
|
|
54 |
:checkClasspath
|
|
|
55 |
set _USE_CLASSPATH=yes
|
|
|
56 |
rem CLASSPATH must not be used if it is equal to ""
|
|
|
57 |
if "%CLASSPATH%"=="""" set _USE_CLASSPATH=no
|
|
|
58 |
if "%CLASSPATH%"=="" set _USE_CLASSPATH=no
|
|
|
59 |
|
|
|
60 |
rem Slurp the command line arguments. This loop allows for an unlimited number
|
|
|
61 |
rem of arguments (up to the command line limit, anyway).
|
|
|
62 |
set ANT_CMD_LINE_ARGS=
|
|
|
63 |
:setupArgs
|
|
|
64 |
if ""%1""=="""" goto doneStart
|
|
|
65 |
if ""%1""==""-noclasspath"" goto clearclasspath
|
|
|
66 |
set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
|
|
|
67 |
shift
|
|
|
68 |
goto setupArgs
|
|
|
69 |
|
|
|
70 |
rem here is there is a -noclasspath in the options
|
|
|
71 |
:clearclasspath
|
|
|
72 |
set _USE_CLASSPATH=no
|
|
|
73 |
shift
|
|
|
74 |
goto setupArgs
|
|
|
75 |
|
|
|
76 |
rem This label provides a place for the argument list loop to break out
|
|
|
77 |
rem and for NT handling to skip to.
|
|
|
78 |
|
|
|
79 |
:doneStart
|
|
|
80 |
|
|
|
81 |
if "%_USE_CLASSPATH%"=="no" goto findAntHome
|
|
|
82 |
|
|
|
83 |
:stripClasspath
|
|
|
84 |
if not _%CLASSPATH:~-1%==_\ goto findAntHome
|
|
|
85 |
set CLASSPATH=%CLASSPATH:~0,-1%
|
|
|
86 |
goto stripClasspath
|
|
|
87 |
|
|
|
88 |
:findAntHome
|
|
|
89 |
rem find ANT_HOME if it does not exist due to either an invalid value passed
|
|
|
90 |
rem by the user or the %0 problem on Windows 9x
|
|
|
91 |
if exist "%ANT_HOME%\lib\ant.jar" goto checkJava
|
|
|
92 |
|
|
|
93 |
rem check for ant in Program Files
|
|
|
94 |
if not exist "%ProgramFiles%\ant" goto checkSystemDrive
|
|
|
95 |
set ANT_HOME=%ProgramFiles%\ant
|
|
|
96 |
goto checkJava
|
|
|
97 |
|
|
|
98 |
:checkSystemDrive
|
|
|
99 |
rem check for ant in root directory of system drive
|
|
|
100 |
if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive
|
|
|
101 |
set ANT_HOME=%SystemDrive%\ant
|
|
|
102 |
goto checkJava
|
|
|
103 |
|
|
|
104 |
:checkCDrive
|
|
|
105 |
rem check for ant in C:\ant for Win9X users
|
|
|
106 |
if not exist C:\ant\lib\ant.jar goto noAntHome
|
|
|
107 |
set ANT_HOME=C:\ant
|
|
|
108 |
goto checkJava
|
|
|
109 |
|
|
|
110 |
:noAntHome
|
|
|
111 |
echo ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME.
|
|
|
112 |
goto end
|
|
|
113 |
|
|
|
114 |
:checkJava
|
|
|
115 |
set _JAVACMD=%JAVACMD%
|
|
|
116 |
|
|
|
117 |
if "%JAVA_HOME%" == "" goto noJavaHome
|
|
|
118 |
if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
|
|
|
119 |
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
|
|
|
120 |
goto checkJikes
|
|
|
121 |
|
|
|
122 |
:noJavaHome
|
|
|
123 |
if "%_JAVACMD%" == "" set _JAVACMD=java.exe
|
|
|
124 |
|
|
|
125 |
:checkJikes
|
|
|
126 |
if not "%JIKESPATH%"=="" goto runAntWithJikes
|
|
|
127 |
|
|
|
128 |
:runAnt
|
|
|
129 |
if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath
|
|
|
130 |
:runAntWithClasspath
|
|
|
131 |
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
|
|
|
132 |
rem Check the error code of the Ant build
|
|
|
133 |
if not "%OS%"=="Windows_NT" goto onError
|
|
|
134 |
set ANT_ERROR=%ERRORLEVEL%
|
|
|
135 |
goto end
|
|
|
136 |
|
|
|
137 |
:runAntNoClasspath
|
|
|
138 |
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
|
|
|
139 |
rem Check the error code of the Ant build
|
|
|
140 |
if not "%OS%"=="Windows_NT" goto onError
|
|
|
141 |
set ANT_ERROR=%ERRORLEVEL%
|
|
|
142 |
goto end
|
|
|
143 |
|
|
|
144 |
:runAntWithJikes
|
|
|
145 |
|
|
|
146 |
if not _%JIKESPATH:~-1%==_\ goto checkJikesAndClasspath
|
|
|
147 |
set JIKESPATH=%JIKESPATH:~0,-1%
|
|
|
148 |
goto runAntWithJikes
|
|
|
149 |
|
|
|
150 |
:checkJikesAndClasspath
|
|
|
151 |
|
|
|
152 |
if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath
|
|
|
153 |
|
|
|
154 |
:runAntWithJikesAndClasspath
|
|
|
155 |
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS%
|
|
|
156 |
rem Check the error code of the Ant build
|
|
|
157 |
if not "%OS%"=="Windows_NT" goto onError
|
|
|
158 |
set ANT_ERROR=%ERRORLEVEL%
|
|
|
159 |
goto end
|
|
|
160 |
|
|
|
161 |
:runAntWithJikesNoClasspath
|
|
|
162 |
"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
|
|
|
163 |
rem Check the error code of the Ant build
|
|
|
164 |
if not "%OS%"=="Windows_NT" goto onError
|
|
|
165 |
set ANT_ERROR=%ERRORLEVEL%
|
|
|
166 |
goto end
|
|
|
167 |
|
|
|
168 |
:onError
|
|
|
169 |
rem Windows 9x way of checking the error code. It matches via brute force.
|
|
|
170 |
for %%i in (1 10 100) do set err%%i=
|
|
|
171 |
for %%i in (0 1 2) do if errorlevel %%i00 set err100=%%i
|
|
|
172 |
if %err100%==2 goto onError200
|
|
|
173 |
if %err100%==0 set err100=
|
|
|
174 |
for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%%i0 set err10=%%i
|
|
|
175 |
if "%err100%"=="" if %err10%==0 set err10=
|
|
|
176 |
:onError1
|
|
|
177 |
for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%err10%%%i set err1=%%i
|
|
|
178 |
goto onErrorEnd
|
|
|
179 |
:onError200
|
|
|
180 |
for %%i in (0 1 2 3 4 5) do if errorlevel 2%%i0 set err10=%%i
|
|
|
181 |
if err10==5 for %%i in (0 1 2 3 4 5) do if errorlevel 25%%i set err1=%%i
|
|
|
182 |
if not err10==5 goto onError1
|
|
|
183 |
:onErrorEnd
|
|
|
184 |
set ANT_ERROR=%err100%%err10%%err1%
|
|
|
185 |
for %%i in (1 10 100) do set err%%i=
|
|
|
186 |
|
|
|
187 |
:end
|
|
|
188 |
rem bug ID 32069: resetting an undefined env variable changes the errorlevel.
|
|
|
189 |
if not "%_JAVACMD%"=="" set _JAVACMD=
|
|
|
190 |
if not "%_ANT_CMD_LINE_ARGS%"=="" set ANT_CMD_LINE_ARGS=
|
|
|
191 |
|
|
|
192 |
if "%ANT_ERROR%"=="0" goto mainEnd
|
|
|
193 |
|
|
|
194 |
goto omega
|
|
|
195 |
|
|
|
196 |
:mainEnd
|
|
|
197 |
|
|
|
198 |
rem If there were no errors, we run the post script.
|
|
|
199 |
if "%OS%"=="Windows_NT" @endlocal
|
|
|
200 |
if "%OS%"=="WINNT" @endlocal
|
|
|
201 |
|
|
|
202 |
if "%HOME%"=="" goto homeDrivePathPost
|
|
|
203 |
if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
|
|
|
204 |
|
|
|
205 |
:homeDrivePathPost
|
|
|
206 |
if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePost
|
|
|
207 |
if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePost
|
|
|
208 |
if exist "%HOMEDRIVE%%HOMEPATH%\antrc_post.bat" call "%HOMEDRIVE%%HOMEPATH%\antrc_post.bat"
|
|
|
209 |
|
|
|
210 |
:userProfilePost
|
|
|
211 |
if "%USERPROFILE%"=="" goto omega
|
|
|
212 |
if "%USERPROFILE%"=="%HOME%" goto omega
|
|
|
213 |
if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto omega
|
|
|
214 |
if exist "%USERPROFILE%\antrc_post.bat" call "%USERPROFILE%\antrc_post.bat"
|
|
|
215 |
|
|
|
216 |
:omega
|
|
|
217 |
|
|
|
218 |
exit /b %ANT_ERROR%
|