1@echo off↵
2REM Copyright (C) 2017 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.09REM↵
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.↵
1516REM don't modify the caller's environment↵
17setlocal↵
1819REM Locate bundletool.jar in the directory where bundletool.bat was found and start it.↵
2021REM 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↵
2425rem Check we have a valid Java.exe in the path.↵
26set java_exe=↵
27if exist    "%~dp0..\tools\lib\find_java.bat" call    "%~dp0..\tools\lib\find_java.bat"↵
28if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"↵
29if not defined java_exe goto :EOF↵
3031set jarfile=bundletool.jar32set "frameworkdir=%~dp0"↵
33rem frameworkdir must not end with a dir sep.↵
34set "frameworkdir=%frameworkdir:~0,-1%"↵
3536if exist "%frameworkdir%\%jarfile%" goto JarFileOk↵
37    set "frameworkdir=%~dp0lib"↵
3839if exist "%frameworkdir%\%jarfile%" goto JarFileOk↵
40    set "frameworkdir=%~dp0..\framework"↵
4142:JarFileOk↵
4344set "jarpath=%frameworkdir%\%jarfile%"↵
4546set javaOpts=↵
47set args=↵
4849REM By default, give bundletool a max heap size of 1 gig and a stack size of 1meg.↵
50rem This can be overridden by using "-JXmx..." and "-JXss..." options below.↵
51set defaultXmx=-Xmx1024M↵
52set defaultXss=-Xss1m↵
5354REM Capture all arguments that are not -J options.↵
55REM Note that when reading the input arguments with %1, the cmd.exe56REM 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=↵
5960:firstArg↵
61if [%1]==[] goto endArgs↵
62set a=%~1↵
6364    if [%defaultXmx%]==[] goto notXmx↵
65    if %a:~0,5% NEQ -JXmx goto notXmx↵
66        set defaultXmx=↵
67    :notXmx↵
6869    if [%defaultXss%]==[] goto notXss↵
70    if %a:~0,5% NEQ -JXss goto notXss↵
71        set defaultXss=↵
72    :notXss↵
7374    if %a:~0,2% NEQ -J goto notJ↵
75        set javaOpts=%javaOpts% -%a:~2%↵
76        shift /1↵
77        goto firstArg↵
7879    :notJ↵
80    set params=%params% %1↵
81    shift /1↵
82    goto firstArg↵
8384:endArgs↵
8586set javaOpts=%javaOpts% %defaultXmx% %defaultXss%↵
87call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -jar "%jarpath%" %params%↵
8889