Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
michael@0 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
michael@0 | 2 | <!-- |
michael@0 | 3 | Copyright (c) 2012 The Chromium Authors. All rights reserved. |
michael@0 | 4 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 5 | found in the LICENSE file. |
michael@0 | 6 | --> |
michael@0 | 7 | <project name="chrome_sdk_overrides" > |
michael@0 | 8 | <!-- |
michael@0 | 9 | Redefinition of targets used by SDK tools. |
michael@0 | 10 | Supported version: SDK tools revision 20. |
michael@0 | 11 | |
michael@0 | 12 | SDK tools do not allow easy way of extending classpaths |
michael@0 | 13 | for aidl and javac. This file defines targets which can be used to |
michael@0 | 14 | override targets used by tools. |
michael@0 | 15 | --> |
michael@0 | 16 | <target name="-pre-compile"> |
michael@0 | 17 | <!-- |
michael@0 | 18 | Remove all .class files from the output directory. This prevents inclusion of incorrect .class |
michael@0 | 19 | files in the final apk. For example, if a .java file was deleted, the apk should not contain |
michael@0 | 20 | the .class files for that .java from previous builds. |
michael@0 | 21 | --> |
michael@0 | 22 | <delete> |
michael@0 | 23 | <fileset dir="${out.classes.absolute.dir}" includes="**/*.class"/> |
michael@0 | 24 | </delete> |
michael@0 | 25 | </target> |
michael@0 | 26 | |
michael@0 | 27 | <!-- |
michael@0 | 28 | Override the -compile target. |
michael@0 | 29 | This target requires 'javac.custom.classpath' to be set to reference |
michael@0 | 30 | of classpath to be used for javac. Also accepts custom path for |
michael@0 | 31 | sources: 'javac.custom.sourcepath'. |
michael@0 | 32 | --> |
michael@0 | 33 | <target |
michael@0 | 34 | name="-compile" |
michael@0 | 35 | depends="-build-setup, -pre-build, -code-gen, -pre-compile"> |
michael@0 | 36 | <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..." > |
michael@0 | 37 | <!-- If javac.srcdirs.additional isn't set, set it to an empty path. --> |
michael@0 | 38 | <if> |
michael@0 | 39 | <condition> |
michael@0 | 40 | <not> |
michael@0 | 41 | <isreference refid="javac.srcdirs.additional"/> |
michael@0 | 42 | </not> |
michael@0 | 43 | </condition> |
michael@0 | 44 | <then> |
michael@0 | 45 | <path id="javac.srcdirs.additional"/> |
michael@0 | 46 | </then> |
michael@0 | 47 | </if> |
michael@0 | 48 | <javac |
michael@0 | 49 | bootclasspathref="project.target.class.path" |
michael@0 | 50 | classpathref="javac.custom.classpath" |
michael@0 | 51 | debug="true" |
michael@0 | 52 | destdir="${out.classes.absolute.dir}" |
michael@0 | 53 | encoding="${java.encoding}" |
michael@0 | 54 | extdirs="" |
michael@0 | 55 | fork="${need.javac.fork}" |
michael@0 | 56 | includeantruntime="false" |
michael@0 | 57 | source="${java.source}" |
michael@0 | 58 | target="${java.target}" |
michael@0 | 59 | verbose="${verbose}"> |
michael@0 | 60 | <src path="${source.absolute.dir}"/> |
michael@0 | 61 | <src path="${gen.absolute.dir}"/> |
michael@0 | 62 | <src> |
michael@0 | 63 | <path refid="javac.srcdirs.additional"/> |
michael@0 | 64 | </src> |
michael@0 | 65 | <compilerarg line="${java.compilerargs}"/> |
michael@0 | 66 | </javac> |
michael@0 | 67 | <!-- |
michael@0 | 68 | If the project is instrumented, then instrument the classes |
michael@0 | 69 | TODO(shashishekhar): Add option to override emma filter. |
michael@0 | 70 | --> |
michael@0 | 71 | <if condition="${build.is.instrumented}"> |
michael@0 | 72 | <then> |
michael@0 | 73 | <echo level="info"> |
michael@0 | 74 | Instrumenting classes from ${out.absolute.dir}/classes... |
michael@0 | 75 | </echo> |
michael@0 | 76 | <!-- build the default filter to remove R, Manifest, BuildConfig --> |
michael@0 | 77 | <getemmafilter |
michael@0 | 78 | appPackage="${project.app.package}" |
michael@0 | 79 | filterOut="emma.default.filter" |
michael@0 | 80 | libraryPackagesRefId="project.library.packages"/> |
michael@0 | 81 | <!-- |
michael@0 | 82 | Define where the .em file is output. |
michael@0 | 83 | This may have been setup already if this is a library. |
michael@0 | 84 | --> |
michael@0 | 85 | <property name="emma.coverage.absolute.file" |
michael@0 | 86 | location="${out.absolute.dir}/coverage.em"/> |
michael@0 | 87 | <!-- It only instruments class files, not any external libs --> |
michael@0 | 88 | |
michael@0 | 89 | <emma enabled="true"> |
michael@0 | 90 | <instr |
michael@0 | 91 | instrpath="${out.absolute.dir}/classes" |
michael@0 | 92 | metadatafile="${emma.coverage.absolute.file}" |
michael@0 | 93 | mode="overwrite" |
michael@0 | 94 | outdir="${out.absolute.dir}/classes" |
michael@0 | 95 | verbosity="${verbosity}"> |
michael@0 | 96 | <filter excludes="${emma.default.filter}"/> |
michael@0 | 97 | <filter value="${emma.filter}"/> |
michael@0 | 98 | </instr> |
michael@0 | 99 | </emma> |
michael@0 | 100 | </then> |
michael@0 | 101 | </if> |
michael@0 | 102 | <!-- |
michael@0 | 103 | If the project needs a test jar then generate a jar containing |
michael@0 | 104 | all compiled classes and referenced jars. |
michael@0 | 105 | project.is.testapp is set by Android's ant build system based on the |
michael@0 | 106 | target's manifest. It is true only for instrumentation apks. |
michael@0 | 107 | --> |
michael@0 | 108 | <if condition="${project.is.testapp}"> |
michael@0 | 109 | <then> |
michael@0 | 110 | <echo level="info">Creating test jar file: |
michael@0 | 111 | ${ant.project.name}-debug.jar</echo> |
michael@0 | 112 | <property-location name="create.test.jar.file" |
michael@0 | 113 | location="${CHROMIUM_SRC}/build/android/ant/create-test-jar.js"/> |
michael@0 | 114 | <script language="javascript" src="${create.test.jar.file}"/> |
michael@0 | 115 | </then> |
michael@0 | 116 | </if> |
michael@0 | 117 | |
michael@0 | 118 | </do-only-if-manifest-hasCode> |
michael@0 | 119 | </target> |
michael@0 | 120 | |
michael@0 | 121 | <!-- |
michael@0 | 122 | For debug builds, the Android SDK tools create a key in ~/.android and sign the build with it. |
michael@0 | 123 | This has caused all kinds of issues. Instead, the debug build should be signed with a key in |
michael@0 | 124 | build/android/ant. The SDK tools do not provide any support for overriding that behavior and so |
michael@0 | 125 | instead one must use the hack below. |
michael@0 | 126 | --> |
michael@0 | 127 | |
michael@0 | 128 | <!-- Disables automatic signing. --> |
michael@0 | 129 | <property name="build.is.signing.debug" value="false"/> |
michael@0 | 130 | |
michael@0 | 131 | <!-- TODO(cjhopman): Remove this property when all gyp files define the CHROMIUM_SRC property. --> |
michael@0 | 132 | <property name="CHROMIUM_SRC" value="${PRODUCT_DIR}/../.." /> |
michael@0 | 133 | |
michael@0 | 134 | <property name="key.store" value="${CHROMIUM_SRC}/build/android/ant/chromium-debug.keystore"/> |
michael@0 | 135 | <property name="key.store.password" value="chromium"/> |
michael@0 | 136 | <property name="key.alias" value="chromiumdebugkey"/> |
michael@0 | 137 | <property name="key.alias.password" value="chromium"/> |
michael@0 | 138 | |
michael@0 | 139 | <!-- SDK tools assume that out.packaged.file is signed and name it "...-unaligned" --> |
michael@0 | 140 | <property name="out.packaged.file" |
michael@0 | 141 | value="${apks.dir}/${ant.project.name}-debug-unsigned.apk" /> |
michael@0 | 142 | <property name="out.unaligned.file" |
michael@0 | 143 | value="${apks.dir}/${ant.project.name}-debug-unaligned.apk" /> |
michael@0 | 144 | |
michael@0 | 145 | <!-- By default, the SDK tools build only aligns the APK in the -do-debug target. --> |
michael@0 | 146 | <target name="-do-debug" |
michael@0 | 147 | depends="-set-debug-mode, -debug-obfuscation-check, -package, -post-package"> |
michael@0 | 148 | <!-- only create apk if *not* a library project --> |
michael@0 | 149 | <do-only-if-not-library elseText="Library project: do not create apk..." > |
michael@0 | 150 | <sequential> |
michael@0 | 151 | <!-- Signs the APK --> |
michael@0 | 152 | <echo level="info">Signing final apk...</echo> |
michael@0 | 153 | <signapk |
michael@0 | 154 | input="${out.packaged.file}" |
michael@0 | 155 | output="${out.unaligned.file}" |
michael@0 | 156 | keystore="${key.store}" |
michael@0 | 157 | storepass="${key.store.password}" |
michael@0 | 158 | alias="${key.alias}" |
michael@0 | 159 | keypass="${key.alias.password}"/> |
michael@0 | 160 | |
michael@0 | 161 | <!-- Zip aligns the APK --> |
michael@0 | 162 | <zipalign-helper |
michael@0 | 163 | in.package="${out.unaligned.file}" |
michael@0 | 164 | out.package="${out.final.file}" /> |
michael@0 | 165 | <echo level="info">Release Package: ${out.final.file}</echo> |
michael@0 | 166 | </sequential> |
michael@0 | 167 | </do-only-if-not-library> |
michael@0 | 168 | <record-build-info /> |
michael@0 | 169 | </target> |
michael@0 | 170 | |
michael@0 | 171 | <path id="native.libs.gdbserver"> |
michael@0 | 172 | <fileset file="${android.gdbserver}"/> |
michael@0 | 173 | </path> |
michael@0 | 174 | |
michael@0 | 175 | <target name="-post-compile"> |
michael@0 | 176 | <!-- |
michael@0 | 177 | Copy gdbserver to main libs directory if building a non-instrumentation debug apk. |
michael@0 | 178 | TODO(jrg): For now, Chrome on Android always builds native code |
michael@0 | 179 | as Release and java/ant as Debug, which means we always install |
michael@0 | 180 | gdbserver. Resolve this discrepancy, possibly by making this |
michael@0 | 181 | Release Official build java/ant as Release. |
michael@0 | 182 | --> |
michael@0 | 183 | <if> |
michael@0 | 184 | <condition> |
michael@0 | 185 | <and> |
michael@0 | 186 | <equals arg1="${build.target}" arg2="debug"/> |
michael@0 | 187 | <isfalse value="${project.is.testapp}"/> |
michael@0 | 188 | </and> |
michael@0 | 189 | </condition> |
michael@0 | 190 | <then> |
michael@0 | 191 | <echo message="Copying gdbserver to the apk to enable native debugging"/> |
michael@0 | 192 | <copy todir="${out.dir}/libs/${target.abi}"> |
michael@0 | 193 | <path refid="native.libs.gdbserver"/> |
michael@0 | 194 | </copy> |
michael@0 | 195 | </then> |
michael@0 | 196 | </if> |
michael@0 | 197 | |
michael@0 | 198 | <!-- Package all the compiled .class files into a .jar. --> |
michael@0 | 199 | <jar |
michael@0 | 200 | jarfile="${lib.java.dir}/chromium_apk_${PACKAGE_NAME}.jar" |
michael@0 | 201 | basedir="${out.classes.absolute.dir}" |
michael@0 | 202 | /> |
michael@0 | 203 | </target> |
michael@0 | 204 | |
michael@0 | 205 | <!-- |
michael@0 | 206 | Override obfuscate target to pass javac.custom.classpath to Proguard. SDK tools do not provide |
michael@0 | 207 | any way to pass custom class paths to Proguard. |
michael@0 | 208 | --> |
michael@0 | 209 | <target name="-obfuscate"> |
michael@0 | 210 | <if condition="${proguard.enabled}"> |
michael@0 | 211 | <then> |
michael@0 | 212 | <property name="obfuscate.absolute.dir" location="${out.absolute.dir}/proguard"/> |
michael@0 | 213 | <property name="preobfuscate.jar.file" value="${obfuscate.absolute.dir}/original.jar"/> |
michael@0 | 214 | <property name="obfuscated.jar.file" value="${obfuscate.absolute.dir}/obfuscated.jar"/> |
michael@0 | 215 | <!-- input for dex will be proguard's output --> |
michael@0 | 216 | <property name="out.dex.input.absolute.dir" value="${obfuscated.jar.file}"/> |
michael@0 | 217 | |
michael@0 | 218 | <!-- Add Proguard Tasks --> |
michael@0 | 219 | <property name="proguard.jar" location="${android.tools.dir}/proguard/lib/proguard.jar"/> |
michael@0 | 220 | <taskdef name="proguard" classname="proguard.ant.ProGuardTask" classpath="${proguard.jar}"/> |
michael@0 | 221 | |
michael@0 | 222 | <!-- Set the android classpath Path object into a single property. It'll be |
michael@0 | 223 | all the jar files separated by a platform path-separator. |
michael@0 | 224 | Each path must be quoted if it contains spaces. |
michael@0 | 225 | --> |
michael@0 | 226 | <pathconvert property="project.target.classpath.value" refid="project.target.class.path"> |
michael@0 | 227 | <firstmatchmapper> |
michael@0 | 228 | <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> |
michael@0 | 229 | <identitymapper/> |
michael@0 | 230 | </firstmatchmapper> |
michael@0 | 231 | </pathconvert> |
michael@0 | 232 | |
michael@0 | 233 | <!-- Build a path object with all the jar files that must be obfuscated. |
michael@0 | 234 | This include the project compiled source code and any 3rd party jar |
michael@0 | 235 | files. --> |
michael@0 | 236 | <path id="project.all.classes.path"> |
michael@0 | 237 | <pathelement location="${preobfuscate.jar.file}"/> |
michael@0 | 238 | <path refid="project.all.jars.path"/> |
michael@0 | 239 | <!-- Pass javac.custom.classpath for apks. --> |
michael@0 | 240 | <path refid="javac.custom.classpath"/> |
michael@0 | 241 | </path> |
michael@0 | 242 | <!-- Set the project jar files Path object into a single property. It'll be |
michael@0 | 243 | all the jar files separated by a platform path-separator. |
michael@0 | 244 | Each path must be quoted if it contains spaces. |
michael@0 | 245 | --> |
michael@0 | 246 | <pathconvert property="project.all.classes.value" refid="project.all.classes.path"> |
michael@0 | 247 | <firstmatchmapper> |
michael@0 | 248 | <regexpmapper from='^([^ ]*)( .*)$$' to='"\1\2"'/> |
michael@0 | 249 | <identitymapper/> |
michael@0 | 250 | </firstmatchmapper> |
michael@0 | 251 | </pathconvert> |
michael@0 | 252 | |
michael@0 | 253 | <!-- Turn the path property ${proguard.config} from an A:B:C property |
michael@0 | 254 | into a series of includes: -include A -include B -include C |
michael@0 | 255 | suitable for processing by the ProGuard task. Note - this does |
michael@0 | 256 | not include the leading '-include "' or the closing '"'; those |
michael@0 | 257 | are added under the <proguard> call below. |
michael@0 | 258 | --> |
michael@0 | 259 | <path id="proguard.configpath"> |
michael@0 | 260 | <pathelement path="${proguard.config}"/> |
michael@0 | 261 | </path> |
michael@0 | 262 | <pathconvert pathsep='" -include "' property="proguard.configcmd" |
michael@0 | 263 | refid="proguard.configpath"/> |
michael@0 | 264 | |
michael@0 | 265 | <mkdir dir="${obfuscate.absolute.dir}"/> |
michael@0 | 266 | <delete file="${preobfuscate.jar.file}"/> |
michael@0 | 267 | <delete file="${obfuscated.jar.file}"/> |
michael@0 | 268 | <jar basedir="${out.classes.absolute.dir}" |
michael@0 | 269 | destfile="${preobfuscate.jar.file}"/> |
michael@0 | 270 | <proguard> |
michael@0 | 271 | -include "${proguard.configcmd}" |
michael@0 | 272 | -include "${out.absolute.dir}/proguard.txt" |
michael@0 | 273 | -injars ${project.all.classes.value} |
michael@0 | 274 | -outjars "${obfuscated.jar.file}" |
michael@0 | 275 | -libraryjars ${project.target.classpath.value} |
michael@0 | 276 | -dump "${obfuscate.absolute.dir}/dump.txt" |
michael@0 | 277 | -printseeds "${obfuscate.absolute.dir}/seeds.txt" |
michael@0 | 278 | -printusage "${obfuscate.absolute.dir}/usage.txt" |
michael@0 | 279 | -printmapping "${obfuscate.absolute.dir}/mapping.txt" |
michael@0 | 280 | </proguard> |
michael@0 | 281 | </then> |
michael@0 | 282 | </if> |
michael@0 | 283 | </target> |
michael@0 | 284 | </project> |