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