Ivan Gavrilovic | 69befeb | 2018-05-17 10:04:09 +0100 | [diff] [blame] | 1 | @echo off |
| 2 | REM Copyright (C) 2018 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 d8.jar in the directory where d8.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 | |
Joe Baker-Malone | 4c2d2dd | 2020-04-24 12:44:11 -0700 | [diff] [blame^] | 25 | @rem Find java.exe |
| 26 | if defined JAVA_HOME goto findJavaFromJavaHome |
Ivan Gavrilovic | 69befeb | 2018-05-17 10:04:09 +0100 | [diff] [blame] | 27 | |
Joe Baker-Malone | 4c2d2dd | 2020-04-24 12:44:11 -0700 | [diff] [blame^] | 28 | set JAVA_EXE=java.exe |
| 29 | %JAVA_EXE% -version >NUL 2>&1 |
| 30 | if "%ERRORLEVEL%" == "0" goto init |
| 31 | |
| 32 | echo. |
| 33 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. |
| 34 | echo. |
| 35 | echo Please set the JAVA_HOME variable in your environment to match the |
| 36 | echo location of your Java installation. |
| 37 | exit /b 1 |
| 38 | |
| 39 | :findJavaFromJavaHome |
| 40 | set JAVA_HOME=%JAVA_HOME:"=% |
| 41 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe |
| 42 | |
| 43 | if exist "%JAVA_EXE%" goto init |
| 44 | |
| 45 | echo. |
| 46 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% |
| 47 | echo. |
| 48 | echo Please set the JAVA_HOME variable in your environment to match the |
| 49 | echo location of your Java installation. |
| 50 | exit /b 1 |
| 51 | |
| 52 | :init |
Ivan Gavrilovic | 69befeb | 2018-05-17 10:04:09 +0100 | [diff] [blame] | 53 | set jarfile=d8.jar |
| 54 | set "frameworkdir=%~dp0" |
| 55 | rem frameworkdir must not end with a dir sep. |
| 56 | set "frameworkdir=%frameworkdir:~0,-1%" |
| 57 | |
| 58 | if exist "%frameworkdir%\%jarfile%" goto JarFileOk |
| 59 | set "frameworkdir=%~dp0lib" |
| 60 | |
| 61 | if exist "%frameworkdir%\%jarfile%" goto JarFileOk |
| 62 | set "frameworkdir=%~dp0..\framework" |
| 63 | |
| 64 | :JarFileOk |
| 65 | |
| 66 | set "jarpath=%frameworkdir%\%jarfile%" |
| 67 | |
| 68 | set javaOpts= |
| 69 | set args= |
| 70 | |
| 71 | REM By default, give d8 a max heap size of 1 gig and a stack size of 1meg. |
| 72 | rem This can be overridden by using "-JXmx..." and "-JXss..." options below. |
| 73 | set defaultXmx=-Xmx1024M |
| 74 | set defaultXss=-Xss1m |
| 75 | |
| 76 | REM Capture all arguments that are not -J options. |
| 77 | REM Note that when reading the input arguments with %1, the cmd.exe |
| 78 | REM automagically converts --name=value arguments into 2 arguments "--name" |
| 79 | REM followed by "value". |
| 80 | set params= |
| 81 | |
| 82 | :firstArg |
| 83 | if [%1]==[] goto endArgs |
| 84 | set a=%~1 |
| 85 | |
| 86 | if [%defaultXmx%]==[] goto notXmx |
| 87 | if %a:~0,5% NEQ -JXmx goto notXmx |
| 88 | set defaultXmx= |
| 89 | :notXmx |
| 90 | |
| 91 | if [%defaultXss%]==[] goto notXss |
| 92 | if %a:~0,5% NEQ -JXss goto notXss |
| 93 | set defaultXss= |
| 94 | :notXss |
| 95 | |
| 96 | if %a:~0,2% NEQ -J goto notJ |
| 97 | set javaOpts=%javaOpts% -%a:~2% |
| 98 | shift /1 |
| 99 | goto firstArg |
| 100 | |
| 101 | :notJ |
| 102 | set params=%params% %1 |
| 103 | shift /1 |
| 104 | goto firstArg |
| 105 | |
| 106 | :endArgs |
| 107 | |
| 108 | set javaOpts=%javaOpts% %defaultXmx% %defaultXss% |
Tamas Kenez | c579a41 | 2018-12-18 16:36:10 +0100 | [diff] [blame] | 109 | call "%java_exe%" %javaOpts% -Djava.ext.dirs="%frameworkdir%" -cp "%jarpath%" com.android.tools.r8.D8 %params% |
Ivan Gavrilovic | 69befeb | 2018-05-17 10:04:09 +0100 | [diff] [blame] | 110 | |