dx.bat revision 1e4c4bebc1feb4b68155e9c2e7e6f2c056ef8e3b
1@echo off
2REM Copyright (C) 2007 The Android Open Source Project
3REM
4REM Licensed under the Apache License, Version 2.0 (the "License");
5REM you may not use this file except in compliance with the License.
6REM You may obtain a copy of the License at
7REM
8REM     http://www.apache.org/licenses/LICENSE-2.0
9REM
10REM Unless required by applicable law or agreed to in writing, software
11REM distributed under the License is distributed on an "AS IS" BASIS,
12REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13REM See the License for the specific language governing permissions and
14REM limitations under the License.
15
16REM don't modify the caller's environment
17setlocal
18
19REM Locate dx.jar in the directory where dx.bat was found and start it.
20
21REM Set up prog to be the path of this script, including following symlinks,
22REM and set up progdir to be the fully-qualified pathname of its directory.
23set prog=%~f0
24
25REM Change current directory to where dx is, to avoid issues with directories
26REM containing whitespaces.
27cd /d %~dp0
28
29rem Check we have a valid Java.exe in the path.
30set java_exe=
31call ..\tools\lib\find_java.bat
32if not defined java_exe goto :EOF
33
34set jarfile=dx.jar
35set frameworkdir=
36
37if exist %frameworkdir%%jarfile% goto JarFileOk
38    set frameworkdir=lib\
39
40if exist %frameworkdir%%jarfile% goto JarFileOk
41    set frameworkdir=..\framework\
42
43:JarFileOk
44
45set jarpath=%frameworkdir%%jarfile%
46
47set javaOpts=
48set args=
49
50REM By default, give dx a max heap size of 1 gig. This can be overridden
51REM by using a "-JXmx..." option (see below).
52set defaultMx=-Xmx1024M
53
54REM capture all arguments that are not -J options.
55REM Note that when reading the input arguments with %1, the cmd.exe
56REM automagically converts --name=value arguments into 2 arguments "--name"
57REM followed by "value". Dx has been changed to know how to deal with that.
58set params=
59
60:firstArg
61if [%1]==[] goto endArgs
62set a=%~1
63
64    if [%defaultMx%]==[] goto notXmx
65    if %a:~0,5% NEQ -JXmx goto notXmx
66        set defaultMx=
67    :notXmx
68
69    if %a:~0,2% NEQ -J goto notJ
70        set javaOpts=%javaOpts% -%a:~2%
71        shift /1
72        goto firstArg
73
74    :notJ
75    set params=%params% %1
76    shift /1
77    goto firstArg
78
79:endArgs
80
81set javaOpts=%javaOpts% %defaultMx%
82
83call %java_exe% %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %params%
84