-
Notifications
You must be signed in to change notification settings - Fork 28
/
build.xml
296 lines (269 loc) · 11.9 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
<project name="streamsx.inet" default="all" basedir=".">
<description>
Build file for streamsx.inet project, built the toolkits and samples.
</description>
<property environment="env" />
<fail message="STREAMS_INSTALL is not set">
<condition>
<not><isset property="env.STREAMS_INSTALL"/></not>
</condition>
</fail>
<echo message="STREAMS_INSTALL : ${env.STREAMS_INSTALL}"/>
<!-- set global properties for this build -->
<property name="streams.install" value="${env.STREAMS_INSTALL}" />
<property name="toolkit.string" value="com.ibm.streamsx.inet"/>
<property name="toolkit.dir" location="${toolkit.string}"/>
<property name="toolkit.test" location="tests" />
<property name="release.dir" location="release" />
<property name="release.info.file" value="${toolkit.dir}/build.info"/>
<property name="spl-md" value="${streams.install}/bin/spl-make-doc" />
<property name="spl-st" value="${streams.install}/bin/streamtool" />
<!-- Create the time stamp -->
<tstamp/>
<target name="all"
description="Build the toolkit code, build the samples index and generate the spl documentation"
depends="toolkit, samples, spldoc"
/>
<target name="clean" depends="spldoc-clean,samples-clean,releaseinfo-clean"
description="clean up toolkit code, samples code and all spldocs">
<delete includeemptydirs="true">
<fileset dir="${basedir}" includes="release-*/"/>
</delete>
<ant dir="${toolkit.dir}" target="clean"/>
</target>
<target name="clean-all" depends="clean"
description="clean up toolkit code, samples code and all spldocs and test artifacts">
<ant dir="${toolkit.test}" target="clean-all"/>
</target>
<target name="requirements" depends="get_name"
description="Download required libraries." >
<ant dir="${toolkit.dir}" target="requirements"/>
</target>
<target name="toolkit" depends="get_name"
description="Build any code and index the toolkit." >
<ant dir="${toolkit.dir}" target="all"/>
</target>
<target name="get_name">
<xmlproperty file="${toolkit.dir}/info.xml" prefix="tkinfo" keepRoot="no"/>
<echo message="Toolkit Name: ${tkinfo.identity.name}"/>
<echo message="Toolkit Version: ${tkinfo.identity.version}"/>
</target>
<target name="toolkitIndexOnly" description="Index the toolkit.">
<ant dir="${toolkit.dir}" target="cleanToolkitxml" />
<ant dir="${toolkit.dir}" target="indextoolkit" />
</target>
<target name="spldoc" depends="get_name, samples"
description="Create spldoc for toolkit and all samples">
<!-- build the toolkit doc -->
<echo message="Tookit to SPLDOC: ${toolkit.dir}"/>
<exec executable="${spl-md}" failonerror="true">
<arg value="--include-composite-operator-diagram"/>
<arg value="--author"/>
<arg value="IBMStreams Open Source Community at GitHub - https://github.com/IBMStreams/${ant.project.name}"/>
<arg value="--doc-title"/>
<arg value="IBMStreams ${tkinfo.identity.name} Toolkit"/>
<arg value="--toolkit-path"/>
<arg value="${toolkit.dir}"/>
<arg value="--warn-no-comments"/>
<arg value="--check-tags"/>
</exec>
<!-- build the sample doc for each sample-->
<exec executable="bash" outputproperty="samples.list" failonerror="true">
<arg value="-c"/>
<arg value="for x in samples/*/info.xml; do echo -n ${x%/*}; echo -n : ; done"/>
</exec>
<echo message="All samples to SPLDOC: ${samples.list}"/>
<exec executable="${spl-md}" failonerror="true">
<arg value="--include-composite-operator-diagram"/>
<arg value="--author"/>
<arg value="IBMStreams Open Source Community at GitHub - https://github.com/IBMStreams/${ant.project.name}"/>
<arg value="--doc-title"/>
<arg value="IBMStreams ${tkinfo.identity.name} Samples"/>
<arg value="--toolkit-path"/>
<arg value="${samples.list}"/>
<arg value="--warn-no-comments"/>
<arg value="--check-tags"/>
<arg value="--include-source"/>
<arg value="--output-directory"/>
<arg value="samples/doc/spldoc"/>
</exec>
</target>
<target name="samples" depends="toolkit" description="Build the toolkit index for the samples">
<subant target="indextoolkit" genericantfile="${basedir}/build.xml">
<dirset dir="samples" includes="*" excludes="doc"/>
</subant>
</target>
<target name="samples-clean" description="Clean up samples index and samples code">
<subant genericantfile="${basedir}/build.xml">
<target name="cleantoolkit"/>
<target name="cleansample"/>
<dirset dir="samples" includes="*" excludes="doc"/>
</subant>
</target>
<target name="samples-build" depends="toolkit" description="Compile all samples">
<subant target="buildsample" genericantfile="${basedir}/build.xml">
<dirset dir="samples" includes="*" excludes="doc"/>
</subant>
</target>
<!-- Test targets -->
<target name="test" depends="toolkit" description="Start the (quick) test">
<ant dir="${toolkit.dir}" target="test"/>
<ant dir="${toolkit.test}" target="test"/>
</target>
<target name="test-full" depends="toolkit" description="Start the full test">
<ant dir="${toolkit.dir}" target="test"/>
<ant dir="${toolkit.test}" target="test-full"/>
</target>
<!-- Targets called on samples -->
<target name="buildsample">
<echo message="Sample to build: ${basedir}"/>
<exec executable="make" failonerror="true" dir="${basedir}">
<arg value="-f" />
<arg value="Makefile" />
<arg value="all" />
</exec>
</target>
<target name="cleansample">
<echo message="Sample to clean: ${basedir}"/>
<exec executable="make" failonerror="true" dir="${basedir}">
<arg value="-f" />
<arg value="Makefile" />
<arg value="clean" />
</exec>
</target>
<target name="indextoolkit">
<echo message="Tookit to index: ${basedir}"/>
<exec executable="${streams.install}/bin/spl-make-toolkit" failonerror="true">
<arg value="--directory"/>
<arg value="${basedir}"/>
<arg value="-m"/>
</exec>
</target>
<target name="cleantoolkit">
<echo message="Tookit to clean: ${basedir}"/>
<exec executable="${streams.install}/bin/spl-make-toolkit">
<arg value="--clean"/>
<arg value="--directory"/>
<arg value="${basedir}"/>
</exec>
<delete dir="${basedir}/output" quiet="true"/>
<delete dir="${basedir}/doc" quiet="true"/>
</target>
<target name="spldoc-clean" description="clean the toolkit doc and the all samples doc">
<delete dir="${basedir}/doc" quiet="true"/>
<delete dir="${basedir}/samples/doc"/>
</target>
<!-- Targets to build releases -->
<target name="release" description="Make a toolkit release archive - purge workspace and build toolkit from scratch" depends="clean">
<antcall target="release-target" inheritAll="true"/>
</target>
<target name="release-target" depends="releaseinfo">
<!-- prepare toolkit code and docs -->
<antcall target="all" inheritAll="true"/>
<antcall target="samples-clean" inheritAll="true"/> <!-- remove toolkit index from samples -->
<!-- get os type string -->
<property name="osVersion" value="${os.version}"/>
<condition property="osPlat" value="el7">
<contains string="${osVersion}" substring="el7" casesensitive="false"/>
</condition>
<condition property="osPlat" value="el6">
<contains string="${osVersion}" substring="el6" casesensitive="false"/>
</condition>
<!-- Extract the git commit hash -->
<exec executable="git" outputproperty="commithash.short">
<arg value="rev-parse"/>
<arg value="--short"/>
<arg value="HEAD"/>
</exec>
<!-- create release bundle -->
<mkdir dir="${release.dir}" />
<property name="releasefilename" value="${release.dir}/streamsx.inet.toolkit-${tkinfo.identity.version}-${osPlat}-${os.arch}-${commithash.short}-${DSTAMP}-${TSTAMP}.tgz"/>
<echo message="Create release archive ${releasefilename}"/>
<tar compression="gzip" longfile="gnu"
destfile="${releasefilename}"
basedir="${basedir}"
includes="${toolkit.string}/** samples/** doc/** README.md LICENSE.md"
excludes="**/pom.xml **/.gitignore **/.gitkeep ${toolkit.string}/.project ${toolkit.string}/.settings/** ${toolkit.string}/.classpath ${toolkit.string}/icons/ ${toolkit.string}/impl/java/ ${toolkit.string}/impl/cpp/ ${toolkit.string}/impl/src/ ${toolkit.string}/impl/Makefile ${toolkit.string}/build.xml "
/>
<checksum file="${releasefilename}"/>
<checksum algorithm="sha1" file="${releasefilename}"/>
</target>
<!-- Extract the git commit hash and make release info -->
<target name="releaseinfo" depends="get_name,clean-ignored" description="Make the release information file">
<echo message="create info-file ${release.info.file}"/>
<exec executable="git" outputproperty="commithash.long" failonerror="true">
<arg value="rev-parse" />
<arg value="HEAD" />
</exec>
<exec executable="bash" outputproperty="streamsversion" failonerror="true">
<arg value="-c"/>
<arg value="${spl-st} version | grep Version="/>
</exec>
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="echo -e "commit_hash=${commithash.long}\nos=${os.version}\nStreams_${streamsversion}" > ${release.info.file}"/>
</exec>
<echo message="Generated release info file ${release.info.file}"/>
<exec executable="bash" failonerror="true">
<arg value="-c" />
<arg value="cat ${release.info.file}" />
</exec>
</target>
<target name="releaseinfo-clean" description="remove the release information file">
<delete file="${release.info.file}"/>
</target>
<!--- Targets to purge the workspace before a release archive is produced -->
<target name="clean-ignored" depends="warn-unclean" description="Remove all git-ignored files and warn if workspace has uncommited changes"/>
<target name="warn-unclean" depends="check-unclean" if="has.uncommited">
<echo>!Your workspace is not clean!</echo>
<echo>Commit all changes before you produce a release</echo>
<echo>commitstatus:</echo>
<echo>${commitstatus}</echo>
<input>Press Return key to continue or ^C to exit...</input>
</target>
<target name="check-unclean" depends="warn-untracked">
<exec executable="git" outputproperty="commitstatus">
<arg value="status" />
<arg value="--porcelain" />
</exec>
<!-- set condition true if there are any non-whitespaces -->
<condition property="has.uncommited">
<matches string="${commitstatus}" pattern="\S" multiline="true"/>
</condition>
<echo message="has.uncommited=${has.uncommited}"/>
</target>
<target name="warn-untracked" depends="check-untracked" if="has.untracked">
<echo>!!! DANGER: Git-ignored files to be removed from your workspace:</echo>
<echo>${untracked}</echo>
<input>Press Return key to continue or ^C to exit...</input>
<exec executable="git" failonerror="true">
<arg value="clean"/>
<arg value="--force"/>
<arg value="-d"/>
<arg value="-x"/>
<arg value="--"/>
<arg value="${toolkit.string}/"/>
<arg value="samples/"/>
<arg value="README.md"/>
<arg value="doc/"/>
</exec>
</target>
<target name="check-untracked">
<exec executable="git" outputproperty="untracked" failonerror="true">
<arg value="clean"/>
<arg value="--dry-run"/>
<arg value="-d"/>
<arg value="-x"/>
<arg value="--"/>
<arg value="${toolkit.string}/"/>
<arg value="samples/"/>
<arg value="README.md"/>
<arg value="doc/"/>
</exec>
<!-- set condition true if there are any non-whitespaces -->
<condition property="has.untracked">
<matches string="${untracked}" pattern="\S" multiline="true"/>
</condition>
<echo message="has.untracked=${has.untracked}"/>
</target>
</project>