summaryrefslogtreecommitdiffstats
path: root/build/android/ant/sdk-targets.xml
blob: 59913e3b55c2a81f8d4056376cc368c816f2fef7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) 2012 The Chromium Authors. All rights reserved.
  Use of this source code is governed by a BSD-style license that can be
  found in the LICENSE file.
-->
<project name="chrome_sdk_overrides" >
  <!--
    Redefinition of targets used by SDK tools.
    Supported version: SDK tools revision 20.

    SDK tools do not allow easy way of extending classpaths
    for aidl and javac. This file defines targets which can be used to
    override targets used by tools.
  -->

  <!--
    Override the -compile target.
    This target requires 'javac.custom.classpath' to be set to reference
    of classpath to be used for javac. Also accepts custom path for
    sources: 'javac.custom.sourcepath'.
  -->
  <target
      name="-compile"
      depends="-build-setup, -pre-build, -code-gen, -pre-compile">
    <do-only-if-manifest-hasCode elseText="hasCode = false. Skipping..." >
      <!-- If souce path is not set, then use the default value -->
      <if>
        <condition>
          <not>
            <isreference refid="javac.custom.sourcepath"/>
          </not>
        </condition>
        <then>
          <path id="javac.custom.sourcepath">
            <pathelement path="${source.absolute.dir}"/>
            <pathelement path="${gen.absolute.dir}"/>
          </path>
        </then>
      </if>
      <javac
          bootclasspathref="project.target.class.path"
          classpathref="javac.custom.classpath"
          debug="true"
          destdir="${out.classes.absolute.dir}"
          encoding="${java.encoding}"
          extdirs=""
          fork="${need.javac.fork}"
          includeantruntime="false"
          source="${java.source}"
          target="${java.target}"
          verbose="${verbose}">
        <src path="${source.absolute.dir}"/>
        <src path="${gen.absolute.dir}"/>
        <src>
          <path refid="javac.custom.sourcepath"/>
        </src>
        <compilerarg line="${java.compilerargs}"/>
      </javac>
      <!--
        If the project is instrumented, then instrument the classes
        TODO(shashishekhar): Add option to override emma filter.
      -->
      <if condition="${build.is.instrumented}">
        <then>
          <echo level="info">
            Instrumenting classes from ${out.absolute.dir}/classes...
          </echo>
          <!-- build the default filter to remove R, Manifest, BuildConfig -->
          <getemmafilter
              appPackage="${project.app.package}"
              filterOut="emma.default.filter"
              libraryPackagesRefId="project.library.packages"/>
          <!--
            Define where the .em file is output.
            This may have been setup already if this is a library.
          -->
          <property name="emma.coverage.absolute.file"
              location="${out.absolute.dir}/coverage.em"/>
          <!-- It only instruments class files, not any external libs -->

          <emma enabled="true">
            <instr
                instrpath="${out.absolute.dir}/classes"
                metadatafile="${emma.coverage.absolute.file}"
                mode="overwrite"
                outdir="${out.absolute.dir}/classes"
                verbosity="${verbosity}">
              <filter excludes="${emma.default.filter}"/>
              <filter value="${emma.filter}"/>
            </instr>
          </emma>
        </then>
      </if>
    </do-only-if-manifest-hasCode>
  </target>

  <!--
    For debug builds, the Android SDK tools create a key in ~/.android and sign the build with it.
    This has caused all kinds of issues. Instead, the debug build should be signed with a key in
    build/android/ant. The SDK tools do not provide any support for overriding that behavior and so
    instead one must use the hack below.
  -->

  <!-- Disables automatic signing. -->
  <property name="build.is.signing.debug" value="false"/>

  <!-- TODO(cjhopman): Remove this property when all gyp files define the CHROMIUM_SRC property. -->
  <property name="CHROMIUM_SRC" value="${PRODUCT_DIR}/../.." />

  <property name="key.store" value="${CHROMIUM_SRC}/build/android/ant/chromium-debug.keystore"/>
  <property name="key.store.password" value="chromium"/>
  <property name="key.alias" value="chromiumdebugkey"/>
  <property name="key.alias.password" value="chromium"/>

  <!-- SDK tools assume that out.packaged.file is signed and name it "...-unaligned" -->
  <property name="out.packaged.file"
    value="${out.dir}/${ant.project.name}-debug-unsigned.apk" />
  <property name="out.unaligned.file"
    value="${out.dir}/${ant.project.name}-debug-unaligned.apk" />

  <!-- By default, the SDK tools build only aligns the APK in the -do-debug target. -->
  <target name="-do-debug"
      depends="-set-debug-mode, -debug-obfuscation-check, -package, -post-package">
    <!-- only create apk if *not* a library project -->
    <do-only-if-not-library elseText="Library project: do not create apk..." >
      <sequential>
        <!-- Signs the APK -->
        <echo level="info">Signing final apk...</echo>
        <signapk
          input="${out.packaged.file}"
          output="${out.unaligned.file}"
          keystore="${key.store}"
          storepass="${key.store.password}"
          alias="${key.alias}"
          keypass="${key.alias.password}"/>

        <!-- Zip aligns the APK -->
        <zipalign-helper
          in.package="${out.unaligned.file}"
          out.package="${out.final.file}" />
        <echo level="info">Release Package: ${out.final.file}</echo>
      </sequential>
    </do-only-if-not-library>
    <record-build-info />
  </target>
</project>