1@echo off 2REM Copyright (C) 2013 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.0 9REM 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. 15 16REM don't modify the caller's environment 17setlocal 18 19rem Check we have a valid Java.exe in the path. 20set java_exe= 21if exist "%~dp0..\tools\lib\find_java.bat" call "%~dp0..\tools\lib\find_java.bat" 22if exist "%~dp0..\..\tools\lib\find_java.bat" call "%~dp0..\..\tools\lib\find_java.bat" 23if not defined java_exe goto :EOF 24 25set baserules="%~dp0\mainDexClasses.rules" 26 27REM Locate dx.jar in the directory where dx.bat was found. 28set jarfile=dx.jar 29set "frameworkdir=%~dp0" 30rem frameworkdir must not end with a dir sep. 31set "frameworkdir=%frameworkdir:~0,-1%" 32if exist "%frameworkdir%\%jarfile%" goto JarFileOk 33 set "frameworkdir=%~dp0lib" 34 35if exist "%frameworkdir%\%jarfile%" goto JarFileOk 36 set "frameworkdir=%~dp0..\framework" 37:JarFileOk 38 39set "jarpath=%frameworkdir%\%jarfile%" 40 41set "shrinkedAndroidJar=%SHRINKED_ANDROID_JAR% 42if exist "%shrinkedAndroidJar%" goto shrinkedAndroidOk 43 set "shrinkedAndroidJar=shrinkedAndroid.jar" 44 45if exist "%shrinkedAndroidJar%" goto shrinkedAndroidOk 46 set "shrinkedAndroidJar=%frameworkdir%\%shrinkedAndroidJar%" 47 48:shrinkedAndroidOk 49set "proguardExec=proguard.bat" 50set "proguard=%PROGUARD_HOME%\bin\%proguardExec%" 51 52if exist "%proguard%" goto proguardOk 53REM set proguard location for the SDK case 54 set "PROGUARD_HOME=%~dp0\..\..\tools\proguard" 55 set "proguard=%PROGUARD_HOME%\bin\%proguardExec%" 56 57if exist "%proguard%" goto proguardOk 58REM set proguard location for the Android tree case 59 set "PROGUARD_HOME=%~dp0\..\..\..\..\external\proguard" 60 set "proguard=%PROGUARD_HOME%\bin\%proguardExec%" 61 62:proguardOk 63REM Capture all arguments. 64REM Note that when reading the input arguments with %1, the cmd.exe 65REM automagically converts --name=value arguments into 2 arguments "--name" 66REM followed by "value". Dx has been changed to know how to deal with that. 67set params= 68 69set output= 70set disableKeepAnnotated= 71 72:firstArg 73if [%1]==[] goto endArgs 74 75 if %1 NEQ --output goto notOut 76 set "output=%2" 77 shift 78 shift 79 goto firstArg 80 81:notOut 82 83 if %1 NEQ --disable-annotation-resolution-workaround goto notDisable 84 set "disableKeepAnnotated=%1" 85 shift 86 goto firstArg 87 88:notDisable 89 if defined params goto usage 90 set params=%1 91 shift 92 goto firstArg 93 94:endArgs 95if defined params ( goto makeTmpJar ) else ( goto usage ) 96 97:makeTmpJar 98set "tmpJar=%TMP%\mainDexClasses-%RANDOM%.tmp.jar" 99if exist "%tmpJar%" goto makeTmpJar 100echo "" > "%tmpJar%" 101set "exitStatus=0" 102 103 104call "%proguard%" -injars %params% -dontwarn -forceprocessing -outjars "%tmpJar%" -libraryjars "%shrinkedAndroidJar%" -dontoptimize -dontobfuscate -dontpreverify -include "%baserules%" 1>nul 105 106if DEFINED output goto redirect 107call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder "%disableKeepAnnotated%" "%tmpJar%" "%params%" 108goto afterClassReferenceListBuilder 109:redirect 110call "%java_exe%" -Djava.ext.dirs="%frameworkdir%" com.android.multidex.MainDexListBuilder "%disableKeepAnnotated%" "%tmpJar%" "%params%" 1>"%output%" 111:afterClassReferenceListBuilder 112 113del %tmpJar% 114exit /b 115 116:usage 117echo "Usage : %0 [--output <output file>] <application path>" 118exit /b 1 119