xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 1 | @echo off
|
| 2 |
|
| 3 | :: Copyright (C) 2014 The Android Open Source Project
|
| 4 |
|
| 5 | :: Licensed under the Apache License, Version 2.0 (the "License");
|
| 6 | :: you may not use this file except in compliance with the License.
|
| 7 | :: You may obtain a copy of the License at
|
| 8 |
|
| 9 | :: http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
|
| 11 | :: Unless required by applicable law or agreed to in writing, software
|
| 12 | :: distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 | :: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 | :: See the License for the specific language governing permissions and
|
| 15 | :: limitations under the License.
|
| 16 |
|
| 17 | :: A helper script that launches TradeFederation from the current build
|
| 18 | :: environment.
|
| 19 |
|
xingdai | f5d9b95 | 2014-12-03 16:52:14 -0800 | [diff] [blame] | 20 | setlocal EnableDelayedExpansion
|
xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 21 | call:checkCommand adb
|
| 22 | call:checkCommand java
|
| 23 |
|
| 24 | :: check java version
|
xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 25 |
|
Tobias Thierer | 0ca60a4 | 2017-11-17 22:39:03 +0000 | [diff] [blame] | 26 | %JAVA% -version 2>&1 | findstr /R "version\ \"1*\.*[89].*\"$" || (
|
| 27 | echo "Wrong java version. 1.8 or 9 is required."
|
xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 28 | exit /B
|
| 29 | )
|
| 30 |
|
| 31 | :: check debug flag and set up remote debugging
|
| 32 | if not "%TF_DEBUG%"=="" (
|
| 33 | if "%TF_DEBUG_PORT%" == "" (
|
| 34 | set TF_DEBUG_PORT=10088
|
| 35 | )
|
xingdai | f5d9b95 | 2014-12-03 16:52:14 -0800 | [diff] [blame] | 36 | set RDBG_FLAG=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=!TF_DEBUG_PORT!
|
xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 37 | )
|
| 38 |
|
| 39 | :: first try to find TF jars in same dir as this script
|
| 40 | set CUR_DIR=%CD%
|
| 41 |
|
| 42 | if exist "%CUR_DIR%\tradefed.jar" (
|
| 43 | set tf_path="%CUR_DIR%\*"
|
| 44 | ) else (
|
| 45 | if not "%ANDROID_HOST_OUT%" == "" (
|
| 46 | if exist "%ANDROID_HOST_OUT%\tradefed\tradefed.jar" (
|
| 47 | set tf_path="%ANDROID_HOST_OUT%\tradefed\*"
|
| 48 | )
|
| 49 | )
|
| 50 | )
|
| 51 |
|
| 52 | if "%tf_path%" == "" (
|
| 53 | echo "ERROR: Could not find tradefed jar files"
|
| 54 | exit /B
|
| 55 | )
|
| 56 |
|
| 57 | :: set any host specific options
|
| 58 | :: file format for file at $TRADEFED_OPTS_FILE is one line per host with the following format:
|
| 59 | :: <hostname>=<options>
|
| 60 | :: for example:
|
| 61 | :: hostname.domain.com=-Djava.io.tmpdir=/location/on/disk -Danother=false ...
|
| 62 | :: hostname2.domain.com=-Djava.io.tmpdir=/different/location -Danother=true ...
|
| 63 | if exist "%TRADEFED_OPTS_FILE%" (
|
| 64 | call:commandResult "hostname" HOST_NAME
|
| 65 | call:commandResult "findstr /i /b "%HOST_NAME%" "%TRADEFED_OPTS_FILE%"" TRADEFED_OPTS
|
| 66 | :: delete the hostname part
|
| 67 | set TRADEFED_OPTS=!TRADEFED_OPTS:%HOST_NAME%=!
|
| 68 | :: delete the first =
|
| 69 | set TRADEFED_OPTS=!TRADEFED_OPTS:~1!
|
| 70 | )
|
| 71 |
|
| 72 | java %RDBG_FLAG% -XX:+HeapDumpOnOutOfMemoryError ^
|
| 73 | -XX:-OmitStackTraceInFastThrow %TRADEFED_OPTS% -cp %tf_path% com.android.tradefed.command.Console %*
|
| 74 |
|
xingdai | f5d9b95 | 2014-12-03 16:52:14 -0800 | [diff] [blame] | 75 | endlocal
|
xingdai | 4bea46a | 2014-11-20 14:41:02 -0800 | [diff] [blame] | 76 | ::end of file
|
| 77 | goto:eof
|
| 78 |
|
| 79 | :: check command exist or not
|
| 80 | :: if command not exist, exit
|
| 81 | :checkCommand
|
| 82 | for /f "delims=" %%i in ('where %~1') do (
|
| 83 | if %%i == "" (
|
| 84 | echo %~1 not exist
|
| 85 | exit /B
|
| 86 | )
|
| 87 | goto:eof
|
| 88 | )
|
| 89 | goto:eof
|
| 90 |
|
| 91 | :: get the command result
|
| 92 | :: usage: call:commandResult "command" result
|
| 93 | :commandResult
|
| 94 | for /f "delims=" %%i in ('%~1') do (
|
| 95 | set %~2=%%i
|
| 96 | goto:eof
|
| 97 | )
|
| 98 | goto:eof
|