-
Notifications
You must be signed in to change notification settings - Fork 57
/
build.xml
292 lines (259 loc) · 12.3 KB
/
build.xml
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
<?xml version="1.0" encoding="UTF-8"?>
<project name="IRB" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- if sdk.dir was not set from one of the property file, then
get it from the ANDROID_HOME env var.
This must be done before we load project.properties since
the proguard config can use sdk.dir -->
<property environment="env" />
<condition property="sdk.dir" value="${env.ANDROID_HOME}">
<isset property="env.ANDROID_HOME" />
</condition>
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable."
unless="sdk.dir"
/>
<!--
Import per project custom build rules if present at the root of the project.
This is the place to put custom intermediary targets such as:
-pre-build
-pre-compile
-post-compile (This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir})
-post-package
-post-build
-pre-clean
-->
<import file="custom_rules.xml" optional="true" />
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
<!-- BEGIN added by Ruboto -->
<property name="second_dex_file" value="${out.absolute.dir}/classes2.dex" />
<macrodef name="multi-dex-helper">
<element name="external-libs" optional="yes" />
<sequential>
<union id="out.dex.jar.input.ref.union">
<resources refid="out.dex.jar.input.ref"/>
</union>
<if>
<condition>
<uptodate targetfile="${out.absolute.dir}/classes.dex" >
<srcfiles dir="${out.classes.absolute.dir}" includes="**/*.class"/>
<srcresources refid="out.dex.jar.input.ref.union"/>
</uptodate>
</condition>
<then>
<echo>Java classes and jars are unchanged.</echo>
</then>
<else>
<echo>Converting compiled files and external libraries into ${out.absolute.dir} (multi-dex)</echo>
<delete file="${out.absolute.dir}/classes2.dex"/>
<echo>Dexing ${out.classes.absolute.dir} and ${toString:out.dex.jar.input.ref}</echo>
<apply executable="${dx}" failonerror="true" parallel="true">
<arg value="--dex" />
<arg value="--multi-dex" />
<arg value="--output=${out.absolute.dir}" />
<arg line="${jumbo.option}" />
<arg line="${verbose.option}" />
<arg path="${out.classes.absolute.dir}" />
<path refid="out.dex.jar.input.ref" />
<external-libs />
</apply>
<sleep seconds="1"/>
</else>
</if>
</sequential>
</macrodef>
<macrodef name="dex-helper">
<element name="external-libs" optional="yes" />
<attribute name="nolocals" default="false" />
<sequential>
<!-- sets the primary input for dex. If a pre-dex task sets it to
something else this has no effect -->
<property name="out.dex.input.absolute.dir" value="${out.classes.absolute.dir}" />
<!-- set the secondary dx input: the project (and library) jar files
If a pre-dex task sets it to something else this has no effect -->
<if>
<condition>
<isreference refid="out.dex.jar.input.ref" />
</condition>
<else>
<path id="out.dex.jar.input.ref">
<path refid="project.all.jars.path" />
</path>
</else>
</if>
<condition property="verbose.option" value="--verbose" else="">
<istrue value="${verbose}" />
</condition>
<condition property="jumbo.option" value="--force-jumbo" else="">
<istrue value="${dex.force.jumbo}" />
</condition>
<if>
<condition>
<not>
<available file="${second_dex_file}" />
</not>
</condition>
<then>
<!-- Regular DEX process. We would prefer to use the Android SDK
ANT target, but we need to detect the "use multidex" error.
https://android.googlesource.com/platform/sdk/+/tools_r21.1/anttasks/src/com/android/ant/DexExecTask.java
-->
<mapper id="pre-dex-mapper" type="glob" from="libs/*.jar" to="bin/dexedLibs/*-dexed.jar"/>
<!-- FIXME(uwe): Output something about what we are doing -->
<apply executable="${dx}" failonerror="true" parallel="false" dest="${out.dexed.absolute.dir}" relative="true">
<arg value="--dex" />
<arg value="--output" />
<targetfile/>
<arg line="${jumbo.option}" />
<arg line="${verbose.option}" />
<fileset dir="." includes="libs/*" />
<external-libs />
<mapper refid="pre-dex-mapper"/>
</apply>
<apply executable="${dx}" resultproperty="dex.merge.result" outputproperty="dex.merge.output" parallel="true">
<arg value="--dex" />
<arg value="--output=${intermediate.dex.file}" />
<arg line="${jumbo.option}" />
<arg line="${verbose.option}" />
<arg path="${out.classes.absolute.dir}" />
<fileset dir="${out.dexed.absolute.dir}" includes="*-dexed.jar" />
<external-libs />
</apply>
<if>
<condition>
<contains string="${dex.merge.output}" substring="method ID not in [0, 0xffff]: 65536"/>
</condition>
<then>
<echo message="The package contains too many methods. Switching to multi-dex build." />
<multi-dex-helper>
<external-libs>
<external-libs/>
</external-libs>
</multi-dex-helper>
</then>
<else>
<echo message="${dex.merge.output}"/>
<fail status="${dex.merge.result}">
<condition>
<not>
<equals arg1="${dex.merge.result}" arg2="0"/>
</not>
</condition>
</fail>
</else>
</if>
</then>
<else>
<multi-dex-helper>
<external-libs>
<external-libs/>
</external-libs>
</multi-dex-helper>
</else>
</if>
</sequential>
</macrodef>
<!-- This is copied directly from <android-sdk>/tools/ant/build.xml,
just added the "-post-package-resources" dependency -->
<target name="-package" depends="-dex, -package-resources, -post-package-resources">
<!-- only package apk if *not* a library project -->
<do-only-if-not-library elseText="Library project: do not package apk..." >
<if condition="${build.is.instrumented}">
<then>
<package-helper>
<extra-jars>
<!-- Injected from external file -->
<jarfile path="${emma.dir}/emma_device.jar" />
</extra-jars>
</package-helper>
</then>
<else>
<package-helper />
</else>
</if>
</do-only-if-not-library>
</target>
<target name="-post-package-resources">
<!-- FIXME(uwe): This is hardcoded for one extra dex file.
It should iterate over all classes?.dex files -->
<property name="second_dex_path" value="assets/classes2.jar" />
<property name="second_dex_jar" value="${out.dexed.absolute.dir}/${second_dex_path}" />
<property name="second_dex_copy" value="${out.dexed.absolute.dir}/classes.dex" />
<if>
<condition>
<and>
<available file="${second_dex_file}" />
<or>
<not>
<uptodate srcfile="${second_dex_file}" targetfile="${out.absolute.dir}/${resource.package.file.name}" />
</not>
<uptodate srcfile="${out.absolute.dir}/${resource.package.file.name}" targetfile="${out.absolute.dir}/${resource.package.file.name}.d" />
</or>
</and>
</condition>
<then>
<echo>Adding ${second_dex_path} to ${resource.package.file.name}</echo>
<exec executable="aapt" dir="${out.dexed.absolute.dir}">
<arg line='remove -v "${out.absolute.dir}/${resource.package.file.name}" ${second_dex_path}'/>
</exec>
<copy file="${second_dex_file}" tofile="${second_dex_copy}"/>
<mkdir dir="${out.dexed.absolute.dir}/assets"/>
<zip destfile="${second_dex_jar}" basedir="${out.dexed.absolute.dir}" includes="classes.dex" />
<delete file="${second_dex_copy}"/>
<!-- FIXME(uwe): Use zip instead of aapt? -->
<exec executable="aapt" dir="${out.dexed.absolute.dir}" failonerror="true">
<arg line='add -v "${out.absolute.dir}/${resource.package.file.name}" ${second_dex_path}'/>
</exec>
<!-- EMXIF -->
</then>
</if>
</target>
<!-- END added by Ruboto -->
</project>