forked from scottschiller/SoundManager2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.xml
executable file
·315 lines (222 loc) · 12.5 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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<?xml version="1.0"?>
<!--
SoundManager 2 buildfile (Ant)
WARNING: This is probably the worst build.xml file ever made. Don't say I didn't warn you. ;)
Never having made one of these before, I took the dumbest, "it just works" approach to string replacement,
creating numerous temporary files and making assumptions about paths. This could be massively improved on.
This is tested on OS X and uses Google's closure compiler, MTASC to build the Flash 8 stuff, and mxmlc (Adobe Flex Open Source SDK) for the Flash 9 versions.
Perl, zip and sed are also used for file munging purposes.
USAGE
run "ant" from the soundmanager2 root directory (ie., where this build.xml file is.)
RELATED DOWNLOADS
http://code.google.com/closure/compiler/
http://www.mtasc.org/
http://opensource.adobe.com/wiki/display/flexsdk/Flex+SDK
WHAT IS AUTOMATED
* Build of soundmanager-jsmin.js from soundmanager2.js (google closure compiler compression)
* Build of soundmanager-nodebug.js and soundmanager-nodebug-jsmin.js (above, plus stripping out <d>-annotated sections</d> of debug functionality, eg. writeDebug() and debug strings etc.)
* Build of AS2/AS3 SWFs from .AS source, plus debug-enabled versions. Additionally, cross-domain-enabled versions are made and placed into a zip file.
MAKING THIS SUCK LESS (TODO)
* Get rid of temporary files made from numerous sed calls
* Split up actions (ie., option to do only JS, only SWFs etc. vs. full build)
* Error handling - exit build if anything fails along the way
-->
<project name="SoundManager 2" default="build" basedir=".">
<property file='${basedir}/.build.properties'/>
<property name='mxmlc' value='mxmlc'/>
<property name='mtasc' value='mtasc'/>
<property name='closure-compiler.jar' value="${user.home}/compiler.jar"/>
<echo>${closure-compiler.jar}</echo>
<target name="build">
<echo>Compressing minified JS...</echo>
<!--
<exec executable="/bin/sh">
<arg line='-c "java -jar ~/yuicompressor-2.4.2.jar script/soundmanager2.js -o script/soundmanager2-jsmin.js"'/>
</exec>
-->
<exec executable="/bin/sh">
<arg line='-c "mkdir -p tmp"'/>
</exec>
<!-- Google Closure Compiler -->
<exec executable="/bin/sh">
<arg line='-c "java -jar ${closure-compiler.jar} --compilation_level SIMPLE_OPTIMIZATIONS --js script/soundmanager2.js --js_output_file tmp/soundmanager2-jsmin-temp.js"'/>
</exec>
<!-- Retain license comment through further closure compiler minification -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\*/\/\*\* \@license/g;p;}' tmp/soundmanager2-jsmin-temp.js > script/soundmanager2-jsmin.js"'/>
</exec>
<echo>Making no-debug JS...</echo>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/this.debugMode = true;/this.debugMode = false;/g;p;}' script/soundmanager2.js > tmp/sm2-nodebug-temp.js"'/>
</exec>
<!-- _s._wD() / _wDS() -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/_s._wD(/\/\/_s._wD(/g;p;}' tmp/sm2-nodebug-temp.js > tmp/sm2-nodebug-temp2.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/_wDS(/\/\/_wDS(/g;p;}' tmp/sm2-nodebug-temp2.js > tmp/sm2-nodebug-temp3.js"'/>
</exec>
<!-- _debugTS() -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/_debugTS(/\/\/_debugTS(/g;p;}' tmp/sm2-nodebug-temp3.js > tmp/sm2-nodebug-temp4.js"'/>
</exec>
<!-- <d> and </d> -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <d>/\/\*/g;p;}' tmp/sm2-nodebug-temp4.js > tmp/sm2-nodebug-temp5.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <\/d>/\*\//g;p;}' tmp/sm2-nodebug-temp5.js > tmp/sm2-nodebug-temp6.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "cp tmp/sm2-nodebug-temp6.js script/soundmanager2-nodebug.js"'/>
</exec>
<echo>Compressing no-debug JS...</echo>
<!--
<echo>[YUICompressor]</echo>
<exec executable="/bin/sh">
<arg line='-c "java -jar ~/yuicompressor-2.4.2.jar sm2-nodebug-temp6.js -o script/soundmanager2-nodebug-yuicompressor.js"'/>
</exec>
-->
<exec executable="/bin/sh">
<arg line='-c "java -jar ${closure-compiler.jar} --compilation_level SIMPLE_OPTIMIZATIONS --js tmp/sm2-nodebug-temp6.js --js_output_file tmp/soundmanager2-nodebug-jsmin.js"'/>
</exec>
<!-- Retain license comment through further closure compiler minification -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\*/\/\*\* \@license/g;p;}' tmp/soundmanager2-nodebug-jsmin.js > script/soundmanager2-nodebug-jsmin.js"'/>
</exec>
<!-- show size -->
<echo>soundmanager2.js sizes (full, -jsmin, -nodebug, -nodebug-jsmin):</echo>
<exec executable="/bin/sh">
<arg line='-c "perl -e 'printf "%d" ,(stat(shift))[7]; ' script/soundmanager2.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "perl -e 'printf "%d" ,(stat(shift))[7]; ' script/soundmanager2-jsmin.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "perl -e 'printf "%d" ,(stat(shift))[7]; ' script/soundmanager2-nodebug.js"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "perl -e 'printf "%dn" ,(stat(shift))[7]; ' script/soundmanager2-nodebug-jsmin.js"'/>
</exec>
<echo>Building debug version, Flash 8/AS2...</echo>
<exec executable="/bin/sh">
<arg line='-c "${mtasc} -swf swf/soundmanager2_debug.swf -main -header 16:16:30 src/SoundManager2.as -version 8"'/>
</exec>
<echo>Building debug version, Flash 9/AS3...</echo>
<exec executable="/bin/sh">
<arg line='-c "${mxmlc} -debug=true -static-link-runtime-shared-libraries=true -optimize=true -o swf/soundmanager2_flash9_debug.swf -file-specs src/SoundManager2_AS3.as"'/>
</exec>
<echo>Making no-debug .AS...</echo>
<exec executable="/bin/sh">
<arg line='-c "mkdir -p tmp/soundmanager2_flash_nodebug"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "cp src/*.as tmp/soundmanager2_flash_nodebug"'/>
</exec>
<!-- flash 8 debug -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/var debugEnabled = true;/var debugEnabled = false;/g;p;}' src/SoundManager2.as > tmp/SoundManager2-temp1.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/writeDebug(/\/\/ flashDebug(/g;p;}' tmp/SoundManager2-temp1.as > tmp/SoundManager2-temp2.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <d>/\/\*/g;p;}' tmp/SoundManager2-temp2.as > tmp/SoundManager2-temp3.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <\/d>/\*\//g;p;}' tmp/SoundManager2-temp3.as > tmp/SoundManager2-temp4.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/writeDebug(/\/\/ writeDebug(/g;p;}' tmp/SoundManager2-temp4.as > tmp/soundmanager2_flash_nodebug/SoundManager2.as"'/>
</exec>
<!-- flash 9 debug: SoundManager2 -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/public var debugEnabled: Boolean = true;/public var debugEnabled: Boolean = false;/g;p;}' src/SoundManager2_AS3.as > tmp/SoundManager2_AS3-temp1.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/flashDebug(/\/\/ flashDebug(/g;p;}' tmp/SoundManager2_AS3-temp1.as > tmp/SoundManager2_AS3-temp2.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <d>/\/\*/g;p;}' tmp/SoundManager2_AS3-temp2.as > tmp/SoundManager2_AS3-temp3.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <\/d>/\*\//g;p;}' tmp/SoundManager2_AS3-temp3.as > tmp/SoundManager2_AS3-temp4.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/writeDebug(/\/\/ writeDebug(/g;p;}' tmp/SoundManager2_AS3-temp4.as > tmp/soundmanager2_flash_nodebug/SoundManager2_AS3.as"'/>
</exec>
<!-- flash 9 debug: SMSound -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/flashDebug(/\/\/ flashDebug(/g;p;}' src/SoundManager2_SMSound_AS3.as > tmp/SoundManager2_SMSound_AS3-temp1.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/writeDebug(/\/\/ writeDebug(/g;p;}' tmp/SoundManager2_SMSound_AS3-temp1.as > tmp/SoundManager2_SMSound_AS3-temp2.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <d>/\/\*/g;p;}' tmp/SoundManager2_SMSound_AS3-temp2.as > tmp/SoundManager2_SMSound_AS3-temp3.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/\/\/ <\/d>/\*\//g;p;}' tmp/SoundManager2_SMSound_AS3-temp3.as > tmp/soundmanager2_flash_nodebug/SoundManager2_SMSound_AS3.as"'/>
</exec>
<echo>Making cross-domain .AS..</echo>
<exec executable="/bin/sh">
<arg line='-c "mkdir -p tmp/soundmanager2_flash_xdomain/nodebug"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "cp src/*.as tmp/soundmanager2_flash_xdomain"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "cp tmp/soundmanager2_flash_nodebug/*.as tmp/soundmanager2_flash_xdomain/nodebug"'/>
</exec>
<!-- cross-domain .AS (regular, debug version)... -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/var allow_xdomain_scripting = false;/var allow_xdomain_scripting = true;/g;p;}' src/SoundManager2.as > tmp/soundmanager2_flash_xdomain/SoundManager2.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/var allow_xdomain_scripting:Boolean = false;/var allow_xdomain_scripting:Boolean = true;/g;p;}' src/SoundManager2_AS3.as > tmp/soundmanager2_flash_xdomain/SoundManager2_AS3.as"'/>
</exec>
<!-- -nodebug cross-domain -->
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/var allow_xdomain_scripting = false;/var allow_xdomain_scripting = true;/g;p;}' tmp/soundmanager2_flash_nodebug/SoundManager2.as > tmp/soundmanager2_flash_xdomain/nodebug/SoundManager2.as"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "sed -n '1h;1!H;${;g;s/var allow_xdomain_scripting:Boolean = false;/var allow_xdomain_scripting:Boolean = true;/g;p;}' tmp/soundmanager2_flash_nodebug/SoundManager2_AS3.as > tmp/soundmanager2_flash_xdomain/nodebug/SoundManager2_AS3.as"'/>
</exec>
<echo>Building no-debug SWFs...</echo>
<exec executable="/bin/sh">
<arg line='-c "${mtasc} -swf swf/soundmanager2.swf -main -header 16:16:30 tmp/soundmanager2_flash_nodebug/SoundManager2.as -version 8"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "${mxmlc} -static-link-runtime-shared-libraries=true -optimize=true -o swf/soundmanager2_flash9.swf -file-specs tmp/soundmanager2_flash_nodebug/SoundManager2_AS3.as"'/>
</exec>
<echo>Building debug cross-domain SWFs...</echo>
<exec executable="/bin/sh">
<arg line='-c "${mtasc} -swf tmp/soundmanager2_flash_xdomain/soundmanager2_debug.swf -main -header 16:16:30 tmp/soundmanager2_flash_xdomain/SoundManager2.as -version 8"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "${mxmlc} -debug=true -static-link-runtime-shared-libraries=true -optimize=true -o tmp/soundmanager2_flash_xdomain/soundmanager2_flash9_debug.swf -file-specs tmp/soundmanager2_flash_xdomain/SoundManager2_AS3.as"'/>
</exec>
<echo>Building no-debug cross-domain SWFs...</echo>
<exec executable="/bin/sh">
<arg line='-c "${mtasc} -swf tmp/soundmanager2_flash_xdomain/soundmanager2.swf -main -header 16:16:30 tmp/soundmanager2_flash_xdomain/nodebug/SoundManager2.as -version 8"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "${mxmlc} -static-link-runtime-shared-libraries=true -optimize=true -o tmp/soundmanager2_flash_xdomain/soundmanager2_flash9.swf -file-specs tmp/soundmanager2_flash_xdomain/nodebug/SoundManager2_AS3.as"'/>
</exec>
<!-- remove existing .zip, if found -->
<exec executable="/bin/sh">
<arg line='-c "if [ -f swf/soundmanager2_flash_xdomain.zip ]; then rm swf/soundmanager2_flash_xdomain.zip; fi"'/>
</exec>
<!-- do the zip thing, FROM WITHIN THE TMP/ PATH -->
<exec executable="/bin/sh">
<arg line='-c "cd tmp; zip -r ../swf/soundmanager2_flash_xdomain.zip soundmanager2_flash_xdomain -i \*.swf"'/>
</exec>
<!-- remove temporary file(s) -->
<exec executable="/bin/sh">
<arg line='-c "rm -r tmp/*"'/>
</exec>
<exec executable="/bin/sh">
<arg line='-c "rmdir tmp"'/>
</exec>
</target>
</project>