12ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll@echo off
22ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Copyright (C) 2007 The Android Open Source Project
32ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem
42ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Licensed under the Apache License, Version 2.0 (the "License");
52ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem you may not use this file except in compliance with the License.
62ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem You may obtain a copy of the License at
72ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem
82ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem      http://www.apache.org/licenses/LICENSE-2.0
92ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem
102ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Unless required by applicable law or agreed to in writing, software
112ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem distributed under the License is distributed on an "AS IS" BASIS,
122ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem See the License for the specific language governing permissions and
142ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem limitations under the License.
152ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
162ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem don't modify the caller's environment
172ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollsetlocal
182ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
192ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Set up prog to be the path of this script, including following symlinks,
202ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem and set up progdir to be the fully-qualified pathname of its directory.
212ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollset prog=%~f0
222ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
232ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Change current directory and drive to where the script is, to avoid
242ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem issues with directories containing whitespaces.
252ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollcd /d %~dp0
262ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
272ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollrem Check we have a valid Java.exe in the path.
282ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollset java_exe=
292ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollcall lib\find_java.bat
302ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollif not defined java_exe goto :EOF
312ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
322ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollset jarfile=traceview.jar
339d4302d82956811119ead28656c537e494b75527Scott Bartaset frameworkdir=.
342ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
359d4302d82956811119ead28656c537e494b75527Scott Bartaif exist %frameworkdir%\%jarfile% goto JarFileOk
369d4302d82956811119ead28656c537e494b75527Scott Barta    set frameworkdir=lib
372ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
389d4302d82956811119ead28656c537e494b75527Scott Bartaif exist %frameworkdir%\%jarfile% goto JarFileOk
399d4302d82956811119ead28656c537e494b75527Scott Barta    set frameworkdir=..\framework
402ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
412ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll:JarFileOk
422ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
439d4302d82956811119ead28656c537e494b75527Scott Bartaset jarpath=%frameworkdir%\%jarfile%
442ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
452ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollif not defined ANDROID_SWT goto QueryArch
462ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll    set swt_path=%ANDROID_SWT%
472ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll    goto SwtDone
482ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
492ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll:QueryArch
502ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
519d4302d82956811119ead28656c537e494b75527Scott Barta    for /f "delims=" %%a in ('"%java_exe%" -jar %frameworkdir%\archquery.jar') do set swt_path=%frameworkdir%\%%a
522ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
532ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll:SwtDone
542ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
559d4302d82956811119ead28656c537e494b75527Scott Bartaif exist "%swt_path%" goto SetPath
562ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll    echo SWT folder '%swt_path%' does not exist.
572ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll    echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
582ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll    exit /B
592ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
602ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll:SetPath
612ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollset javaextdirs=%swt_path%;%frameworkdir%
622ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Moll
632ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollecho The standalone version of traceview is deprecated.
642ecff7c9e52fb3fefa0311358fccbc668099cd7aRaphael Mollecho Please use Android Device Monitor (tools/monitor) instead.
659d4302d82956811119ead28656c537e494b75527Scott Bartacall "%java_exe%" "-Djava.ext.dirs=%javaextdirs%" -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
66