blob: d24437d5f86efbc7fea6b17715dec03fa428a760 [file] [log] [blame]
Ed Tanousf2caadc2024-01-02 18:34:36 -08001project(
2 'bmcweb',
3 'cpp',
4 version: '1.0',
Ed Tanous8dc3ddf2024-06-25 13:00:16 -07005 meson_version: '>=1.3.0',
Ed Tanousf2caadc2024-01-02 18:34:36 -08006 default_options: [
7 'b_lto_mode=default',
8 'b_lto_threads=0',
9 'b_lto=true',
10 'b_ndebug=if-release',
11 'buildtype=debugoptimized',
12 'cpp_rtti=false',
Patrick Williams921cfcd2023-08-23 06:31:07 -050013 'cpp_std=c++23',
Ed Tanousf2caadc2024-01-02 18:34:36 -080014 'warning_level=3',
15 'werror=true',
16 ],
17)
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053018
19# Project related links
20
21project_pretty_name = 'bmcweb'
22project_url = 'https://github.com/openbmc/' + project_pretty_name
23project_issues_url = project_url + '/issues/new'
Ed Tanousf2caadc2024-01-02 18:34:36 -080024summary('Issues', project_issues_url, section: 'Report Issues')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053025
26# Validate the c++ Standard
27
Patrick Williams921cfcd2023-08-23 06:31:07 -050028if get_option('cpp_std') != 'c++23'
29 error('This project requires c++23 support')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053030endif
31
32# Get compiler and default build type
33
34cxx = meson.get_compiler('cpp')
35build = get_option('buildtype')
36optimization = get_option('optimization')
Ed Tanousf2caadc2024-01-02 18:34:36 -080037summary('Build Type', build, section: 'Build Info')
38summary('Optimization', optimization, section: 'Build Info')
Ed Tanous5e34b672021-02-05 14:21:27 -080039
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053040# remove debug information for minsize buildtype
Ed Tanousf2caadc2024-01-02 18:34:36 -080041if (get_option('buildtype') == 'minsize')
Ed Tanous92e26be2024-08-21 13:39:14 -070042 add_project_arguments(
43 ['-fdata-sections', '-ffunction-sections'],
44 language: 'cpp',
45 )
Ed Tanousf2caadc2024-01-02 18:34:36 -080046 add_project_arguments('-DNDEBUG', language: 'cpp')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053047endif
48
Ed Tanousf2caadc2024-01-02 18:34:36 -080049if (get_option('dns-resolver') == 'systemd-dbus')
50 add_project_arguments('-DBMCWEB_DBUS_DNS_RESOLVER', language: 'cpp')
Ed Tanousf8ca6d72022-06-28 12:12:03 -070051endif
52
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053053# Disable lto when compiling with no optimization
Ed Tanousf2caadc2024-01-02 18:34:36 -080054if (get_option('optimization') == '0')
55 add_project_arguments('-fno-lto', language: 'cpp')
56 message('Disabling lto & its supported features as optimization is disabled')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053057endif
58
59# Include Directories
60
Ed Tanous92e26be2024-08-21 13:39:14 -070061incdir = include_directories(
62 'include',
63 'redfish-core/include',
64 'redfish-core/lib',
65 'http',
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -070066)
Ed Tanous92e26be2024-08-21 13:39:14 -070067incdir_cli = include_directories('http', 'include')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053068
Manojkiran Edaaf6298d2020-05-27 08:51:32 +053069# Add compiler arguments
Ed Tanous27f5ecf2025-02-09 09:46:52 -080070boost_flags = ['-Wno-unused-parameter']
71nghttp2_flags = []
Ed Tanousade3f092024-03-13 13:28:36 -070072if (cxx.get_id() == 'clang')
Ed Tanousf2caadc2024-01-02 18:34:36 -080073 if (cxx.version().version_compare('<17.0'))
74 error('This project requires clang-17 or higher')
75 endif
76 add_project_arguments(
77 '-Weverything',
78 '-Wformat=2',
Ed Tanous3d158642025-05-12 14:20:49 -070079 # https://github.com/llvm/llvm-project/issues/101614
80 '-fno-builtin-std-forward_like',
Ed Tanous25991f72024-06-13 18:10:25 -070081 '-Wno-c++20-extensions',
Ed Tanous27f5ecf2025-02-09 09:46:52 -080082 '-Wno-c++23-extensions',
83 '-Wno-c++26-extensions',
Ed Tanousb5edf032025-02-09 09:45:00 -080084 '-Wno-c++98-compat',
85 '-Wno-c++98-compat-pedantic',
86 '-Wno-covered-switch-default',
87 '-Wno-disabled-macro-expansion',
Ed Tanousf2caadc2024-01-02 18:34:36 -080088 '-Wno-documentation',
Ed Tanousb5edf032025-02-09 09:45:00 -080089 '-Wno-documentation-unknown-command',
Ed Tanousf2caadc2024-01-02 18:34:36 -080090 '-Wno-exit-time-destructors',
91 '-Wno-global-constructors',
Ed Tanous27f5ecf2025-02-09 09:46:52 -080092 '-Wno-missing-include-dirs',
Ed Tanousf2caadc2024-01-02 18:34:36 -080093 '-Wno-newline-eof',
94 '-Wno-padded',
95 '-Wno-shadow',
Ed Tanousf2caadc2024-01-02 18:34:36 -080096 '-Wno-switch-enum',
Ed Tanous724985f2024-06-05 09:19:06 -070097 '-Wno-unneeded-internal-declaration',
Ed Tanous60b8de32024-12-18 11:01:53 -080098 '-Wno-unsafe-buffer-usage-in-container',
Ed Tanous3d158642025-05-12 14:20:49 -070099 '-Wno-unsafe-buffer-usage-in-libc-call',
Ed Tanousb5edf032025-02-09 09:45:00 -0800100 '-Wno-unused-macros',
101 '-Wno-used-but-marked-unused',
102 '-Wno-weak-vtables',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800103 language: 'cpp',
104 )
Ed Tanous5c467f92025-06-05 11:22:53 -0700105 if (cxx.version().version_compare('>=21.0'))
106 # TODO(Ed) These warnings look valid and need cleaned up.
107 add_project_arguments(
108 '-Wno-unique-object-duplication',
109 '-Wno-nrvo',
110 language: 'cpp',
111 )
112 endif
113
Ed Tanous27f5ecf2025-02-09 09:46:52 -0800114 boost_flags += ['-Wno-strict-prototypes', '-Wno-unused-but-set-variable']
115 nghttp2_flags += ['-Wno-extra-semi']
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530116endif
117
Ed Tanousade3f092024-03-13 13:28:36 -0700118if (cxx.get_id() == 'gcc')
Ed Tanousf2caadc2024-01-02 18:34:36 -0800119 if (cxx.version().version_compare('<13.0'))
120 error('This project requires gcc-13 or higher')
121 endif
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530122
Ed Tanousf2caadc2024-01-02 18:34:36 -0800123 add_project_arguments(
124 '-Wformat=2',
125 '-Wcast-align',
126 '-Wconversion',
127 '-Woverloaded-virtual',
128 '-Wsign-conversion',
129 '-Wunused',
130 '-Wduplicated-cond',
131 '-Wduplicated-branches',
132 '-Wlogical-op',
133 '-Wnull-dereference',
134 '-Wunused-parameter',
135 '-Wdouble-promotion',
136 '-Wshadow',
137 '-Wno-psabi',
138 '-Wno-attributes',
139 language: 'cpp',
140 )
Ed Tanousc66403c2021-09-22 15:28:57 -0700141endif
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530142
Ed Tanousc66403c2021-09-22 15:28:57 -0700143if (get_option('buildtype') != 'plain')
Ed Tanousf2caadc2024-01-02 18:34:36 -0800144 if (get_option('b_lto') == true and get_option('optimization') != '0')
145 # Reduce the binary size by removing unnecessary
146 # dynamic symbol table entries
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530147
Ed Tanousf2caadc2024-01-02 18:34:36 -0800148 add_project_arguments(
149 cxx.get_supported_arguments(
150 [
151 '-fno-fat-lto-objects',
152 '-fvisibility=hidden',
153 '-fvisibility-inlines-hidden',
154 ],
155 ),
156 language: 'cpp',
157 )
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530158
Ed Tanousf2caadc2024-01-02 18:34:36 -0800159 if cxx.has_link_argument('-Wl,--exclude-libs,ALL')
160 add_project_link_arguments('-Wl,--exclude-libs,ALL', language: 'cpp')
161 endif
George Liue8204932021-02-01 14:42:49 +0800162 endif
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530163endif
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530164# Set Compiler Security flags
165
166security_flags = [
Ed Tanousf2caadc2024-01-02 18:34:36 -0800167 '-fstack-protector-strong',
168 '-fPIE',
169 '-fPIC',
170 '-D_FORTIFY_SOURCE=2',
171 '-Wformat',
172 '-Wformat-security',
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530173]
174
175## Add security flags for builds of type 'release','debugoptimized' and 'minsize'
176
Ed Tanous92e26be2024-08-21 13:39:14 -0700177if not (get_option('buildtype') == 'plain'
178or get_option('buildtype').startswith('debug')
Ed Tanousf2caadc2024-01-02 18:34:36 -0800179)
Ed Tanous92e26be2024-08-21 13:39:14 -0700180 add_project_arguments(
181 cxx.get_supported_arguments([security_flags]),
182 language: 'cpp',
183 )
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530184endif
185
186# Boost dependency configuration
187
188add_project_arguments(
Ed Tanousf2caadc2024-01-02 18:34:36 -0800189 cxx.get_supported_arguments(
190 [
Ed Tanousf2caadc2024-01-02 18:34:36 -0800191 '-DBOOST_ALL_NO_LIB',
192 '-DBOOST_ALLOW_DEPRECATED_HEADERS',
193 '-DBOOST_ASIO_DISABLE_THREADS',
194 '-DBOOST_ASIO_NO_DEPRECATED',
195 '-DBOOST_ASIO_SEPARATE_COMPILATION',
196 '-DBOOST_BEAST_SEPARATE_COMPILATION',
197 '-DBOOST_EXCEPTION_DISABLE',
198 '-DBOOST_NO_EXCEPTIONS',
199 '-DBOOST_URL_NO_SOURCE_LOCATION',
Ed Tanousf88b2172022-04-15 13:55:05 -0700200 '-DBOOST_SPIRIT_X3_NO_RTTI',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800201 '-DJSON_NOEXCEPTION',
Ed Tanous82b286f2025-05-06 13:29:48 -0700202 '-DJSON_USE_IMPLICIT_CONVERSIONS=0',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800203 '-DOPENSSL_NO_FILENAMES',
204 '-DSDBUSPLUS_DISABLE_BOOST_COROUTINES',
205 ],
206 ),
207 language: 'cpp',
208)
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530209
210# Find the dependency modules, if not found use meson wrap to get them
211# automatically during the configure step
Jason M. Billsceb8ddc2020-11-23 14:38:39 -0800212bmcweb_dependencies = []
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700213bmcweb_cli_dependencies = []
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530214
Nan Zhou8682c5a2021-11-13 11:00:07 -0800215pam = cxx.find_library('pam', required: true)
Ed Tanousf2caadc2024-01-02 18:34:36 -0800216atomic = cxx.find_library('atomic', required: true)
Ed Tanouse7923992023-12-03 14:14:02 -0800217bmcweb_dependencies += [pam, atomic]
218
Ed Tanousf2caadc2024-01-02 18:34:36 -0800219openssl = dependency('openssl', required: false, version: '>=3.0.0')
Ed Tanousd033fd12025-03-13 11:16:24 -0700220if not openssl.found()
Ed Tanousf2caadc2024-01-02 18:34:36 -0800221 openssl_proj = subproject(
222 'openssl',
223 required: true,
224 default_options: ['warning_level=0', 'werror=false'],
225 )
226 openssl = openssl_proj.get_variable('openssl_dep')
227 openssl = openssl.as_system('system')
Ed Tanouse7923992023-12-03 14:14:02 -0800228endif
229bmcweb_dependencies += [openssl]
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530230
Ed Tanousf2caadc2024-01-02 18:34:36 -0800231nghttp2 = dependency('libnghttp2', version: '>=1.52.0', required: false)
Ed Tanousfca2cbe2021-01-28 14:49:59 -0800232if not nghttp2.found()
Ed Tanousf2caadc2024-01-02 18:34:36 -0800233 cmake = import('cmake')
234 opt_var = cmake.subproject_options()
Ed Tanous211cfa42024-04-17 13:43:14 -0700235 opt_var.add_cmake_defines(
Ed Tanous27f5ecf2025-02-09 09:46:52 -0800236 {
237 'CMAKE_C_FLAGS': ' '.join(nghttp2_flags),
238 'CMAKE_CXX_FLAGS': ' '.join(nghttp2_flags),
239 'ENABLE_LIB_ONLY': true,
240 'ENABLE_STATIC_LIB': true,
241 },
Ed Tanous211cfa42024-04-17 13:43:14 -0700242 )
Ed Tanousf2caadc2024-01-02 18:34:36 -0800243 nghttp2_ex = cmake.subproject('nghttp2', options: opt_var)
Ed Tanous211cfa42024-04-17 13:43:14 -0700244 nghttp2 = nghttp2_ex.dependency('nghttp2')
Ed Tanousfca2cbe2021-01-28 14:49:59 -0800245endif
246bmcweb_dependencies += nghttp2
247
Ed Tanousf2caadc2024-01-02 18:34:36 -0800248sdbusplus = dependency('sdbusplus', required: false, include_type: 'system')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530249if not sdbusplus.found()
Ed Tanousf2caadc2024-01-02 18:34:36 -0800250 sdbusplus_proj = subproject('sdbusplus', required: true)
251 sdbusplus = sdbusplus_proj.get_variable('sdbusplus_dep')
252 sdbusplus = sdbusplus.as_system('system')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530253endif
Jason M. Billsceb8ddc2020-11-23 14:38:39 -0800254bmcweb_dependencies += sdbusplus
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700255bmcweb_cli_dependencies += sdbusplus
256
Ed Tanous92e26be2024-08-21 13:39:14 -0700257cli11 = dependency('CLI11', required: false, include_type: 'system')
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700258if not cli11.found()
Ed Tanous92e26be2024-08-21 13:39:14 -0700259 cli11_proj = subproject('cli11', required: true)
260 cli11 = cli11_proj.get_variable('CLI11_dep')
261 cli11 = cli11.as_system('system')
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700262endif
263bmcweb_cli_dependencies += cli11
264
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530265
Ed Tanousc9374ff2023-05-26 09:42:08 -0700266tinyxml = dependency(
267 'tinyxml2',
Cody Smith3a097b22022-05-19 14:22:32 -0700268 include_type: 'system',
Ed Tanousc9374ff2023-05-26 09:42:08 -0700269 version: '>=9.0.0',
Konstantin Aladyshev60e299b2024-04-03 11:44:51 +0300270 default_options: ['tests=false'],
Cody Smith3a097b22022-05-19 14:22:32 -0700271)
Ed Tanousc9374ff2023-05-26 09:42:08 -0700272if not tinyxml.found()
273 tinyxml_proj = subproject('tinyxml2', required: true)
274 tinyxml = tinyxml_proj.get_variable('tinyxml_dep')
275 tinyxml = tinyxml.as_system('system')
276endif
Cody Smith3a097b22022-05-19 14:22:32 -0700277bmcweb_dependencies += tinyxml
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530278
279systemd = dependency('systemd')
Patrick Williams058f54e2024-09-03 16:07:55 -0400280libsystemd = dependency('libsystemd')
Ed Tanous77dcace2024-09-07 16:38:05 -0700281add_project_arguments(
282 '-DLIBSYSTEMD_VERSION=' + libsystemd.version(),
283 language: 'cpp',
284)
Ed Tanous055713e2024-07-17 17:19:36 -0700285
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530286zlib = dependency('zlib')
Patrick Williams058f54e2024-09-03 16:07:55 -0400287bmcweb_dependencies += [libsystemd, zlib]
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530288
Ed Tanous92e26be2024-08-21 13:39:14 -0700289nlohmann_json_dep = dependency(
290 'nlohmann_json',
Patrick Williams0183e472024-10-10 12:31:07 -0400291 version: '>=3.11.3',
Ed Tanous92e26be2024-08-21 13:39:14 -0700292 include_type: 'system',
293)
Patrick Williamsdfd55472023-12-07 11:50:37 -0600294bmcweb_dependencies += nlohmann_json_dep
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530295
Carson Labrado2b5b4da2023-10-18 00:02:10 +0000296boost = dependency(
Ed Tanousf2caadc2024-01-02 18:34:36 -0800297 'boost',
Ed Tanous92e26be2024-08-21 13:39:14 -0700298 modules: ['url'],
Ed Tanousf2caadc2024-01-02 18:34:36 -0800299 version: '>=1.84.0',
300 required: false,
Ed Tanous5e2f0992024-12-02 20:23:51 -0800301 static: true,
Ed Tanousf2caadc2024-01-02 18:34:36 -0800302 include_type: 'system',
Carson Labrado2b5b4da2023-10-18 00:02:10 +0000303)
Jayanth Othayoth90fcc262024-11-11 06:24:49 -0600304
305# Boost version is 1.86 or higher to include the 'process' module
306if boost.version().version_compare('>=1.86.0')
307 boost = dependency(
308 'boost',
309 modules: ['url', 'process'],
310 version: '>=1.86.0',
Ed Tanous5e2f0992024-12-02 20:23:51 -0800311 static: true,
Jayanth Othayoth90fcc262024-11-11 06:24:49 -0600312 required: false,
313 include_type: 'system',
314 )
315endif
316
Ed Tanous6fd29552023-10-04 09:40:14 -0700317if boost.found()
Ed Tanous92e26be2024-08-21 13:39:14 -0700318 bmcweb_dependencies += [boost]
319 bmcweb_cli_dependencies += [boost]
Ed Tanous6fd29552023-10-04 09:40:14 -0700320else
Ed Tanousf2caadc2024-01-02 18:34:36 -0800321 cmake = import('cmake')
322 opt = cmake.subproject_options()
Ed Tanousf80a87f2024-06-16 12:10:33 -0700323 boost_libs = [
324 'asio',
325 'beast',
326 'circular_buffer',
327 'callable_traits',
328 'headers',
329 'process',
330 'type_index',
331 'url',
332 'uuid',
333 'spirit',
334 ]
Ed Tanousf2caadc2024-01-02 18:34:36 -0800335 opt.add_cmake_defines(
336 {
Ed Tanous27f5ecf2025-02-09 09:46:52 -0800337 'CMAKE_CXX_FLAGS': ' '.join(boost_flags),
338 'CMAKE_C_FLAGS': ' '.join(boost_flags),
Ed Tanousf80a87f2024-06-16 12:10:33 -0700339 'BOOST_INCLUDE_LIBRARIES': ';'.join(boost_libs),
Ed Tanousf2caadc2024-01-02 18:34:36 -0800340 'BUILD_SHARED_LIBS': 'OFF',
341 },
342 )
Ed Tanous144983c2024-03-28 00:39:10 -0700343
Ed Tanousf2caadc2024-01-02 18:34:36 -0800344 boost = cmake.subproject('boost', required: true, options: opt)
Ed Tanousf80a87f2024-06-16 12:10:33 -0700345 foreach boost_lib : boost_libs
346 boost_lib_instance = boost.dependency('boost_' + boost_lib).as_system()
347 bmcweb_dependencies += [boost_lib_instance]
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700348 bmcweb_cli_dependencies += [boost_lib_instance]
Ed Tanousf80a87f2024-06-16 12:10:33 -0700349 endforeach
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530350endif
351
Patrick Williams4efe3e02023-04-12 08:05:58 -0500352systemd_system_unit_dir = systemd.get_variable('systemdsystemunitdir')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530353
Ed Tanous92e26be2024-08-21 13:39:14 -0700354bindir = get_option('prefix') + '/' + get_option('bindir')
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700355libexec = get_option('prefix') + '/' + get_option('libexecdir')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530356
Ed Tanousf2caadc2024-01-02 18:34:36 -0800357summary(
358 {
359 'prefix': get_option('prefix'),
360 'bindir': bindir,
361 'systemd unit directory': systemd_system_unit_dir,
362 },
363 section: 'Directories',
364)
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530365
Ed Tanousa529a6a2024-05-29 16:51:37 -0700366subdir('static')
367subdir('redfish-core')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530368
Nan Zhou307386e2022-10-12 20:29:34 +0000369# Config subdirectory
Nan Zhou307386e2022-10-12 20:29:34 +0000370subdir('config')
371bmcweb_dependencies += conf_h_dep
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700372bmcweb_cli_dependencies += conf_h_dep
Nan Zhou307386e2022-10-12 20:29:34 +0000373
Ed Tanous02f1cd92021-10-27 12:09:06 -0700374# Source files
Nan Zhou0ad63df2022-10-17 23:03:21 +0000375fs = import('fs')
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530376
Nan Zhou0ad63df2022-10-17 23:03:21 +0000377srcfiles_bmcweb = files(
Ed Tanous724985f2024-06-05 09:19:06 -0700378 'http/mutual_tls.cpp',
Ed Tanouse60300a2025-02-23 12:31:53 -0800379 'http/routing/sserule.cpp',
Ed Tanousbeb96b02025-02-09 09:22:46 -0800380 'http/routing/websocketrule.cpp',
Ed Tanousb26ff342024-11-22 11:47:08 -0800381 'redfish-core/src/dbus_log_watcher.cpp',
Ed Tanous6c038f22025-01-14 09:46:04 -0800382 'redfish-core/src/error_message_utils.cpp',
Patrick Williams24050912025-02-01 08:38:29 -0500383 'redfish-core/src/error_messages.cpp',
Alexander Hansenb80ba2e2024-11-18 12:24:35 +0100384 'redfish-core/src/event_log.cpp',
Ed Tanous2185dde2024-11-22 11:33:51 -0800385 'redfish-core/src/filesystem_log_watcher.cpp',
Ed Tanous25991f72024-06-13 18:10:25 -0700386 'redfish-core/src/filter_expr_executor.cpp',
Ed Tanousf88b2172022-04-15 13:55:05 -0700387 'redfish-core/src/filter_expr_printer.cpp',
Ed Tanousa8a5bc12024-12-02 15:43:16 -0800388 'redfish-core/src/heartbeat_messages.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800389 'redfish-core/src/redfish.cpp',
390 'redfish-core/src/registries.cpp',
Ed Tanousa8a5bc12024-12-02 15:43:16 -0800391 'redfish-core/src/resource_messages.cpp',
Alexander Hansen02c1e292024-11-15 14:30:40 +0100392 'redfish-core/src/subscription.cpp',
Ed Tanousa8a5bc12024-12-02 15:43:16 -0800393 'redfish-core/src/task_messages.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800394 'redfish-core/src/utils/dbus_utils.cpp',
395 'redfish-core/src/utils/json_utils.cpp',
396 'redfish-core/src/utils/time_utils.cpp',
397 'src/boost_asio.cpp',
398 'src/boost_asio_ssl.cpp',
399 'src/boost_beast.cpp',
400 'src/dbus_singleton.cpp',
Ed Tanousbb1c7d32025-02-09 09:39:19 -0800401 'src/dbus_utility.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800402 'src/json_html_serializer.cpp',
403 'src/ossl_random.cpp',
Ed Tanous724985f2024-06-05 09:19:06 -0700404 'src/ssl_key_handler.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800405 'src/webserver_run.cpp',
Nan Zhou0ad63df2022-10-17 23:03:21 +0000406)
Ed Tanous02f1cd92021-10-27 12:09:06 -0700407
Ed Tanous42bbcd82023-01-07 18:04:28 -0800408bmcweblib = static_library(
Ed Tanousf2caadc2024-01-02 18:34:36 -0800409 'bmcweblib',
410 srcfiles_bmcweb,
411 include_directories: incdir,
412 dependencies: bmcweb_dependencies,
Ed Tanous42bbcd82023-01-07 18:04:28 -0800413)
414
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700415# Generate the bmcwebd daemon
Ed Tanous02f1cd92021-10-27 12:09:06 -0700416executable(
Ed Tanous92e26be2024-08-21 13:39:14 -0700417 'bmcwebd',
418 'src/webserver_main.cpp',
419 include_directories: incdir,
420 dependencies: bmcweb_dependencies,
421 link_with: bmcweblib,
422 link_args: '-Wl,--gc-sections',
423 install: true,
424 install_dir: libexec,
Aushim Nagarkattibd1299b2024-08-12 17:11:04 -0700425)
426
427# Generate the bmcweb CLI application
428executable(
Ed Tanous92e26be2024-08-21 13:39:14 -0700429 'bmcweb',
430 ['src/webserver_cli.cpp', 'src/boost_asio.cpp'],
431 include_directories: incdir_cli,
432 dependencies: bmcweb_cli_dependencies,
433 install: true,
434 install_dir: bindir,
Ed Tanous02f1cd92021-10-27 12:09:06 -0700435)
436
Nan Zhou0ad63df2022-10-17 23:03:21 +0000437srcfiles_unittest = files(
Ed Tanousf2caadc2024-01-02 18:34:36 -0800438 'test/http/crow_getroutes_test.cpp',
439 'test/http/http2_connection_test.cpp',
440 'test/http/http_body_test.cpp',
441 'test/http/http_connection_test.cpp',
442 'test/http/http_response_test.cpp',
443 'test/http/mutual_tls.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800444 'test/http/parsing_test.cpp',
445 'test/http/router_test.cpp',
446 'test/http/server_sent_event_test.cpp',
447 'test/http/utility_test.cpp',
448 'test/http/verb_test.cpp',
449 'test/include/async_resolve_test.cpp',
450 'test/include/credential_pipe_test.cpp',
451 'test/include/dbus_utility_test.cpp',
452 'test/include/google/google_service_root_test.cpp',
453 'test/include/http_utility_test.cpp',
454 'test/include/human_sort_test.cpp',
455 'test/include/ibm/configfile_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800456 'test/include/json_html_serializer.cpp',
457 'test/include/multipart_test.cpp',
458 'test/include/openbmc_dbus_rest_test.cpp',
459 'test/include/ossl_random.cpp',
Malik Akbar Hashemi Rafsanjani4d7b5dd2025-02-26 13:14:30 -0800460 'test/include/sessions_test.cpp',
Ed Tanous099225c2024-03-27 22:03:05 -0700461 'test/include/ssl_key_handler_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800462 'test/include/str_utility_test.cpp',
Alexander Hansen56431b22024-12-03 17:19:19 +0100463 'test/redfish-core/include/dbus_log_watcher_test.cpp',
Alexander Hansen5494e212024-11-18 19:21:57 +0100464 'test/redfish-core/include/event_log_test.cpp',
Ed Tanousd3a48a12024-09-25 08:58:29 -0700465 'test/redfish-core/include/event_matches_filter_test.cpp',
Ed Tanous25991f72024-06-13 18:10:25 -0700466 'test/redfish-core/include/filter_expr_executor_test.cpp',
Ed Tanousf88b2172022-04-15 13:55:05 -0700467 'test/redfish-core/include/filter_expr_parser_test.cpp',
Ed Tanous92e26be2024-08-21 13:39:14 -0700468 'test/redfish-core/include/privileges_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800469 'test/redfish-core/include/redfish_aggregator_test.cpp',
rohitpaic1a75eb2025-01-03 19:13:36 +0530470 'test/redfish-core/include/redfish_oem_routing_test.cpp',
Ed Tanous6e1a52f2024-11-15 19:44:16 -0800471 'test/redfish-core/include/redfish_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800472 'test/redfish-core/include/registries_test.cpp',
Ed Tanous04adfbc2024-12-27 10:55:20 -0800473 'test/redfish-core/include/submit_test_event_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800474 'test/redfish-core/include/utils/dbus_utils.cpp',
Patrick Williams1e4bc6f2025-02-03 14:14:42 -0500475 'test/redfish-core/include/utils/error_code_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800476 'test/redfish-core/include/utils/hex_utils_test.cpp',
477 'test/redfish-core/include/utils/ip_utils_test.cpp',
478 'test/redfish-core/include/utils/json_utils_test.cpp',
479 'test/redfish-core/include/utils/query_param_test.cpp',
Janet Adkins1516c212024-08-14 13:22:41 -0500480 'test/redfish-core/include/utils/sensor_utils_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800481 'test/redfish-core/include/utils/stl_utils_test.cpp',
482 'test/redfish-core/include/utils/time_utils_test.cpp',
483 'test/redfish-core/lib/chassis_test.cpp',
Ed Tanous6e1a52f2024-11-15 19:44:16 -0800484 'test/redfish-core/lib/ethernet_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800485 'test/redfish-core/lib/log_services_dump_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800486 'test/redfish-core/lib/manager_diagnostic_data_test.cpp',
Ed Tanous090ab8e2024-05-18 16:07:23 -0700487 'test/redfish-core/lib/metadata_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800488 'test/redfish-core/lib/power_subsystem_test.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800489 'test/redfish-core/lib/service_root_test.cpp',
490 'test/redfish-core/lib/system_test.cpp',
Ed Tanous8d2f8682024-09-03 17:03:29 -0700491 'test/redfish-core/lib/systems_logservices_postcode.cpp',
Ed Tanousf2caadc2024-01-02 18:34:36 -0800492 'test/redfish-core/lib/thermal_subsystem_test.cpp',
493 'test/redfish-core/lib/update_service_test.cpp',
Nan Zhou0ad63df2022-10-17 23:03:21 +0000494)
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530495
Ed Tanousf2caadc2024-01-02 18:34:36 -0800496if (get_option('tests').allowed())
Ed Tanous77dcace2024-09-07 16:38:05 -0700497 gtest = dependency(
498 'gtest_main',
499 main: true,
500 version: '>=1.15.0',
501 required: true,
502 )
503 gmock = dependency('gmock', required: true)
504 gtestlib = static_library('gtestlib', dependencies: [gtest, gmock])
505 gtestdep = declare_dependency(
506 link_with: gtestlib,
507 dependencies: [
508 gtest.partial_dependency(includes: true),
509 gmock.partial_dependency(includes: true),
510 ],
511 )
Ed Tanous02f1cd92021-10-27 12:09:06 -0700512 # generate the test executable
Nan Zhou0ad63df2022-10-17 23:03:21 +0000513 foreach test_src : srcfiles_unittest
Ed Tanousf2caadc2024-01-02 18:34:36 -0800514 test_bin = executable(
515 fs.stem(test_src),
516 test_src,
517 link_with: bmcweblib,
518 include_directories: incdir,
519 install_dir: bindir,
Ed Tanous77dcace2024-09-07 16:38:05 -0700520 dependencies: bmcweb_dependencies + [gtestdep],
Ed Tanousf2caadc2024-01-02 18:34:36 -0800521 )
Ed Tanous77dcace2024-09-07 16:38:05 -0700522 test(fs.stem(test_src), test_bin, protocol: 'gtest')
Nan Zhou0ad63df2022-10-17 23:03:21 +0000523 endforeach
Manojkiran Edaaf6298d2020-05-27 08:51:32 +0530524endif