-
Notifications
You must be signed in to change notification settings - Fork 25
/
build.xml
395 lines (334 loc) · 15 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
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
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
<project name="common schema" default="all" basedir=".">
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="/usr/share/java/ant-contrib.jar" />
</classpath>
</taskdef>
<!--
<property name="mysql.user" value="root" />
<property name="mysql.password" value="" />
<property name="mysql.socket" value="/tmp/mysql.prime.sock" />
-->
<property name="mysql.user" value="root" />
<property name="mysql.password" value="root" />
<property name="mysql.socket" value="/var/run/mysqld/mysqld.sock" />
<!--
<property name="mysql.user" value="root" />
<property name="mysql.password" value="msandbox" />
<property name="mysql.socket" value="/var/folders/m2/jxhw5r550fbcj96cg_9j8xx40000gn/T//mysql_sandbox22293.sock" />
-->
<!--
<property name="mysql.user" value="root" />
<property name="mysql.password" value="msandbox" />
<property name="mysql.socket" value="/tmp/mysql_sandbox5524.sock" />
-->
<!--
<property name="mysql.user" value="root" />
<property name="mysql.password" value="msandbox" />
<property name="mysql.socket" value="/tmp/mysql_sandbox5612.sock" />
-->
<property name="mysql.database" value="common_schema" />
<property name="build_data.dir" value="build_data" />
<property name="build.dir" value="build" />
<property name="dist.dir" value="dist" />
<property name="tests.dir" value="tests" />
<property name="tmp.dir" value="ant-tmp" />
<property name="sql.help.output.file" value="common_schema_help.sql" />
<property name="sql.base_components.output.file" value="common_schema_base_components.sql" />
<property name="sql.additional_components.output.file" value="common_schema_additional_components.sql" />
<property name="sql.scripts.output.file" value="common_schema_scripts.sql" />
<property name="sql.build.output.file" value="common_schema.sql" />
<property name="doc.templates.dir" value="doc/templates" />
<property name="doc.html.dir" value="doc/html" />
<property name="doc.sql.tmp.file" value="doc_sql.txt" />
<target name="all" depends="build">
</target>
<target name="clean">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
<delete dir="${tmp.dir}" />
</target>
<target name="undeploy">
<antcall target="exec_mysql_command">
<param name="mysql_command" value="DROP DATABASE IF EXISTS ${mysql.database}" />
</antcall>
</target>
<target name="buildnumber" description="Get the current timestamp">
<tstamp description="To be used as build number">
<format property="build.number" pattern="yyyyMMddHHmmss" locale="en,GB"/>
</tstamp>
<echo>build number: ${build.number}</echo>
</target>
<target name="build_base_components" depends="buildnumber">
<mkdir dir="${build.dir}" />
<concat destfile="${build.dir}/${sql.base_components.output.file}">
<fileset dir="tables/" includes="*.sql" />
<fileset dir="tables/common_schema_version_control/" includes="*.sql" />
<fileset dir="routines/chart/" includes="*.sql" />
<fileset dir="routines/debug/" includes="*.sql" />
<fileset dir="routines/dependencies/" includes="*.sql" />
<fileset dir="routines/general/" includes="*.sql" />
<fileset dir="routines/general_internal/" includes="*.sql" />
<fileset dir="routines/meta/" includes="*.sql" />
<fileset dir="routines/privileges/" includes="*.sql" />
<fileset dir="routines/process/" includes="*.sql" />
<fileset dir="routines/schema/" includes="*.sql" />
<fileset dir="routines/script/" includes="*.sql" />
<fileset dir="routines/script/states" includes="*.sql" />
<fileset dir="routines/script/variables" includes="*.sql" />
<fileset dir="routines/script/functions" includes="*.sql" />
<fileset dir="routines/script/array" includes="*.sql" />
<fileset dir="routines/script/array/mxarray" includes="*.sql" />
<fileset dir="routines/script/split" includes="*.sql" />
<fileset dir="routines/script/split/analyze" includes="*.sql" />
<fileset dir="routines/text/" includes="*.sql" />
<fileset dir="routines/time/" includes="*.sql" />
<fileset dir="routines/version_control/" includes="*.sql" />
<!--
<fileset dir="routines/math/" includes="*.sql" />
-->
<!--
<fileset dir="autocache/tables/" includes="*.sql" />
<fileset dir="autocache/routines/" includes="*.sql" />
<fileset dir="autocache/views_internal/" includes="*.sql" />
<fileset dir="autocache/views/" includes="*.sql" />
-->
<fileset dir="views/schema_analysis/" includes="*.sql" />
<fileset dir="views/data_dimension/" includes="*.sql" />
<fileset dir="views/debug/" includes="*.sql" />
<fileset dir="views/i_s/" includes="*.sql" />
<fileset dir="views/meta/" includes="*.sql" />
<fileset dir="views/monitoring/" includes="*.sql" />
<fileset dir="views/process/" includes="*.sql" />
<fileset dir="views/script/" includes="*.sql" />
<fileset dir="views/security/" includes="*.sql" />
</concat>
<replace file="${build.dir}/${sql.base_components.output.file}" token="buildnumber.placeholder" value="${build.number}"/>
</target>
<target name="build_additional_components">
<delete dir="${tmp.dir}" />
<mkdir dir="${tmp.dir}" />
<foreach param="innodb_plugin_component.filename" target="build_innodb_plugin_component">
<path>
<fileset dir="views/innodb_plugin/" includes="*.sql" />
</path>
</foreach>
<foreach param="percona_server_component.filename" target="build_percona_server_component">
<path>
<fileset dir="views/percona_server/" includes="*.sql" />
</path>
</foreach>
<foreach param="tokudb_component.filename" target="build_tokudb_component">
<path>
<fileset dir="views/tokudb/" includes="*.sql" />
</path>
</foreach>
<concat destfile="${build.dir}/${sql.additional_components.output.file}">
<fileset dir="${tmp.dir}" includes="*.sql" />
</concat>
<delete dir="${tmp.dir}" />
</target>
<target name="build_innodb_plugin_component">
<basename property="innodb_plugin_component.file.basename" file="${innodb_plugin_component.filename}" />
<loadfile property="component.text" srcfile="${innodb_plugin_component.filename}"></loadfile>
<copy file="${build_data.dir}/innodb_plugin_component.sql" toFile="${tmp.dir}/${innodb_plugin_component.file.basename}" />
<replace file="${tmp.dir}/${innodb_plugin_component.file.basename}" token="component.placeholder" value="${component.text}"/>
</target>
<target name="build_percona_server_component">
<basename property="percona_server_component.file.basename" file="${percona_server_component.filename}" />
<loadfile property="component.text" srcfile="${percona_server_component.filename}"></loadfile>
<copy file="${build_data.dir}/percona_server_component.sql" toFile="${tmp.dir}/${percona_server_component.file.basename}" />
<replace file="${tmp.dir}/${percona_server_component.file.basename}" token="component.placeholder" value="${component.text}"/>
</target>
<target name="build_tokudb_component">
<basename property="tokudb_component.file.basename" file="${tokudb_component.filename}" />
<loadfile property="component.text" srcfile="${tokudb_component.filename}"></loadfile>
<copy file="${build_data.dir}/tokudb_component.sql" toFile="${tmp.dir}/${tokudb_component.file.basename}" />
<replace file="${tmp.dir}/${tokudb_component.file.basename}" token="component.placeholder" value="${component.text}"/>
</target>
<target name="build_scripts">
<delete file="${build.dir}/${sql.scripts.output.file}" />
<foreach param="script.filename" target="build_script">
<path>
<fileset dir="scripts" includes="*.sql" />
</path>
</foreach>
</target>
<target name="build_script">
<basename property="script.file.basename" file="${script.filename}" suffix=".sql"/>
<loadfile property="script.text" srcfile="${script.filename}"></loadfile>
<propertyregex override="true" property="script.text" input="${script.text}"
regexp="[\\\\]" replace="\\\\\\\\" global="true" />
<propertyregex override="true" property="script.text" input="${script.text}"
regexp="[']" replace="''" global="true" />
<concat destfile="${build.dir}/${sql.scripts.output.file}" append="true">
INSERT INTO ${mysql.database}._named_scripts (script_name, script_text) VALUES ('${script.file.basename}','${script.text}');
</concat>
</target>
<target name="build" depends="buildnumber, build_base_components, build_additional_components, build_scripts">
<concat destfile="${build.dir}/${sql.build.output.file}">
<fileset file="${build_data.dir}/main_head.sql" />
<fileset file="${build.dir}/${sql.base_components.output.file}" />
<fileset file="${build.dir}/${sql.additional_components.output.file}" />
<fileset file="${build.dir}/${sql.scripts.output.file}" />
<fileset file="${build.dir}/${sql.help.output.file}" />
<fileset file="${build_data.dir}/main_tail.sql" />
</concat>
</target>
<target name="deploy" depends="build">
<antcall target="deploy_file">
<param name="common_schema_sql_file" value="${build.dir}/${sql.build.output.file}" />
</antcall>
</target>
<target name="dist" depends="clean, build, doc_sql, buildnumber, test">
<mkdir dir="${dist.dir}" />
<propertyregex property="release_filename" input="${sql.build.output.file}" regexp="(.*).sql" select="\1-r${build.number}.sql" />
<loadfile property="doc_sql" srcfile="${build.dir}/${sql.help.output.file}"></loadfile>
<copy file="${build.dir}/${sql.build.output.file}" tofile="${dist.dir}/${release_filename}" />
<replace file="${dist.dir}/${release_filename}" token="doc_sql.placeholder" value="${doc_sql}"/>
<tar destfile="${dist.dir}/common_schema_doc_r${build.number}.tar.gz" basedir="doc/html" compression="gzip" />
</target>
<target name="deploy_file">
<echo>
Deploying file: ${common_schema_sql_file}
</echo>
<antcall target="exec_mysql_file">
<param name="sql_file" value="${common_schema_sql_file}" />
</antcall>
</target>
<target name="exec_mysql_file">
<echo>
Executing SQL file: ${sql_file}
</echo>
<exec executable="mysql" input="${sql_file}">
<arg value="--user=${mysql.user}" />
<arg value="--password=${mysql.password}" />
<arg value="--socket=${mysql.socket}" />
<arg value="--host=localhost" />
</exec>
</target>
<target name="exec_mysql_command">
<propertyregex property="short.command" input="${mysql_command}"
regexp="(^.{1,80})" select="\1" casesensitive="false" />
<echo>
Executing SQL command: ${short.command}
</echo>
<exec executable="mysql">
<arg value="--user=${mysql.user}" />
<arg value="--password=${mysql.password}" />
<arg value="--socket=${mysql.socket}" />
<arg value="--host=localhost" />
<arg value="--execute=${mysql_command}" />
</exec>
</target>
<target name="doc" depends="buildnumber">
<copy file="${doc.templates.dir}/style.css" todir="${doc.html.dir}/css">
</copy>
<foreach param="component_doc_filename" target="component_doc" inheritall="true">
<path>
<fileset dir="${doc.templates.dir}/components">
<include name="*.html" />
</fileset>
</path>
</foreach>
<foreach param="generaldoc_filename" target="generaldoc" inheritall="true">
<path>
<fileset dir="${doc.templates.dir}/general">
<include name="*.html" />
</fileset>
</path>
</foreach>
<exec dir="." executable="svn" failifexecutionfails="false" description="Add files to SVN">
<arg value="--depth"/>
<arg value="files"/>
<arg value="add"/>
<arg value="${doc.html.dir}/"/>
</exec>
<exec dir="." executable="svn" failifexecutionfails="false" description="Set text/html property for all HTML doc files">
<arg value="--depth"/>
<arg value="files"/>
<arg value="propset"/>
<arg value="svn:mime-type"/>
<arg value="text/html"/>
<arg value="${doc.html.dir}/"/>
</exec>
</target>
<target name="component_doc">
<basename property="doc_basename" file="${component_doc_filename}" />
<basename property="component_name" file="${component_doc_filename}" suffix=".html" />
<echo message="Generating documentation for ${component_name} component" />
<concat destfile="${doc.html.dir}/${doc_basename}">
<filelist dir="${doc.templates.dir}" files="head.html.template, ${component_doc_filename}, tail.html.template" />
</concat>
<replace file="${doc.html.dir}/${doc_basename}" token="pagetitle" value="${component_name}" />
<replace file="${doc.html.dir}/${doc_basename}" token="pagename" value="${component_name}" />
<replace file="${doc.html.dir}/${doc_basename}" token="buildnumber.placeholder" value="${build.number}"/>
</target>
<target name="generaldoc">
<basename property="doc_basename" file="${generaldoc_filename}" />
<basename property="docname" file="${generaldoc_filename}" suffix=".html" />
<echo message="Generating documentation for ${docname} file" />
<concat destfile="${doc.html.dir}/${doc_basename}">
<filelist dir="${doc.templates.dir}" files="head.html.template, ${generaldoc_filename}, tail.html.template" />
</concat>
<replace file="${doc.html.dir}/${doc_basename}" token="pagetitle" value="${docname}" />
<replace file="${doc.html.dir}/${doc_basename}" token="pagename" value="${docname}" />
<replace file="${doc.html.dir}/${doc_basename}" token="buildnumber.placeholder" value="${build.number}"/>
</target>
<target name="doc_sql">
<mkdir dir="${tmp.dir}" />
<mkdir dir="${build.dir}" />
<delete file="${build.dir}/${sql.help.output.file}" />
<foreach param="page_doc_filename" target="page_doc_sql">
<path>
<fileset dir="${doc.templates.dir}/general">
<include name="*.html" />
</fileset>
<fileset dir="${doc.templates.dir}/components">
<include name="*.html" />
</fileset>
</path>
</foreach>
<delete dir="${tmp.dir}" />
</target>
<target name="page_doc_sql">
<basename property="doc_basename" file="${page_doc_filename}" />
<basename property="page_doc_name" file="${page_doc_filename}" suffix=".html" />
<echo message="Generating documentation for ${page_doc_name} page" />
<exec executable="html2text">
<arg value="-ascii"/>
<arg value="-width"/>
<arg value="78"/>
<arg value="-style"/>
<arg value="pretty"/>
<arg value="-o"/>
<arg value="${tmp.dir}/${doc.sql.tmp.file}"/>
<arg value="${page_doc_filename}"/>
</exec>
<replace file="${tmp.dir}/${doc.sql.tmp.file}" token="\" value="\\"/>
<replace file="${tmp.dir}/${doc.sql.tmp.file}" token="'" value="''"/>
<loadfile property="doc.sql.text" srcfile="${tmp.dir}/${doc.sql.tmp.file}"></loadfile>
<concat destfile="${build.dir}/${sql.help.output.file}" append="true">
INSERT INTO ${mysql.database}.help_content VALUES ('${page_doc_name}','${doc.sql.text}');
</concat>
</target>
<target name="test">
<echo>Testing</echo>
<exec executable="bash" dir="${tests.dir}" failonerror="true">
<arg value="test_all.sh" />
<arg value="${mysql.user}" />
<arg value="${mysql.password}" />
<arg value="${mysql.socket}" />
</exec>
</target>
<target name="__test__">
<echo>${basedir}</echo>
<echo>${abc}</echo>
<loadfile property="f.c" srcfile="/tmp/crc64.sql">
</loadfile>
<echo>prop: ${f.c}</echo>
<propertyregex property="f.c2" input="${f.c}" regexp="@desc (.*)" select="\1">
</propertyregex>
<echo>prop2: ---${f.c2}---</echo>
</target>
</project>