forked from bustardcelly/as3couchdb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.xml
192 lines (176 loc) · 9.35 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
<?xml version="1.0"?>
<project name="as3couchdb" basedir="." default="build-project">
<!-- as3couchdb library requires the following libraries in order to be built properly: -->
<!-- [as3corelib] can be found at: http://code.google.com/p/as3corelib/ -->
<!-- [as3crypto] can be found at http://code.google.com/p/as3crypto/ -->
<!-- [as3httpclientlib] can be found at: http://code.google.com/p/as3httpclientlib -->
<!-- -->
<!-- The 'lib' target locates these external libraries within a directory described in the -->
<!-- build.properties file denoted as ${lib.dir}. Make sure you have these libraries within -->
<!-- that defined directory in order to properly build the as3couchdb.swc and/or optimized -->
<!-- SWF file. -->
<!-- -->
<!-- In order to be truly ActionScript 3 compliant (and not resticted to rely on classes -->
<!-- from the Flex framework), specific sources are targeted from the as3corelib project. -->
<!-- Specifically, these are the JSON and NET packages, and the StringUtil class. -->
<!-- The project is set up to have a local checkout of as3corelib within a directory -->
<!-- called externals on the root basedir. compc looks into this directory for as3corelib -->
<!-- sources listed in build.properties. -->
<!-- Property file. -->
<property file="build.properties" />
<!-- Generated file names for ease on conditionals. -->
<property name="standalone.swc" value="${standalone.bin.dir}/${library.name}.swc" />
<property name="external.swc" value="${external.bin.dir}/${external.name}.swc" />
<!-- Clean previously buil standalone library based on version. -->
<target name="clean" description="Cleans any previously build library related to projectname-version">
<echo>[CLEAN] Cleaning ${lib.bin.dir}/${lib.name}.swc</echo>
<delete file="${lib.bin.dir}/${lib.name}.swc" />
<echo>[CLEAN] Successfully cleaned ${lib.bin.dir}/${lib.name}.swc</echo>
</target>
<!-- Clean previously built standalone optimized SWF. -->
<target name="clean-optimize" description="Cleans any previously generated optimized standalone library">
<echo>[CLEAN] Cleaning ${lib.bin.dir}/${lib.name}.swf</echo>
<delete file="${lib.bin.dir}/${lib.name}.swf" />
<echo>[CLEAN] Succesfully cleaned ${lib.bin.dir}/${lib.name}.swf</echo>
</target>
<!-- Unpacks built standalone library SWC in order to optimize. -->
<target name="unpack-lib" description="Unpacks the pre-packaged library SWC.">
<!-- See if the SWC already exists. If so, no need to rebuild it. If not, we need to generate one. -->
<condition property="standalone.available">
<available file="${lib.swc}" />
</condition>
<!-- Unless not exists, this is called. -->
<antcall target="build-swc-for-optimize">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="config" value="${config}" />
</antcall>
<!-- Move on to optimizing. -->
<echo>[UNZIP] Unpackaging ${lib.name}.swc.</echo>
<unzip src="${lib.bin.dir}/${lib.name}.swc" dest="${optimize.temp.dir}" />
<echo>[COPY] Moving unpacked library SWF to ${standalone.bin.dir}</echo>
<copy file="${optimize.temp.dir}/library.swf" tofile="${lib.bin.dir}/${lib.name}.swf" />
<echo>[CLEAN] Removing temporary directory for unpacking ${library.name}.swc.</echo>
<delete dir="${optimize.temp.dir}" includeemptydirs="true" />
<echo>[CLEAN] Successful unpackage of ${lib.name}.swc</echo>
</target>
<!-- Conditional task entered from optimize/unpack task if library SWC not previously gernerated. -->
<target name="build-swc-for-optimize" unless="standalone.available" description="Generate the library SWC of not already present.">
<echo>[INFO] SWC not available for optimization. Generating ${lib.name}.swc...</echo>
<antcall target="lib">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="config" value="${config}" />
</antcall>
</target>
<!-- Parameterized target call for generating either standalone or external SWC. -->
<!-- The following parameters need to be passed when invoking this target: -->
<!-- [config] - The custom configuration file to compile against. -->
<!-- [lib.name] - The name of the generated library SWC. -->
<!-- [lib.bin.dir] - The output directory for the generated SWC. -->
<target name="lib" description="Generates the library SWC based on parameters.">
<!-- Clean first -->
<antcall target="clean">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
</antcall>
<!-- Compile against config -->
<echo>[EXEC] Compiling ${lib.name}.swc</echo>
<exec executable="${compc.loc}" dir="${basedir}">
<arg line="+playerglobal.lib.dir=${playerglobal.lib.dir}" />
<arg line="+lib.dir=${lib.dir}" />
<arg line="+as3corelib.net.src=${as3corelib.net.src}" />
<arg line="+as3corelib.json.src=${as3corelib.json.src}" />
<arg line="+as3corelib.utils.StringUtil=${as3corelib.utils.StringUtil}" />
<arg line="+lib.bin.dir=${lib.bin.dir}" />
<arg line="+lib.name=${lib.name}" />
<arg line="+src.dir=${src.dir}" />
<arg line="-load-config+=${config}" />
</exec>
<echo>[EXEC] Finished compiling ${lib.name}.swc. ${lib.name}.swc can be found in ${lib.bin.dir}/.</echo>
</target>
<!-- Parameterized target call for generating either standalone or external optimized SWF. -->
<!-- The following parameters need to be passed when invoking this target: -->
<!-- [config] - The custom configuration file to compile against. -->
<!-- [lib.name] - The name of the generated library SWC. -->
<!-- [lib.bin.dir] - The output directory for the generated SWC. -->
<!-- [lib.swc] - The generated SWC file location. If not avialable, will create. -->
<target name="optimize" description="Generates an optimized SWF file from a library SWC.">
<echo>[EXEC] Optimizing ${lib.name}</echo>
<antcall target="clean-optimize">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
</antcall>
<antcall target="unpack-lib">
<param name="lib.name" value="${lib.name}" />
<param name="lib.bin.dir" value="${lib.bin.dir}" />
<param name="lib.swc" value="${lib.swc}" />
<param name="config" value="${config}" />
</antcall>
<exec executable="${optimizer.loc}">
<arg line="-input ${lib.bin.dir}/${lib.name}.swf" />
<arg line="-output ${lib.bin.dir}/${lib.name}.swf" />
</exec>
<echo>[EXEC] Finished optimizing ${lib.name}. The optimized SWF can be found at ${lib.bin.dir}/${lib.name}.swf</echo>
</target>
<!-- Build the standalone library swc. DEFAULT -->
<target name="standalone" description="Generates the standalone library SWC.">
<antcall target="lib">
<param name="lib.name" value="${library.name}" />
<param name="lib.bin.dir" value="${standalone.bin.dir}" />
<param name="config" value="${standalone.config}" />
</antcall>
</target>
<!-- Build the external library swc. -->
<target name="external" description="Generates the external library SWC.">
<antcall target="lib">
<param name="lib.name" value="${external.name}" />
<param name="lib.bin.dir" value="${external.bin.dir}" />
<param name="config" value="${external.config}" />
</antcall>
</target>
<!-- Build the optimized standalone swf based on the output library SWC. -->
<target name="optimize-standalone" description="Optimizes the standalone library SWC into a generated SWF file.">
<antcall target="optimize">
<param name="lib.name" value="${library.name}" />
<param name="lib.bin.dir" value="${standalone.bin.dir}" />
<param name="lib.swc" value="${standalone.swc}" />
<param name="config" value="${standalone.config}" />
</antcall>
</target>
<!-- Build the optimized external swf based on the output library SWC. -->
<target name="optimize-external" description="Optimizes the external library SWC into a generated SWF file.">
<antcall target="optimize">
<param name="lib.name" value="${external.name}" />
<param name="lib.bin.dir" value="${external.bin.dir}" />
<param name="lib.swc" value="${external.swc}" />
<param name="config" value="${external.config}" />
</antcall>
</target>
<!-- Clean documents directory. -->
<target name="clean-doc" description="Cleans the document directory.">
<echo>[CLEAN] Cleaning ${doc.dir}</echo>
<delete includeemptydirs="true">
<fileset dir="${doc.dir}" includes="**/*" />
</delete>
<echo>[CLEAN] Successfully cleaned ${doc.dir}</echo>
</target>
<!-- Create the ASDocs for the library project. -->
<target name="doc" depends="clean-doc" description="Creates the ASDoc files for the library project.">
<exec executable="${asdoc.loc}" spawn="no">
<arg line="-library-path+=${lib.dir}" />
<arg line="-source-path ${src.dir}" />
<arg line="-doc-sources ${src.dir} " />
<arg line="-output ${doc.dir}" />
<arg line="-window-title 'AS3CouchDB Library - ${library.name}' "/>
</exec>
</target>
<!-- DEFAULT. Runs all tasks to build standard and external SWCs and optimized SWFs as well as project docs. -->
<target name="build-project" description="Runs all tasks to generate SWC, SWF and doc files.">
<antcall target="standalone" />
<antcall target="optimize-standalone" />
<antcall target="external" />
<antcall target="optimize-external" />
<antcall target="doc" />
</target>
</project>