xref: /aosp_15_r20/dalvik/dx/etc/dx.bat (revision 055d459012065f78d96b68be8421640240ddf631)
1*055d4590SKeyi Gui@echo off
2*055d4590SKeyi GuiREM Copyright (C) 2007 The Android Open Source Project
3*055d4590SKeyi GuiREM
4*055d4590SKeyi GuiREM Licensed under the Apache License, Version 2.0 (the "License");
5*055d4590SKeyi GuiREM you may not use this file except in compliance with the License.
6*055d4590SKeyi GuiREM You may obtain a copy of the License at
7*055d4590SKeyi GuiREM
8*055d4590SKeyi GuiREM     http://www.apache.org/licenses/LICENSE-2.0
9*055d4590SKeyi GuiREM
10*055d4590SKeyi GuiREM Unless required by applicable law or agreed to in writing, software
11*055d4590SKeyi GuiREM distributed under the License is distributed on an "AS IS" BASIS,
12*055d4590SKeyi GuiREM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*055d4590SKeyi GuiREM See the License for the specific language governing permissions and
14*055d4590SKeyi GuiREM limitations under the License.
15*055d4590SKeyi Gui
16*055d4590SKeyi GuiREM don't modify the caller's environment
17*055d4590SKeyi Guisetlocal
18*055d4590SKeyi Gui
19*055d4590SKeyi GuiREM Locate dx.jar in the directory where dx.bat was found and start it.
20*055d4590SKeyi Gui
21*055d4590SKeyi GuiREM Set up prog to be the path of this script, including following symlinks,
22*055d4590SKeyi GuiREM and set up progdir to be the fully-qualified pathname of its directory.
23*055d4590SKeyi Guiset prog=%~f0
24*055d4590SKeyi Gui
25*055d4590SKeyi Gui@rem Find java.exe
26*055d4590SKeyi Guiif defined JAVA_HOME goto findJavaFromJavaHome
27*055d4590SKeyi Gui
28*055d4590SKeyi Guiset JAVA_EXE=java.exe
29*055d4590SKeyi Gui%JAVA_EXE% -version >NUL 2>&1
30*055d4590SKeyi Guiif "%ERRORLEVEL%" == "0" goto init
31*055d4590SKeyi Gui
32*055d4590SKeyi Guiecho.
33*055d4590SKeyi Guiecho ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
34*055d4590SKeyi Guiecho.
35*055d4590SKeyi Guiecho Please set the JAVA_HOME variable in your environment to match the
36*055d4590SKeyi Guiecho location of your Java installation.
37*055d4590SKeyi Guiexit /b 1
38*055d4590SKeyi Gui
39*055d4590SKeyi Gui:findJavaFromJavaHome
40*055d4590SKeyi Guiset JAVA_HOME=%JAVA_HOME:"=%
41*055d4590SKeyi Guiset JAVA_EXE=%JAVA_HOME%/bin/java.exe
42*055d4590SKeyi Gui
43*055d4590SKeyi Guiif exist "%JAVA_EXE%" goto init
44*055d4590SKeyi Gui
45*055d4590SKeyi Guiecho.
46*055d4590SKeyi Guiecho ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
47*055d4590SKeyi Guiecho.
48*055d4590SKeyi Guiecho Please set the JAVA_HOME variable in your environment to match the
49*055d4590SKeyi Guiecho location of your Java installation.
50*055d4590SKeyi Guiexit /b 1
51*055d4590SKeyi Gui
52*055d4590SKeyi Gui:init
53*055d4590SKeyi Guiset jarfile=dx.jar
54*055d4590SKeyi Guiset "frameworkdir=%~dp0"
55*055d4590SKeyi Guirem frameworkdir must not end with a dir sep.
56*055d4590SKeyi Guiset "frameworkdir=%frameworkdir:~0,-1%"
57*055d4590SKeyi Gui
58*055d4590SKeyi Guiif exist "%frameworkdir%\%jarfile%" goto JarFileOk
59*055d4590SKeyi Gui    set "frameworkdir=%~dp0lib"
60*055d4590SKeyi Gui
61*055d4590SKeyi Guiif exist "%frameworkdir%\%jarfile%" goto JarFileOk
62*055d4590SKeyi Gui    set "frameworkdir=%~dp0..\framework"
63*055d4590SKeyi Gui
64*055d4590SKeyi Gui:JarFileOk
65*055d4590SKeyi Gui
66*055d4590SKeyi Guiset "jarpath=%frameworkdir%\%jarfile%"
67*055d4590SKeyi Gui
68*055d4590SKeyi Guiset javaOpts=
69*055d4590SKeyi Guiset args=
70*055d4590SKeyi Gui
71*055d4590SKeyi GuiREM By default, give dx a max heap size of 1 gig and a stack size of 1meg.
72*055d4590SKeyi Guirem This can be overridden by using "-JXmx..." and "-JXss..." options below.
73*055d4590SKeyi Guiset defaultXmx=-Xmx1024M
74*055d4590SKeyi Guiset defaultXss=-Xss1m
75*055d4590SKeyi Gui
76*055d4590SKeyi GuiREM Capture all arguments that are not -J options.
77*055d4590SKeyi GuiREM Note that when reading the input arguments with %1, the cmd.exe
78*055d4590SKeyi GuiREM automagically converts --name=value arguments into 2 arguments "--name"
79*055d4590SKeyi GuiREM followed by "value". Dx has been changed to know how to deal with that.
80*055d4590SKeyi Guiset params=
81*055d4590SKeyi Gui
82*055d4590SKeyi Gui:firstArg
83*055d4590SKeyi Guiif [%1]==[] goto endArgs
84*055d4590SKeyi Guiset a=%~1
85*055d4590SKeyi Gui
86*055d4590SKeyi Gui    if [%defaultXmx%]==[] goto notXmx
87*055d4590SKeyi Gui    if %a:~0,5% NEQ -JXmx goto notXmx
88*055d4590SKeyi Gui        set defaultXmx=
89*055d4590SKeyi Gui    :notXmx
90*055d4590SKeyi Gui
91*055d4590SKeyi Gui    if [%defaultXss%]==[] goto notXss
92*055d4590SKeyi Gui    if %a:~0,5% NEQ -JXss goto notXss
93*055d4590SKeyi Gui        set defaultXss=
94*055d4590SKeyi Gui    :notXss
95*055d4590SKeyi Gui
96*055d4590SKeyi Gui    if %a:~0,2% NEQ -J goto notJ
97*055d4590SKeyi Gui        set javaOpts=%javaOpts% -%a:~2%
98*055d4590SKeyi Gui        shift /1
99*055d4590SKeyi Gui        goto firstArg
100*055d4590SKeyi Gui
101*055d4590SKeyi Gui    :notJ
102*055d4590SKeyi Gui    set params=%params% %1
103*055d4590SKeyi Gui    shift /1
104*055d4590SKeyi Gui    goto firstArg
105*055d4590SKeyi Gui
106*055d4590SKeyi Gui:endArgs
107*055d4590SKeyi Gui
108*055d4590SKeyi Guiset javaOpts=%javaOpts% %defaultXmx% %defaultXss%
109*055d4590SKeyi Guicall "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%
110*055d4590SKeyi Gui
111