forked from zabbix/zabbix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-backend.xml
368 lines (343 loc) · 14.3 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" />
<!-- oracle oci library has functions declarations without arguments: f() instead of f(void), so it triggers -Wstrict-prototypes warning -->
<property name="COMP_FLAGS_ORACLE" value="-g -std=gnu99 -pedantic -Wall -Wextra -Wunused -Wshadow -Wdeclaration-after-statement -Wpointer-arith -Wno-maybe-uninitialized -Wformat -Wmissing-prototypes -Wunreachable-code -Wformat-extra-args -Wno-missing-field-initializers -Wno-missing-field-initializers -Wincompatible-pointer-types -Wnull-dereference -Wold-style-definition -Wmissing-declarations -Wunused-parameter -Winit-self -Wnested-externs -Wjump-misses-init -Wdangling-else -Wformat-signedness"/>
<property name="COMP_FLAGS" value="-Wstrict-prototypes ${COMP_FLAGS_ORACLE}"/>
<property name="ZBX_BASE_FLAGS" value="--enable-server --enable-agent --enable-proxy --with-libxml2 --with-unixodbc --with-net-snmp --with-ssh2 --with-libevent --with-ldap --with-libcurl"/>
<!-- 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="with.db" value="--with-oracle"/>
<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="${ZBX_BASE_FLAGS} ${with.db} --with-openipmi --with-openssl"/>
<property name="conf7" value="${ZBX_BASE_FLAGS} ${with.db} --with-openipmi --with-gnutls"/>
</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"/>
<property name="conf10" value="--enable-agent --with-libmodbus"/>
</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="${ZBX_BASE_FLAGS} --with-mysql"/>
</exec>
<exec executable="cppcheck" error="${SCANFILE}" failonerror="on">
<arg line="--enable=all"/>
<arg line="-j5"/>
<arg line="-I/usr/include"/>
<arg line="-I/usr/local/include"/>
<arg line="-I./include/common"/>
<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="--cppcheck-build-dir=${CPPCHECK_BUILD_DIR}"/>
<arg line="."/>
</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="${COMP_FLAGS_ORACLE}"/>
</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" unless="${with.mysql}">
<!-- Build Zabbix with mysql database -->
<sequential>
<make args="${ZBX_BASE_FLAGS} --with-mysql --with-openipmi --with-openssl --enable-ipv6 --with-libmodbus"/>
</sequential>
</target>
<target name="make-db-postgresql" unless="${with.postgresql}">
<!-- Build Zabbix with postgresql database -->
<sequential>
<make args="${ZBX_BASE_FLAGS} --with-postgresql --with-openipmi --with-openssl"/>
</sequential>
</target>
<target name="make-db-oracle" unless="${with.oracle}">
<!-- Build Zabbix with oracle database -->
<sequential>
<make args="${ZBX_BASE_FLAGS} --with-oracle --with-openipmi --with-openssl --with-oracle-include=/usr/include/oracle/19.8/client64 --with-oracle-lib=/usr/lib/oracle/19.8/client64/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='${COMP_FLAGS}' ${ZBX_BASE_FLAGS} --enable-ipv6 --with-mysql --with-openipmi --with-openssl --with-iconv --with-libpcre"/>
<property name="cmocka-2-agent-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-agent"/>
<property name="cmocka-3-server-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-server --with-mysql"/>
<property name="cmocka-4-proxy-only" value="-q CFLAGS='${COMP_FLAGS}' --enable-proxy --with-sqlite3"/>
<property name="cmocka-5-sanitizer" value="CC=clang CFLAGS='${COMP_FLAGS} -Wenum-conversion -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q ${ZBX_BASE_FLAGS} --with-openssl --with-openipmi --enable-ipv6 --with-mysql --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/12.1/client64"/>
<property name="ORA_LIB" value="/usr/lib/oracle/12.1/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='${COMP_FLAGS_ORACLE}' ${ZBX_BASE_FLAGS} --enable-ipv6 --with-openipmi --with-openssl --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 CFLAGS='${COMP_FLAGS_ORACLE}' --enable-server --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="cmocka-ora-3-proxy-only" value="-q CFLAGS='${COMP_FLAGS_ORACLE}' --enable-proxy --with-oracle --with-oracle-include=${ORA_INCLUDE} --with-oracle-lib=${ORA_LIB}"/>
<property name="cmocka-ora-4-sanitizer" value="CC=clang CFLAGS='${COMP_FLAGS_ORACLE} -Wenum-conversion -O2 -fsanitize=leak,address' LDFLAGS='-fsanitize=leak,address' -q ${ZBX_BASE_FLAGS} --enable-ipv6 --with-openipmi --with-openssl --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>