-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.xml
285 lines (224 loc) · 11.2 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
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright: (c) 2014. Turtsevich Alexander
~
~ Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.html
-->
<project default="build.all" basedir="." name="Air native extension">
<property name="project.dir" location="."/>
<property environment="env" description="Environment variables"/>
<property file="local.build.properties" description="Common properties for mac/win"/>
<condition property="isWindows" description="Is set if current OS is MS Windows">
<os family="windows"/>
</condition>
<condition property="isMac" description="Is set if current OS is Mac OS X">
<and>
<os family="mac"/>
<os family="unix"/>
</and>
</condition>
<condition property="platform" value="Windows-x86" else="MacOS-x86">
<isset property="isWindows"/>
</condition>
<condition property="hidapi.native.name" value="hidapi.dll" else="hidapi.framework">
<isset property="isWindows"/>
</condition>
<property name="native.dir" location="${project.dir}/hidapi/hidapi_native"/>
<!--Air SDK-->
<property name="sdk.dir" location="${env.AIR_SDK_HOME}" description="Adobe Air SDK home"/>
<condition property="amxmlc" value="${sdk.dir}/bin/amxmlc.bat" else="${sdk.dir}/bin/amxmlc" description="Air mxmlc compiler">
<isset property="isWindows"/>
</condition>
<condition property="adt" value="${sdk.dir}/bin/adt.bat" else="${sdk.dir}/bin/adt" description="Air packager">
<isset property="isWindows"/>
</condition>
<condition property="acompc" value="${sdk.dir}/bin/acompc.bat" else="${sdk.dir}/bin/acompc" description="Air library compiler">
<isset property="isWindows"/>
</condition>
<condition property="aasdoc" value="${sdk.dir}/bin/aasdoc.bat" else="${sdk.dir}/bin/aasdoc" description="Air documentation compiler">
<isset property="isWindows"/>
</condition>
<condition property="installer.name" value="${application}Installer.exe" else="${application}Installer.dmg" description="Application package name">
<isset property="isWindows"/>
</condition>
<property name="release.dir" location="${project.dir}/release"/>
<property name="app.dir" location="${project.dir}/application"/>
<property name="app.lib.dir" location="${app.dir}/lib"/>
<property name="app.ext.dir" location="${app.dir}/extensions"/>
<property name="app.ext.unpacked.dir" location="${app.ext.dir}/unpacked"/>
<property name="hidapi.dir" location="${project.dir}/hidapi/hidapi_ane/"/>
<property name="hidapi.doc.dir" location="${project.dir}/hidapi/doc/"/>
<property name="hidapi.src.dir" location="${hidapi.dir}/src"/>
<property name="app.src.dir" location="${app.dir}/src"/>
<!--keystore-->
<property name="keystore" location="${project.dir}/${keystore.name}"/>
<target name="build.all" description="Build all modules and create application installer">
<available file="${env.AIR_SDK_HOME}" property="sdk.set"/>
<fail message="AIR_SDK_HOME is not set or does not exist (${env.AIR_SDK_HOME})">
<condition>
<not>
<isset property="sdk.set"/>
</not>
</condition>
</fail>
<info title="Build all" description="Build all modules and create application installer"/>
<echo message="AIR_SDK_HOME: ${sdk.dir}"/>
<echo message=" PLATFORM: ${platform}"/>
<echo message=" warnings: ${warnings}"/>
<echo message=" debug: ${debug}"/>
<antcall target="clean"/>
<antcall target="build.extension"/>
<antcall target="create.extension.package"/>
<antcall target="build.application"/>
<antcall target="create.application.package"/>
</target>
<target name="distribute" description="Collect all build artifacts">
<info title="Distribute" description="Collect all build artifacts"/>
<delete dir="${release.dir}" failonerror="true"/>
<mkdir dir="${release.dir}"/>
<copy file="${app.lib.dir}/${hidapi}.swc" todir="${release.dir}"/>
<copy file="${app.ext.dir}/${hidapi}.ane" todir="${release.dir}"/>
<copy file="${project.dir}/${installer.name}" todir="${release.dir}"/>
<antcall target="hidapi.generate.doc"/>
<zip zipfile="${release.dir}/hidapi.zip">
<fileset dir="${hidapi.doc.dir}">
<include name="**" />
</fileset>
</zip>
<info title="Distribute success" description="Release: ${release.dir}/${installer.name}"/>
</target>
<target name="build.application" description="Build Air application">
<info title="Build application" description="Build Air application"/>
<exec executable="${amxmlc}" failonerror="true">
<arg line="-locale en_US"/>
<arg line="${incremental}"/>
<arg line="-debug=${debug}"/>
<arg line="-warnings=${warnings}"/>
<arg line="-external-library-path+=${app.lib.dir}/${hidapi}.swc"/>
<arg line="-output ${app.dir}/${application}.swf"/>
<arg line="-- ${app.src.dir}/${application}.mxml"/>
</exec>
</target>
<target name="create.application.package" description="Create application package for current OS">
<info title="Create application package" description="Create application package"/>
<exec executable="${adt}" failonerror="true" dir="${app.dir}">
<arg line="-package"/>
<arg line="-XnoAneValidate"/>
<arg line="-storetype pkcs12"/>
<arg line="-keystore ${keystore}"/>
<arg line="-storepass ${storepass}"/>
<arg line="-tsa none"/>
<arg line="-target native"/>
<arg line="${project.dir}/${installer.name}"/>
<arg line="${manifest}"/>
<arg line="${application}.swf"/>
<arg line="-C ${app.src.dir} ${app.src.dir}/style/app"/>
<arg line="-extdir ${app.ext.dir}"/>
</exec>
</target>
<target name="build.extension" description="Build extension library">
<info title="Build extension" description="Build extension library"/>
<exec executable="${acompc}" failonerror="true">
<arg line="-locale en_US"/>
<arg line="${incremental}"/>
<arg line="-debug=${debug}"/>
<arg line="-warnings=${warnings}"/>
<arg line="-output ${app.lib.dir}/${hidapi}.swc"/>
<arg line="-source-path+=${hidapi.src.dir}"/>
<arg line="-include-sources=${hidapi.src.dir}"/>
</exec>
</target>
<target name="create.extension.package" description="Create native extension for current OS">
<info title="Create native extension package (ANE)" description="Create native extension"/>
<condition property="descriptor" value="${hidapi.dir}/extwin/extension.xml" else="${hidapi.dir}/extmac/extension.xml">
<isset property="isWindows"/>
</condition>
<!--temp dir for ane-->
<property name="temp" location="${native.dir}/bin"/>
<!--clean-->
<delete dir="${temp}" verbose="true" failonerror="true"/>
<!--create-->
<mkdir dir="${temp}"/>
<!--Extension descriptor-->
<copy file="${descriptor}" tofile="${temp}/extension.xml" overwrite="true" failonerror="true"/>
<basename property="swc.name" file="${app.lib.dir}/${hidapi}.swc"/>
<antcall target="build.native"/>
<!--Library-->
<copy file="${app.lib.dir}/${hidapi}.swc" todir="${temp}" overwrite="true" failonerror="true"/>
<unzip src="${app.lib.dir}/${hidapi}.swc" dest="${temp}" overwrite="true" failonemptyarchive="true">
<patternset>
<include name="library.swf"/>
</patternset>
</unzip>
<exec executable="${adt}" failonerror="true" dir="${temp}">
<arg line="-package"/>
<arg line="-storetype pkcs12"/>
<arg line="-storepass ${storepass}"/>
<arg line="-keystore ${keystore}"/>
<!--<arg line="-tsa none"/>-->
<arg line="-target ane"/>
<arg line="${app.ext.dir}/${hidapi}.ane"/>
<arg line="extension.xml"/>
<arg line="-swc ${swc.name}"/>
<arg line="-platform ${platform} library.swf ${hidapi.native.name}"/>
</exec>
</target>
<target name="hidapi.generate.doc" description="Create extension documentaion">
<delete file="${hidapi.doc.dir}"/>
<exec executable="${aasdoc}" failonerror="true">
<arg line="-output ${hidapi.doc.dir}"/>
<arg line="--doc-sources=${hidapi.src.dir}"/>
</exec>
</target>
<target name="clean" description="Remove old binaries">
<info title="Clean" description="Remove old binaries"/>
<make target="clean"/>
<delete file="${app.dir}/${application}.swf"/>
<delete file="${app.dir}/${application}.swf.cache"/>
<delete file="${app.lib.dir}/${hidapi}.swc"/>
<delete file="${app.lib.dir}/${hidapi}.swc.cache"/>
<delete file="${hidapi.dir}/${hidapi.native.name}"/>
<delete file="${app.ext.dir}/${hidapi}.ane"/>
<delete file="${hidapi.dir}/library.swf"/>
<delete file="${project.dir}/${application}Installer.exe"/>
<delete file="${release.dir}"/>
</target>
<target name="unzip.extesion.content" description="Exctract extension files for debug (-extDir)">
<delete dir="${app.ext.unpacked.dir}/${hidapi}.ane" failonerror="true"/>
<unzip src="${app.ext.dir}/${hidapi}.ane" dest="${app.ext.unpacked.dir}/${hidapi}.ane" overwrite="true"/>
</target>
<target name="build.native" description="Compile native extension">
<make target="all"/>
</target>
<macrodef name="make">
<attribute name="target" default="all"/>
<sequential>
<!--Native build tool-->
<condition property="make" value="mingw32-make" else="make" description="make tool">
<isset property="isWindows"/>
</condition>
<!--Help-->
<condition property="warn" value="[!] MinGW and MinGW-Utils binaries must be in PATH" else="XCode must be installed, AIR_SDK_HOME must be set">
<isset property="isWindows"/>
</condition>
<echo message="${warn}"/>
<echo message=""/>
<exec executable="${make}" failonerror="true" dir="${native.dir}">
<arg line="@{target}"/>
</exec>
</sequential>
</macrodef>
<macrodef name="info">
<attribute name="title" default=""/>
<attribute name="description" default=""/>
<sequential>
<echo message="_______________________________________________________________________"/>
<echo message="[@{title}] - ${platform}"/>
<echo message="......................................................................."/>
<echo message="@{description}"/>
<echo message="_______________________________________________________________________"/>
<echo message=""/>
<echo message=""/>
</sequential>
</macrodef>
</project>