forked from openbmc/bmcweb
-
Notifications
You must be signed in to change notification settings - Fork 1
/
meson.build
476 lines (427 loc) · 13.9 KB
/
meson.build
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
project(
'bmcweb',
'cpp',
version: '1.0',
meson_version: '>=1.3.0',
default_options: [
'b_lto_mode=default',
'b_lto_threads=0',
'b_lto=true',
'b_ndebug=if-release',
'buildtype=debugoptimized',
'cpp_rtti=false',
'cpp_std=c++23',
'warning_level=3',
'werror=true',
],
)
# Project related links
project_pretty_name = 'bmcweb'
project_url = 'https://github.com/openbmc/' + project_pretty_name
project_issues_url = project_url + '/issues/new'
summary('Issues', project_issues_url, section: 'Report Issues')
# Validate the c++ Standard
if get_option('cpp_std') != 'c++23'
error('This project requires c++23 support')
endif
# Get compiler and default build type
cxx = meson.get_compiler('cpp')
build = get_option('buildtype')
optimization = get_option('optimization')
summary('Build Type', build, section: 'Build Info')
summary('Optimization', optimization, section: 'Build Info')
# remove debug information for minsize buildtype
if (get_option('buildtype') == 'minsize')
add_project_arguments(
['-fdata-sections', '-ffunction-sections'],
language: 'cpp',
)
add_project_arguments('-DNDEBUG', language: 'cpp')
endif
if (get_option('dns-resolver') == 'systemd-dbus')
add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language: 'cpp')
endif
# Disable lto when compiling with no optimization
if (get_option('optimization') == '0')
add_project_arguments('-fno-lto', language: 'cpp')
message('Disabling lto & its supported features as optimization is disabled')
endif
# Include Directories
incdir = include_directories(
'include',
'redfish-core/include',
'redfish-core/lib',
'http',
)
incdir_cli = include_directories('http', 'include')
if (get_option('tests').allowed())
summary('unittest', 'NA', section: 'Features')
endif
# Add compiler arguments
if (cxx.get_id() == 'clang')
if (cxx.version().version_compare('<17.0'))
error('This project requires clang-17 or higher')
endif
add_project_arguments(
'-Weverything',
'-Wformat=2',
'-Wno-c++98-compat-pedantic',
'-Wno-c++98-compat',
'-Wno-c++20-extensions',
'-Wno-documentation-unknown-command',
'-Wno-documentation',
'-Wno-exit-time-destructors',
'-Wno-global-constructors',
'-Wno-newline-eof',
'-Wno-padded',
'-Wno-shadow',
'-Wno-used-but-marked-unused',
'-Wno-weak-vtables',
'-Wno-switch-enum',
'-Wno-unused-macros',
'-Wno-covered-switch-default',
'-Wno-disabled-macro-expansion',
'-Wno-unneeded-internal-declaration',
language: 'cpp',
)
endif
if (cxx.get_id() == 'gcc')
if (cxx.version().version_compare('<13.0'))
error('This project requires gcc-13 or higher')
endif
add_project_arguments(
'-Wformat=2',
'-Wcast-align',
'-Wconversion',
'-Woverloaded-virtual',
'-Wsign-conversion',
'-Wunused',
'-Wduplicated-cond',
'-Wduplicated-branches',
'-Wlogical-op',
'-Wnull-dereference',
'-Wunused-parameter',
'-Wdouble-promotion',
'-Wshadow',
'-Wno-psabi',
'-Wno-attributes',
language: 'cpp',
)
endif
if (get_option('buildtype') != 'plain')
if (get_option('b_lto') == true and get_option('optimization') != '0')
# Reduce the binary size by removing unnecessary
# dynamic symbol table entries
add_project_arguments(
cxx.get_supported_arguments(
[
'-fno-fat-lto-objects',
'-fvisibility=hidden',
'-fvisibility-inlines-hidden',
],
),
language: 'cpp',
)
if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
endif
endif
endif
# Set Compiler Security flags
security_flags = [
'-fstack-protector-strong',
'-fPIE',
'-fPIC',
'-D_FORTIFY_SOURCE=2',
'-Wformat',
'-Wformat-security',
]
## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
if not (get_option('buildtype') == 'plain'
or get_option('buildtype').startswith('debug')
)
add_project_arguments(
cxx.get_supported_arguments([security_flags]),
language: 'cpp',
)
endif
# Boost dependency configuration
add_project_arguments(
cxx.get_supported_arguments(
[
'-DBOOST_ALL_NO_LIB',
'-DBOOST_ALLOW_DEPRECATED_HEADERS',
'-DBOOST_ASIO_DISABLE_THREADS',
'-DBOOST_ASIO_NO_DEPRECATED',
'-DBOOST_ASIO_SEPARATE_COMPILATION',
'-DBOOST_BEAST_SEPARATE_COMPILATION',
'-DBOOST_EXCEPTION_DISABLE',
'-DBOOST_NO_EXCEPTIONS',
'-DBOOST_URL_NO_SOURCE_LOCATION',
'-DBOOST_SPIRIT_X3_NO_RTTI',
'-DJSON_NOEXCEPTION',
'-DOPENSSL_NO_FILENAMES',
'-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
],
),
language: 'cpp',
)
# Find the dependency modules, if not found use meson wrap to get them
# automatically during the configure step
bmcweb_dependencies = []
bmcweb_cli_dependencies = []
pam = cxx.find_library('pam', required: true)
atomic = cxx.find_library('atomic', required: true)
bmcweb_dependencies += [pam, atomic]
openssl = dependency('openssl', required: false, version: '>=3.0.0')
if not openssl.found() or get_option('b_sanitize') != 'none'
openssl_proj = subproject(
'openssl',
required: true,
default_options: ['warning_level=0', 'werror=false'],
)
openssl = openssl_proj.get_variable('openssl_dep')
openssl = openssl.as_system('system')
endif
bmcweb_dependencies += [openssl]
nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false)
if not nghttp2.found()
cmake = import('cmake')
opt_var = cmake.subproject_options()
opt_var.add_cmake_defines(
{'ENABLE_LIB_ONLY': true, 'ENABLE_STATIC_LIB': true},
)
nghttp2_ex = cmake.subproject('nghttp2', options: opt_var)
nghttp2 = nghttp2_ex.dependency('nghttp2')
endif
bmcweb_dependencies += nghttp2
sdbusplus = dependency('sdbusplus', required: false, include_type: 'system')
if not sdbusplus.found()
sdbusplus_proj = subproject('sdbusplus', required: true)
sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
sdbusplus = sdbusplus.as_system('system')
endif
bmcweb_dependencies += sdbusplus
bmcweb_cli_dependencies += sdbusplus
cli11 = dependency('CLI11', required: false, include_type: 'system')
if not cli11.found()
cli11_proj = subproject('cli11', required: true)
cli11 = cli11_proj.get_variable('CLI11_dep')
cli11 = cli11.as_system('system')
endif
bmcweb_cli_dependencies += cli11
tinyxml = dependency(
'tinyxml2',
include_type: 'system',
version: '>=9.0.0',
default_options: ['tests=false'],
)
if not tinyxml.found()
tinyxml_proj = subproject('tinyxml2', required: true)
tinyxml = tinyxml_proj.get_variable('tinyxml_dep')
tinyxml = tinyxml.as_system('system')
endif
bmcweb_dependencies += tinyxml
systemd = dependency('systemd')
libsystemd = dependency('libsystemd')
add_project_arguments(
'-DLIBSYSTEMD_VERSION=' + libsystemd.version(),
language: 'cpp',
)
zlib = dependency('zlib')
bmcweb_dependencies += [libsystemd, zlib]
nlohmann_json_dep = dependency(
'nlohmann_json',
version: '>=3.11.3',
include_type: 'system',
)
bmcweb_dependencies += nlohmann_json_dep
boost = dependency(
'boost',
modules: ['url'],
version: '>=1.84.0',
required: false,
include_type: 'system',
)
if boost.found()
bmcweb_dependencies += [boost]
bmcweb_cli_dependencies += [boost]
else
cmake = import('cmake')
opt = cmake.subproject_options()
boost_libs = [
'asio',
'beast',
'circular_buffer',
'callable_traits',
'headers',
'process',
'type_index',
'url',
'uuid',
'spirit',
]
opt.add_cmake_defines(
{
# 1.86.0 fails this. Hopefully fixed in 1.86.1
'CMAKE_CXX_FLAGS': '-Wno-unused-parameter',
'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs),
'BUILD_SHARED_LIBS': 'OFF',
},
)
boost = cmake.subproject('boost', required: true, options: opt)
foreach boost_lib : boost_libs
boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system()
bmcweb_dependencies += [boost_lib_instance]
bmcweb_cli_dependencies += [boost_lib_instance]
endforeach
endif
systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
bindir = get_option('prefix') + '/' + get_option('bindir')
libexec = get_option('prefix') + '/' + get_option('libexecdir')
summary(
{
'prefix': get_option('prefix'),
'bindir': bindir,
'systemd unit directory': systemd_system_unit_dir,
},
section: 'Directories',
)
subdir('static')
subdir('redfish-core')
# Config subdirectory
subdir('config')
bmcweb_dependencies += conf_h_dep
bmcweb_cli_dependencies += conf_h_dep
# Source files
fs = import('fs')
srcfiles_bmcweb = files(
'http/mutual_tls.cpp',
'redfish-core/src/error_messages.cpp',
'redfish-core/src/event_log.cpp',
'redfish-core/src/filter_expr_executor.cpp',
'redfish-core/src/filter_expr_printer.cpp',
'redfish-core/src/redfish.cpp',
'redfish-core/src/registries.cpp',
'redfish-core/src/subscription.cpp',
'redfish-core/src/utils/dbus_utils.cpp',
'redfish-core/src/utils/json_utils.cpp',
'redfish-core/src/utils/time_utils.cpp',
'src/boost_asio.cpp',
'src/boost_asio_ssl.cpp',
'src/boost_beast.cpp',
'src/dbus_singleton.cpp',
'src/json_html_serializer.cpp',
'src/ossl_random.cpp',
'src/ssl_key_handler.cpp',
'src/webserver_run.cpp',
)
bmcweblib = static_library(
'bmcweblib',
srcfiles_bmcweb,
include_directories: incdir,
dependencies: bmcweb_dependencies,
)
# Generate the bmcwebd daemon
executable(
'bmcwebd',
'src/webserver_main.cpp',
include_directories: incdir,
dependencies: bmcweb_dependencies,
link_with: bmcweblib,
link_args: '-Wl,--gc-sections',
install: true,
install_dir: libexec,
)
# Generate the bmcweb CLI application
executable(
'bmcweb',
['src/webserver_cli.cpp', 'src/boost_asio.cpp'],
include_directories: incdir_cli,
dependencies: bmcweb_cli_dependencies,
install: true,
install_dir: bindir,
)
srcfiles_unittest = files(
'test/http/crow_getroutes_test.cpp',
'test/http/http2_connection_test.cpp',
'test/http/http_body_test.cpp',
'test/http/http_connection_test.cpp',
'test/http/http_response_test.cpp',
'test/http/mutual_tls.cpp',
'test/http/mutual_tls_meta.cpp',
'test/http/parsing_test.cpp',
'test/http/router_test.cpp',
'test/http/server_sent_event_test.cpp',
'test/http/utility_test.cpp',
'test/http/verb_test.cpp',
'test/include/async_resolve_test.cpp',
'test/include/credential_pipe_test.cpp',
'test/include/dbus_utility_test.cpp',
'test/include/google/google_service_root_test.cpp',
'test/include/http_utility_test.cpp',
'test/include/human_sort_test.cpp',
'test/include/ibm/configfile_test.cpp',
'test/include/json_html_serializer.cpp',
'test/include/multipart_test.cpp',
'test/include/openbmc_dbus_rest_test.cpp',
'test/include/ossl_random.cpp',
'test/include/ssl_key_handler_test.cpp',
'test/include/str_utility_test.cpp',
'test/redfish-core/include/event_log_test.cpp',
'test/redfish-core/include/event_matches_filter_test.cpp',
'test/redfish-core/include/filter_expr_executor_test.cpp',
'test/redfish-core/include/filter_expr_parser_test.cpp',
'test/redfish-core/include/privileges_test.cpp',
'test/redfish-core/include/redfish_aggregator_test.cpp',
'test/redfish-core/include/registries_test.cpp',
'test/redfish-core/include/utils/dbus_utils.cpp',
'test/redfish-core/include/utils/hex_utils_test.cpp',
'test/redfish-core/include/utils/ip_utils_test.cpp',
'test/redfish-core/include/utils/json_utils_test.cpp',
'test/redfish-core/include/redfish_test.cpp',
'test/redfish-core/include/utils/query_param_test.cpp',
'test/redfish-core/include/utils/sensor_utils_test.cpp',
'test/redfish-core/include/utils/stl_utils_test.cpp',
'test/redfish-core/include/utils/time_utils_test.cpp',
'test/redfish-core/lib/chassis_test.cpp',
'test/redfish-core/lib/log_services_dump_test.cpp',
'test/redfish-core/lib/manager_diagnostic_data_test.cpp',
'test/redfish-core/lib/manager_logservices_journal_test.cpp',
'test/redfish-core/lib/metadata_test.cpp',
'test/redfish-core/lib/power_subsystem_test.cpp',
'test/redfish-core/lib/service_root_test.cpp',
'test/redfish-core/lib/system_test.cpp',
'test/redfish-core/lib/systems_logservices_postcode.cpp',
'test/redfish-core/lib/thermal_subsystem_test.cpp',
'test/redfish-core/lib/update_service_test.cpp',
)
if (get_option('tests').allowed())
gtest = dependency(
'gtest_main',
main: true,
version: '>=1.15.0',
required: true,
)
gmock = dependency('gmock', required: true)
gtestlib = static_library('gtestlib', dependencies: [gtest, gmock])
gtestdep = declare_dependency(
link_with: gtestlib,
dependencies: [
gtest.partial_dependency(includes: true),
gmock.partial_dependency(includes: true),
],
)
# generate the test executable
foreach test_src : srcfiles_unittest
test_bin = executable(
fs.stem(test_src),
test_src,
link_with: bmcweblib,
include_directories: incdir,
install_dir: bindir,
dependencies: bmcweb_dependencies + [gtestdep],
)
test(fs.stem(test_src), test_bin, protocol: 'gtest')
endforeach
endif