This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.xml
293 lines (230 loc) · 9.52 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
293
<?xml version="1.0" encoding="UTF-8"?>
<project default="all" name="ane.build.core">
<!-- SCRIPTS -->
<scriptdef language="javascript" name="lower">
<attribute name="name" />
<attribute name="value" />
<![CDATA[
project.setProperty( attributes.get( "name" ),
(attributes.get( "value" )+"").toLowerCase() );
]]>
</scriptdef>
<scriptdef language="javascript" name="topath">
<attribute name="name" />
<attribute name="value" />
<![CDATA[
project.setProperty( attributes.get( "name" ),
(attributes.get( "value" )+"").replace( /\./g, "/" ) );
]]>
</scriptdef>
<condition property="is_windows">
<os family="windows"/>
</condition>
<!-- CONFIGURATION -->
<property file="./build_config/build.config" description="build properties" />
<property file="${android.dir}/project.properties" description="android build properties" />
<property name="android.target" value="${target}" />
<lower name="project.packagename" value="${project.name}" />
<property name="actionscript.name" value="distriqt.extension.${project.packagename}.swc" />
<property name="default.name" value="distriqt.extension.${project.packagename}.default.swc" />
<property name="android.name" value="classes.jar" />
<topath name="android.packagepath" value="${android.package}" />
<property name="AIR_SDK_HOME" value="${air.sdk}" />
<taskdef resource="flexTasks.tasks" classpath="${air.sdk}/ant/lib/flexTasks.jar" />
<property name="output.tmpdir" value=".tmp" />
<!-- SETUP ANDROID PROJECT -->
<target name="create_android_project">
<delete dir="${android.dir}/app" />
<!-- APP -->
<mkdir dir="${android.dir}/app" />
<copy todir="${android.dir}/app" overwrite="true" >
<fileset dir="${android.dir}/template/app">
<include name="**/*" />
</fileset>
<filterchain>
<tokenfilter>
<replacestring from="@PACKAGE@" to="${android.package}"/>
</tokenfilter>
</filterchain>
</copy>
<!-- JAVA CODE -->
<mkdir dir="${android.dir}/app/src/main/java/${android.packagepath}" />
<copy todir="${android.dir}/app/src/main/java/${android.packagepath}" overwrite="true" >
<fileset dir="${android.dir}/template/java">
<include name="*" />
</fileset>
<filterchain>
<tokenfilter>
<replacestring from="@PACKAGE@" to="${android.package}"/>
</tokenfilter>
</filterchain>
</copy>
<!-- RESOURCES -->
<mkdir dir="${android.dir}/app/src/main/res" />
<copy todir="${android.dir}/app/src/main/res" >
<fileset dir="${android.resources}">
<include name="**/*" />
<exclude name="PUT_YOUR_RESOURCES_HERE" />
</fileset>
</copy>
<!-- PROPERTIES -->
<copy file="${android.dir}/template/local.properties" tofile="${android.dir}/local.properties" overwrite="true" >
<filterchain>
<tokenfilter>
<replacestring from="@ANDROIDSDK@" to="${android.sdk}"/>
</tokenfilter>
</filterchain>
</copy>
<!-- FlashRuntimeExtensions -->
<copy file="${air.sdk}/lib/android/FlashRuntimeExtensions.jar" todir="${android.dir}/app/libs" overwrite="true" >
</copy>
</target>
<!-- ACTIONSCRIPT LIBRARIES -->
<target name="build_actionscript" >
<echo message="Building actionscript library..."/>
<compc output="${actionscript.dir}/bin/${actionscript.name}" debug="${DEBUG_MODE}" swf-version="17">
<load-config filename="${air.sdk}/frameworks/air-config.xml" />
<source-path path-element="${actionscript.dir}/src" />
<include-sources dir="${actionscript.dir}/src" includes="*" />
</compc>
<echo message="done"/>
</target>
<target name="clean_actionscript" >
<delete dir="${actionscript.dir}/bin" />
</target>
<target name="build_default" >
<echo message="Building default library..."/>
<compc output="${default.dir}/bin/${default.name}" debug="false" swf-version="17">
<load-config filename="${air.sdk}/frameworks/air-config.xml" />
<source-path path-element="${default.dir}/src" />
<include-sources dir="${default.dir}/src" includes="*" />
</compc>
<echo message="done"/>
</target>
<target name="clean_default" >
<delete dir="${default.dir}/bin" />
</target>
<!-- ANDROID LIBRARY -->
<target name="build_android" depends="create_android_project">
<echo message="Building Android library..."/>
<antcall target="build_android_osx" />
<antcall target="build_android_windows" />
</target>
<target name="build_android_osx" unless="is_windows">
<delete>
<fileset dir="${android.dir}" defaultexcludes="false">
<include name="**/.DS_Store" />
</fileset>
</delete>
<exec executable="./gradlew" dir="${android.dir}">
<arg line="wrapper" />
</exec>
<exec executable="./gradlew" dir="${android.dir}">
<arg line="assemble" />
</exec>
</target>
<target name="build_android_windows" if="is_windows">
<exec executable="cmd" dir="${android.dir}">
<arg value="/c"/>
<arg value="gradlew.bat"/>
<arg value="wrapper" />
</exec>
<exec executable="cmd" dir="${android.dir}">
<arg value="/c"/>
<arg value="gradlew.bat"/>
<arg value="assemble" />
</exec>
</target>
<target name="package_android" description="Copy Android files for packaging" >
<copy file="${android.dir}/app/build/intermediates/packaged-classes/release/${android.name}" todir="${android.dir}/${output.dir}" />
<copy includeEmptyDirs="false" overwrite="true" todir="${android.dir}/${output.dir}/${android.resdir}">
<fileset dir="${android.dir}/app/src/main/res/" />
</copy>
<antcall target="setup_platform_options_android" />
</target>
<target name="setup_platform_options_android" >
<copy file="./build_config/extension.xml" tofile="./build_config/extension.build.xml" overwrite="true" >
<filterchain>
<tokenfilter>
<replacestring from="@VERSION@" to="${version}"/>
<replacestring from="@PACKAGE@" to="${android.package}"/>
</tokenfilter>
</filterchain>
</copy>
<copy file="./build_config/platform_android.xml" tofile="./build_config/platform_android.build.xml" overwrite="true" >
<filterchain>
<tokenfilter>
<replacestring from="@PACKAGE@" to="${android.package}"/>
<replacestring from="@RESDIR@" to="${android.resdir}"/>
</tokenfilter>
</filterchain>
</copy>
</target>
<target name="clean_android">
<delete file="build_config/platform_android.build.xml"/>
<delete dir="${android.dir}/${output.tmpdir}" />
<delete dir="${android.dir}/${output.dir}" />
<delete dir="${android.dir}/build" />
<delete dir="${android.dir}/app" />
</target>
<!-- BUILD -->
<target name="build" description="Build Libraries" >
<antcall target="build_actionscript" />
<antcall target="build_default" />
<antcall target="build_android" />
</target>
<!-- PACKAGE -->
<target name="package" description="Package ANE">
<mkdir dir="${output.dir}" />
<antcall target="package_android" />
<!-- Copy over library.swf to each platform output -->
<mkdir dir="${output.tmpdir}" />
<unzip src="${actionscript.dir}/bin/${actionscript.name}" dest="${output.tmpdir}" overwrite="true"/>
<copy file="${output.tmpdir}/library.swf" todir="${android.dir}/${output.dir}" failonerror="true" />
<delete dir="${output.tmpdir}" />
<unzip src="${default.dir}/bin/${default.name}" dest="${default.dir}/bin" overwrite="true"/>
<delete file="${default.dir}/bin/catalog.xml" />
<!-- Compile ANE -->
<antcall target="compile_windows" />
<antcall target="compile_osx" />
<delete file="${android.dir}/${output.dir}/library.swf" />
<delete file="${default.dir}/bin/library.swf" />
</target>
<target name="compile_windows" if="is_windows">
<exec executable="${air.sdk}/bin/adt.bat" failonerror="true">
<arg value="-package"/>
<arg value="-target"/>
<arg value="ane"/>
<arg value="${output.dir}/${output.name}"/>
<arg value="./build_config/extension.build.xml"/>
<arg line="-swc ${actionscript.dir}/bin/${actionscript.name}"/>
<arg line="-platform Android-ARM -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-ARM64 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-x86 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-x64 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform default -C ${default.dir}/bin ."/>
</exec>
</target>
<target name="compile_osx" unless="is_windows">
<exec executable="${air.sdk}/bin/adt" failonerror="true">
<arg value="-package"/>
<arg value="-target"/>
<arg value="ane"/>
<arg value="${output.dir}/${output.name}"/>
<arg value="./build_config/extension.build.xml"/>
<arg line="-swc ${actionscript.dir}/bin/${actionscript.name}"/>
<arg line="-platform Android-ARM -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-ARM64 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-x86 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform Android-x64 -platformoptions ./build_config/platform_android.build.xml -C ${android.dir}/${output.dir} ."/>
<arg line="-platform default -C ${default.dir}/bin ."/>
</exec>
</target>
<!-- CLEAN -->
<target name="clean">
<antcall target="clean_actionscript" />
<antcall target="clean_default" />
<antcall target="clean_android" />
</target>
<target name="all" depends="clean, build, package" />
</project>