This repository has been archived by the owner on Jan 10, 2020. It is now read-only.
/
macrolib.xml
345 lines (300 loc) · 13.9 KB
/
macrolib.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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
<?xml version="1.0" encoding="UTF-8"?>
<project name="YuiMacroLib">
<macrodef name="arrayliteral">
<attribute name="from" />
<attribute name="to" />
<attribute name="key" />
<sequential>
<if>
<and>
<isset property="@{from}" />
<length string="${@{from}}" when="ne" length="0" />
</and>
<then>
<propertyregex property="array"
override="true"
input="${@{from}}"
casesensitive="false"
regexp="([^\,\s]+)"
replace="'\1'"
/>
<property name="@{to}" value="@{key}:[${array}]" />
</then>
</if>
</sequential>
</macrodef>
<macrodef name="createdetails">
<sequential>
<arrayliteral from="component.use" to="component.details.use" key="use" />
<arrayliteral from="component.supersedes" to="component.details.supersedes" key="supersedes" />
<arrayliteral from="component.requires" to="component.details.requires" key="requires" />
<arrayliteral from="component.optional" to="component.details.optional" key="optional" />
<arrayliteral from="component.lang" to="component.details.lang" key="lang" />
<if>
<isset property="component.skinnable" />
<then>
<property name="component.details.skinnable" value="skinnable:${component.skinnable}" />
</then>
</if>
<propertyselector property="details.list"
delimiter=","
match="component\.details.([^\.]*)"
select="\1"
casesensitive="false" />
<var name="details" value="" />
<if>
<isset property="details.list" />
<then>
<for list="${details.list}" param="val">
<sequential>
<var name="details" value="${component.details.@{val}}, ${details}" />
</sequential>
</for>
<propertyregex property="component.details.hash"
input="{${details}}"
regexp="(\,\s*?\})"
replace="}"
casesensitive="false" />
</then>
<else>
<property name="component.details.hash" value="" />
</else>
</if>
</sequential>
</macrodef>
<macrodef name="yuicompress">
<attribute name="src" />
<attribute name="dest" />
<attribute name="args" />
<sequential>
<echo level="info">Running yuicompressor on @{src}</echo>
<java jar="${yuicompressor.jar}" fork="true" failonerror="true">
<arg line="@{args} -o" />
<arg file="@{dest}" />
<arg file="@{src}" />
</java>
</sequential>
</macrodef>
<macrodef name="concatsource">
<attribute name="destfile" />
<attribute name="sourcedir" />
<attribute name="sourcefiles" />
<attribute name="workingdir" default="${workingdir}" />
<element name="filters" optional="true" description="Additonal filters to apply to individual files"/>
<sequential>
<echo level="info">Concatenating</echo>
<echo level="info"> Source Files : @{sourcefiles}</echo>
<echo level="info"> In Source Dir : @{sourcedir}</echo>
<echo level="info"> To : @{destfile}</echo>
<delete dir="@{workingdir}" quiet="true"/>
<copy todir="@{workingdir}">
<filelist dir="@{sourcedir}" files="@{sourcefiles}" />
<filterchain>
<filters />
<fixcrlf fixlast="true" eof="remove"/>
</filterchain>
</copy>
<concat destfile="@{destfile}" fixlastline="true">
<filelist dir="@{workingdir}" files="@{sourcefiles}" />
</concat>
<delete dir="${workingdir}" quiet="true" />
</sequential>
</macrodef>
<macrodef name="jslint">
<element name="jsfiles" optional="false" />
<sequential>
<!--
Need to find a way to convert fileset to args (script?) to
avoid ' ', which will break for files with ' in them
Evaluates to the following java execution line...
java -r js.jar jslintconsole.js 'file1.js' 'file2.js' 'file3.js'
-->
<pathconvert pathsep="' '" property="jsfileargs">
<jsfiles />
</pathconvert>
<java jar="${rhino.jar}" fork="true" failonerror="true">
<arg file="${jslintconsole.js}" />
<arg value="${jslintsrc.js}" />
<arg line="'${jsfileargs}'" />
</java>
</sequential>
</macrodef>
<macrodef name="registerversion">
<attribute name="module" />
<attribute name="classname" />
<attribute name="file" />
<sequential>
<loadfile srcfile="${builddir}/files/versioncode.txt" property="@{module}-@{classname}-version" >
<filterchain>
<replacetokens>
<token key="MODULE" value="@{module}"/>
<token key="CLASSNAME" value="@{classname}"/>
</replacetokens>
</filterchain>
</loadfile>
<echo level="info">Adding Version Registration Code to @{file}</echo>
<concat destfile="@{file}" append="true" fixlastline="true">${@{module}-@{classname}-version}</concat>
</sequential>
</macrodef>
<macrodef name="addlang">
<attribute name="dir" />
<attribute name="module" />
<attribute name="dest" />
<attribute name="lang" default="" />
<attribute name="details" default = ""/>
<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}@{lang}_details" value="" />
</then>
<else>
<property name="@{module}@{lang}_details" value=",@{details}" />
</else>
</if>
<if>
<equals arg1="@{lang}" arg2="" />
<then>
<property name="@{module}@{lang}_fullname" value="@{module}" />
</then>
<else>
<property name="@{module}@{lang}_fullname" value="@{module}_@{lang}" />
</else>
</if>
<if>
<available file="@{dir}/${@{module}@{lang}_fullname}.pres" />
<then>
<mkdir dir="${component.langbuilddir}" />
<java jar="${rhino.jar}" fork="true" failonerror="true">
<jvmarg value="-Dfile.encoding=utf-8" />
<arg file="${yrb2jsonconsole.js}" />
<arg file="${yrb2jsonsrc.js}" />
<arg file="@{dir}/${@{module}@{lang}_fullname}.pres" />
<arg file="${component.langbuilddir}/${@{module}@{lang}_fullname}.js" />
</java>
<echo level="info">Wrapping ${component.langbuilddir}/${@{module}@{lang}_fullname}.js in YUI.add, Y.Intl.add</echo>
<loadfile srcfile="${component.langbuilddir}/${@{module}@{lang}_fullname}.js" property="@{module}@{lang}-strs-loaded" encoding="utf-8" />
</then>
<else>
<echo level="info">Wrapping @{dir}/${@{module}@{lang}_fullname}.js in YUI.add, Y.Intl.add</echo>
<loadfile srcfile="@{dir}/${@{module}@{lang}_fullname}.js" property="@{module}@{lang}-strs-loaded" encoding="utf-8" />
</else>
</if>
<copy file="${builddir}/files/langtemplate.txt" tofile="@{dest}/${@{module}@{lang}_fullname}.js" overwrite="true" outputencoding="utf-8">
<filterset>
<filter token="LANG" value="@{lang}" />
<filter token="LANG_MODULE" value="lang/${@{module}@{lang}_fullname}" />
<filter token="STRINGS" value="${@{module}@{lang}-strs-loaded}" />
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}" />
<filter token="LANG_DETAILS" value="${@{module}@{lang}_details}" />
</filterset>
</copy>
</sequential>
</macrodef>
<macrodef name="addmodule">
<attribute name="file" />
<attribute name="module" />
<attribute name="details" default="" />
<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}-details" value="" />
</then>
<else>
<property name="@{module}-details" value=",@{details}" />
</else>
</if>
<loadfile srcfile="@{file}" property="@{module}-@{file}-code" />
<echo level="info">Wrapping @{file} in YUI.add module</echo>
<copy file="${builddir}/files/moduletemplate.txt" tofile="@{file}" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}-@{file}-code}" />
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}" />
<filter token="DETAILS" value="${@{module}-details}" />
</filterset>
</copy>
</sequential>
</macrodef>
<macrodef name="addrollup">
<attribute name="file" />
<attribute name="module" />
<attribute name="details" default="" />
<sequential>
<if>
<equals arg1="@{details}" arg2="" />
<then>
<property name="@{module}-details" value="" />
</then>
<else>
<property name="@{module}-details" value=",@{details}" />
</else>
</if>
<loadfile srcfile="@{file}" property="@{module}-@{file}-code" />
<echo level="info">Adding Rollup @{file} using YUI.add</echo>
<copy file="${builddir}/files/rolluptemplate.txt" tofile="@{file}" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}-@{file}-code}"/>
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="@{module}"/>
<filter token="DETAILS" value="${@{module}-details}"/>
</filterset>
</copy>
</sequential>
</macrodef>
<macrodef name="addlangrollup">
<attribute name="module" />
<attribute name="dir" />
<sequential>
<echo level="info">Registering rollup info for lang files in @{dir} using YUI.add</echo>
<for list="${component.rollup.lang}" param="lang" trim="true">
<sequential>
<loadfile srcfile="@{dir}/@{module}_@{lang}.js" property="@{module}-@{lang}-code" />
<var name="lang.use" value="{use:[" />
<for list="${component.lang.use}" param="submod" trim="true">
<sequential>
<var name="lang.use" value="${lang.use}'lang/@{submod}_@{lang}'," />
</sequential>
</for>
<var name="lang.use" value="${lang.use}]}" />
<propertyregex property="@{module}-@{lang}-details"
input="${lang.use}"
regexp="(\,\s*?\])"
replace="]"
casesensitive="false" />
<copy file="${builddir}/files/rolluptemplate.txt" tofile="@{dir}/@{module}_@{lang}.js" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}-@{lang}-code}"/>
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="lang/@{module}_@{lang}"/>
<filter token="DETAILS" value=", ${@{module}-@{lang}-details}"/>
</filterset>
</copy>
</sequential>
</for>
<loadfile srcfile="@{dir}/@{module}.js" property="@{module}--code" />
<var name="lang.use" value="{use:[" />
<for list="${component.lang.use}" param="submod" trim="true">
<sequential>
<var name="lang.use" value="${lang.use}'lang/@{submod}'," />
</sequential>
</for>
<var name="lang.use" value="${lang.use}]}" />
<propertyregex property="@{module}--details"
input="${lang.use}"
regexp="(\,\s*?\])"
replace="]"
casesensitive="false" />
<copy file="${builddir}/files/rolluptemplate.txt" tofile="@{dir}/@{module}.js" overwrite="true">
<filterset>
<filter token="CODE" value="${@{module}--code}"/>
<filter token="YUIVAR" value="${yui.variable}" />
<filter token="MODULE" value="lang/@{module}"/>
<filter token="DETAILS" value=", ${@{module}--details}"/>
</filterset>
</copy>
</sequential>
</macrodef>
</project>