-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build-backend.xml
368 lines (345 loc) · 15.1 KB
/
build-backend.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
<?xml version="1.0" encoding="UTF-8"?>
<project name="Zabbix backend" default="build" basedir="." xmlns:if="ant:if" xmlns:unless="ant:unless">
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Initialize database related options based on the database type -->
<switch value="${DBTYPE}" caseinsensitive="true">
<case value="POSTGRESQL">
<property name="with.db" value="--with-postgresql"/>
<property name="with.postgresql" value="true"/>
</case>
<case value="ORACLE">
<property name="ORA_INCLUDE" value="/usr/include/oracle/19.9/client64"/>
<property name="ORA_LIB" value="/usr/lib/oracle/19.9/client64/lib"/>
<property name="with.db" value="--with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="with.oracle" value="true"/>
</case>
<default>
<property name="with.db" value="--with-mysql"/>
<property name="with.mysql" value="true"/>
</default>
</switch>
<!-- Zabbix various configuration parameters -->
<target name="init-conf-options">
<property name="conf1" value="--enable-agent"/>
<property name="conf2" value="--enable-server ${with.db}"/>
<property name="conf3" value="--enable-proxy ${with.db}"/>
<property name="conf4" value="--enable-server --enable-agent --enable-proxy ${with.db}"/>
<property name="conf6" value="--enable-server --enable-agent --enable-proxy ${with.db} --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl"/>
<property name="conf7" value="--enable-server --enable-agent --enable-proxy ${with.db} --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-gnutls --with-ldap --with-libcurl"/>
</target>
<!-- Additional Zabbix configuration parameters -->
<target name="init-conf-options-2">
<property name="conf8" value="--enable-agent2"/>
<property name="conf9" value="--enable-server --enable-agent --enable-proxy ${with.db} --with-ssh"/>
</target>
<!-- Cppcheck static analyzer target -->
<target name="cppcheck-static-analyzer">
<exec executable="./bootstrap.sh" failonerror="on"/>
<exec executable="scan-build" failonerror="on">
<arg line="./configure"/>
<arg line="--quiet"/>
<arg line="--enable-server --enable-agent --enable-proxy --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-libevent --with-ldap --with-libcurl"/>
</exec>
<exec executable="cppcheck" error="tests_results/cppcheck.xml" failonerror="on">
<arg line="--enable=all"/>
<arg line="-j4"/>
<arg line="-I/usr/include"/>
<arg line="-I/usr/local/include"/>
<arg line="-I./include"/>
<!-- Exclude Duktape library from checking -->
<arg line="-isrc/libs/zbxembed/duk_config.h"/>
<arg line="-isrc/libs/zbxembed/duktape.c"/>
<arg line="-isrc/libs/zbxembed/duktape.h"/>
<arg line="--suppress=variableScope:*"/>
<arg line="--suppress=ConfigurationNotChecked:*"/>
<arg line="--inconclusive"/>
<arg line="--force"/>
<arg line="--xml"/>
<arg line="--xml-version=2"/>
<arg line="."/>
</exec>
<mkdir dir="tests_results/cppcheck_html"/>
<exec executable="cppcheck-htmlreport" failonerror="on">
<arg line="--source-dir=."/>
<arg line="--title=Zabbix"/>
<arg line="--file=./tests_results/cppcheck.xml"/>
<arg line="--report-dir=./tests_results/cppcheck_html"/>
</exec>
</target>
<!-- Clang Static Analyzer target with various configuration parameters -->
<target name="clang-static-analyzer" depends="init-conf-options">
<delete dir="clang-scan-build-reports"/>
<exec executable="./bootstrap.sh" failonerror="on"/>
<propertyselector property="conf.list" delimiter="," match="conf(\d+)"/>
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
<for list="${conf.list}" param="name" delimiter=",">
<sequential>
<exec executable="scan-build" failonerror="on">
<arg line="./configure"/>
<arg line="-q"/>
<arg line="${@{name}}"/>
</exec>
<trycatch>
<try>
<exec executable="scan-build" failonerror="on">
<arg line="-plist-html"/>
<arg line="-o"/>
<arg line="./clang-scan-build-reports"/>
<arg line="make"/>
<arg line="-s"/>
<arg line="-j5"/>
</exec>
</try>
<finally>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="clean"/>
</exec>
</finally>
</trycatch>
</sequential>
</for>
</target>
<macrodef name="make">
<!-- Build Zabbix with the specified command line arguments -->
<attribute name="args"/>
<attribute name="cc" default="gcc"/>
<attribute name="target" default=""/>
<attribute name="post-action" default=""/>
<sequential>
<!-- initialize cflags depending on used compiler -->
<local name="common.cflags"/>
<local name="cc.cflags"/>
<property name="common.cflags" value="-O2 -g"/>
<switch value="@{cc}">
<case value="gcc">
<property name="cc.cflags" value="-Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -Wno-maybe-uninitialized -Wformat -Wmissing-prototypes"/>
</case>
<case value="clang">
<property name="cc.cflags" value=""/>
</case>
<default>
<fail>Unknown compiler type: @{cc}</fail>
</default>
</switch>
<!-- clean, configure and build -->
<exec executable="./configure" failonerror="on">
<env key="CC" value="@{cc}"/>
<arg line="@{args}"/>
<arg line="--prefix=$(pwd)/install"/>
<arg line="CFLAGS="${common.cflags} ${cc.cflags}""/>
</exec>
<trycatch>
<try>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="@{target}"/>
</exec>
<if>
<not >
<equals arg1="@{post-action}" arg2=""/>
</not>
<then>
<antcall target="@{post-action}"/>
</then>
</if>
</try>
<finally>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="clean"/>
</exec>
</finally>
</trycatch>
</sequential>
</macrodef>
<target name="make-db-mysql" if="${with.mysql}">
<!-- Build Zabbix with postgresql database -->
<sequential>
<make args="--enable-server --enable-agent --enable-proxy --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl"/>
</sequential>
</target>
<target name="make-db-postgresql" if="${with.postgresql}">
<!-- Build Zabbix with postgresql database -->
<sequential>
<make args="--enable-server --enable-agent --enable-proxy --with-postgresql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl"/>
</sequential>
</target>
<target name="make-db-oracle" if="${with.oracle}">
<!-- Build Zabbix with oracle database -->
<sequential>
<make args="--enable-server --enable-agent --enable-proxy --with-oracle --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
</sequential>
</target>
<!-- Build Zabbix with all supported databases -->
<target name="make-db" depends="make-db-mysql,make-db-postgresql,make-db-oracle"/>
<macrodef name="make-tests">
<!-- Build Zabbix cmocka tests with the specified command line arguments -->
<attribute name="conf"/>
<attribute name="conf-name"/>
<sequential>
<!-- clean, configure and build -->
<exec executable="./configure" failonerror="on">
<arg line="@{conf}"/>
</exec>
<trycatch>
<try>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="tests_build"/>
</exec>
<mkdir dir="tests_results/@{conf-name}"/>
<exec executable="tests/tests_run.pl" failonerror="off" output="tests_results/@{conf-name}/output.xml">
<arg line="-x @{conf-name}"/>
</exec>
</try>
<finally>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="clean"/>
</exec>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="-C"/>
<arg line="tests"/>
<arg line="clean"/>
</exec>
</finally>
</trycatch>
</sequential>
</macrodef>
<target name="init-cmocka-test-conf-options">
<!-- Zabbix various configuration parameters for cmocka tests -->
<!-- Configuration option name must consist of prefix 'cmocka-', configuration order number
and configuration title: cmocka-<number>-<title> -->
<property name="cmocka-1-default" value="-q CFLAGS='-Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -Wno-maybe-uninitialized -Wformat -Wmissing-prototypes' --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl --with-iconv --with-libpcre"/>
<property name="cmocka-2-agent-only" value="-q --enable-agent"/>
<property name="cmocka-3-server-only" value="-q --enable-server --with-mysql"/>
<property name="cmocka-4-proxy-only" value="-q --enable-proxy --with-sqlite3"/>
<property name="cmocka-5-sanitizer" value="CC=clang CFLAGS='-Wall -Wextra -Wenum-conversion -g -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-mysql --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl --with-iconv --with-libpcre"/>
</target>
<target name="cmocka-tests" depends="init-cmocka-test-conf-options">
<!-- Build Zabbix with cmocka tests -->
<delete dir="tests_results"/>
<mkdir dir="tests_results"/>
<exec executable="./bootstrap.sh" failonerror="on">
<arg line="tests"/>
</exec>
<propertyselector property="conf.list" delimiter="," match="cmocka-(.*)" select="\1"/>
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
<for list="${conf.list}" param="name" delimiter=",">
<sequential>
<make-tests conf="${cmocka-@{name}}" conf-name="@{name}"/>
</sequential>
</for>
</target>
<target name="init-cmocka-ora-test-conf-options">
<property name="ORA_INCLUDE" value="/usr/include/oracle/19.9/client64"/>
<property name="ORA_LIB" value="/usr/lib/oracle/19.9/client64/lib"/>
<!-- Zabbix various configuration parameters for cmocka Oracle tests -->
<!-- Configuration option name must consist of prefix 'cmocka-ora-', configuration order number
and configuration title: cmocka-<number>-<title> -->
<property name="cmocka-ora-1-default" value="-q CFLAGS='-Wall -Wextra -Wdeclaration-after-statement -Wpointer-arith -Wno-maybe-uninitialized -Wformat -Wmissing-prototypes' --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl --with-iconv --with-libpcre --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="cmocka-ora-2-server-only" value="-q --enable-server --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="cmocka-ora-3-proxy-only" value="-q --enable-proxy --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="cmocka-ora-4-sanitizer" value="CC=clang CFLAGS='-Wall -Wextra -Wenum-conversion -g -O2 -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-openipmi --with-libevent --with-openssl --with-ldap --with-libcurl --with-iconv --with-libpcre --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
</target>
<target name="cmocka-ora-tests" depends="init-cmocka-ora-test-conf-options">
<!-- Build Zabbix with cmocka Oracle tests -->
<delete dir="tests_results"/>
<mkdir dir="tests_results"/>
<exec executable="./bootstrap.sh" failonerror="on"/>
<propertyselector property="conf.list" delimiter="," match="cmocka-ora-(.*)" select="\1"/>
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
<for list="${conf.list}" param="name" delimiter=",">
<sequential>
<make-tests conf="${cmocka-ora-@{name}}" conf-name="@{name}"/>
</sequential>
</for>
</target>
<target name="gen-test-coverage-report">
<!-- Generate Zabbix cmocka tests coverage report-->
<delete dir="tests_results"/>
<mkdir dir="tests_results"/>
<mkdir dir="tests_results/html"/>
<exec executable="lcov" failonerror="on">
<arg line="--directory"/>
<arg line="src"/>
<arg line="-zerocounters"/>
</exec>
<exec executable="./bootstrap.sh" failonerror="on">
<arg line="tests"/>
</exec>
<make-tests conf="CFLAGS='--coverage' -q --enable-server --enable-agent --enable-proxy --enable-ipv6 --with-mysql" conf-name="gen-test-coverage-report"/>
<exec executable="lcov" failonerror="on">
<arg line="--directory"/>
<arg line="src"/>
<arg line="--capture"/>
<arg line="--output-file"/>
<arg line="tests_results/html/app.info"/>
</exec>
<exec executable="genhtml" failonerror="on">
<arg line="-p"/>
<arg line="${user.dir}"/>
<arg line="-o"/>
<arg line="tests_results/html"/>
<arg line="tests_results/html/app.info"/>
</exec>
</target>
<target name="make-gcc" depends="init-conf-options,init-conf-options-2">
<!-- Build Zabbix with various configuration parameters -->
<propertyselector property="conf.list" delimiter="," match="conf(\d+)"/>
<sortlist property="conf.list" delimiter="," value="${conf.list}" override="true"/>
<for list="${conf.list}" param="name" delimiter=",">
<sequential>
<make args="${@{name}}"/>
</sequential>
</for>
</target>
<target name="build-dist" depends="make-gcc,make-db"/>
<target name="make-dist">
<!-- Create & build Zabbix distribution -->
<exec executable="./bootstrap.sh" failonerror="on"/>
<exec executable="./configure" failonerror="on">
<arg line="--quiet"/>
</exec>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="dbschema"/>
</exec>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="dist"/>
</exec>
<apply executable="tar">
<arg line="xzf"/>
<fileset dir="." includes="zabbix-*.tar.gz"/>
</apply>
<move tofile="sources">
<dirset dir="." includes="zabbix-*"/>
</move>
<ant antfile="../build-backend.xml" dir="sources" target="build-dist" inheritAll="true" inheritRefs="true"/>
</target>
<target name="agent2-tests">
<!-- Create, build & test agent2 -->
<exec executable="./bootstrap.sh" failonerror="on"/>
<exec executable="./configure" failonerror="on">
<arg line="--quiet"/>
<arg line="--enable-agent2"/>
</exec>
<exec executable="make" failonerror="on">
<arg line="-s"/>
<arg line="-j5"/>
<arg line="check"/>
</exec>
</target>
<target name="build" depends="make-dist"/>
</project>