Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 1 | @echo off
|
| 2 | REM Copyright (C) 2016 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 apksigner.jar in the directory where apksigner.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 Check we have a valid Java.exe in the path.
|
| 26 | set java_exe=
|
| 27 | if exist "%~dp0..\tools\lib\find_java.bat" call "%~dp0..\tools\lib\find_java.bat"
|
| 28 | if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat"
|
| 29 | if not defined java_exe goto :EOF
|
| 30 |
|
| 31 | set jarfile=apksigner.jar
|
| 32 | set "frameworkdir=%~dp0"
|
| 33 | rem frameworkdir must not end with a dir sep.
|
| 34 | set "frameworkdir=%frameworkdir:~0,-1%"
|
| 35 |
|
| 36 | if exist "%frameworkdir%\%jarfile%" goto JarFileOk
|
| 37 | set "frameworkdir=%~dp0lib"
|
| 38 |
|
| 39 | if exist "%frameworkdir%\%jarfile%" goto JarFileOk
|
| 40 | set "frameworkdir=%~dp0..\framework"
|
| 41 |
|
| 42 | :JarFileOk
|
| 43 |
|
| 44 | set "jarpath=%frameworkdir%\%jarfile%"
|
| 45 |
|
| 46 | set javaOpts=
|
| 47 | set args=
|
| 48 |
|
| 49 | REM By default, give apksigner a max heap size of 1 gig and a stack size of 1meg.
|
| 50 | rem This can be overridden by using "-JXmx..." and "-JXss..." options below.
|
| 51 | set defaultXmx=-Xmx1024M
|
| 52 | set defaultXss=-Xss1m
|
| 53 |
|
| 54 | REM Capture all arguments that are not -J options.
|
| 55 | REM Note that when reading the input arguments with %1, the cmd.exe
|
| 56 | REM automagically converts --name=value arguments into 2 arguments "--name"
|
| 57 | REM followed by "value". apksigner has been changed to know how to deal with that.
|
| 58 | set params=
|
| 59 |
|
| 60 | :firstArg
|
| 61 | if [%1]==[] goto endArgs
|
Alex Klyubin | b293b20 | 2017-05-10 16:53:25 -0700 | [diff] [blame] | 62 | set "a=%~1"
|
Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 63 |
|
| 64 | if [%defaultXmx%]==[] goto notXmx
|
Alex Klyubin | b293b20 | 2017-05-10 16:53:25 -0700 | [diff] [blame] | 65 | if "%a:~0,5%" NEQ "-JXmx" goto notXmx
|
Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 66 | set defaultXmx=
|
| 67 | :notXmx
|
| 68 |
|
| 69 | if [%defaultXss%]==[] goto notXss
|
Alex Klyubin | b293b20 | 2017-05-10 16:53:25 -0700 | [diff] [blame] | 70 | if "%a:~0,5%" NEQ "-JXss" goto notXss
|
Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 71 | set defaultXss=
|
| 72 | :notXss
|
| 73 |
|
Alex Klyubin | b293b20 | 2017-05-10 16:53:25 -0700 | [diff] [blame] | 74 | if "%a:~0,2%" NEQ "-J" goto notJ
|
Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 75 | set javaOpts=%javaOpts% -%a:~2%
|
| 76 | shift /1
|
| 77 | goto firstArg
|
| 78 |
|
| 79 | :notJ
|
| 80 | set params=%params% %1
|
| 81 | shift /1
|
| 82 | goto firstArg
|
| 83 |
|
| 84 | :endArgs
|
| 85 |
|
| 86 | set javaOpts=%javaOpts% %defaultXmx% %defaultXss%
|
Alex Klyubin | 1337ba7 | 2017-12-28 09:08:47 -0800 | [diff] [blame] | 87 | call "%java_exe%" %javaOpts% -jar "%jarpath%" %params%
|
Alex Klyubin | 3d965c7 | 2016-08-24 16:58:28 -0700 | [diff] [blame] | 88 |
|