dx.bat revision 6bff338b5318a585d7b8fa1af44b677dff056ab6
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=
31if exist    ..\tools\lib\find_java.bat call    ..\tools\lib\find_java.bat
32if exist ..\..\tools\lib\find_java.bat call ..\..\tools\lib\find_java.bat
33if not defined java_exe goto :EOF
34
35set jarfile=dx.jar
36set frameworkdir=
37
38if exist %frameworkdir%%jarfile% goto JarFileOk
39    set frameworkdir=lib\
40
41if exist %frameworkdir%%jarfile% goto JarFileOk
42    set frameworkdir=..\framework\
43
44:JarFileOk
45
46set jarpath=%frameworkdir%%jarfile%
47
48set javaOpts=
49set args=
50
51REM By default, give dx a max heap size of 1 gig and a stack size of 1meg.
52rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
53set defaultXmx=-Xmx1024M
54set defaultXss=-Xss1m
55
56REM Capture all arguments that are not -J options.
57REM Note that when reading the input arguments with %1, the cmd.exe
58REM automagically converts --name=value arguments into 2 arguments "--name"
59REM followed by "value". Dx has been changed to know how to deal with that.
60set params=
61
62:firstArg
63if [%1]==[] goto endArgs
64set a=%~1
65
66    if [%defaultXmx%]==[] goto notXmx
67    if %a:~0,5% NEQ -JXmx goto notXmx
68        set defaultXmx=
69    :notXmx
70
71    if [%defaultXss%]==[] goto notXss
72    if %a:~0,5% NEQ -JXss goto notXss
73        set defaultXss=
74    :notXss
75
76    if %a:~0,2% NEQ -J goto notJ
77        set javaOpts=%javaOpts% -%a:~2%
78        shift /1
79        goto firstArg
80
81    :notJ
82    set params=%params% %1
83    shift /1
84    goto firstArg
85
86:endArgs
87
88set javaOpts=%javaOpts% %defaultXmx% %defaultXss%
89
90call %java_exe% %javaOpts% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %params%
91