blob: 02075205887701b0e709e1811084ab52e3ee80bf [file] [log] [blame]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05001# SPDX-License-Identifier: Apache-2.0
2
3project('phosphor-debug-collector',
4 'cpp',
Patrick Williamsdeed9592023-07-12 11:15:33 -05005 meson_version: '>=1.1.1',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05006 default_options: [
Patrick Williamsdeed9592023-07-12 11:15:33 -05007 'cpp_std=c++23',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05008 'warning_level=3',
PriyangaRamasamy01c66462021-02-23 05:46:25 -06009 'werror=true',
10 'buildtype=debugoptimized'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050011 ],
12 version: '1.0',
13 license: 'Apache-2.0'
14 )
15
Patrick Williamsabbe1592021-10-01 16:04:19 -050016cpp = meson.get_compiler('cpp')
17
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -050018# list of unit files, the path as input and service name
19# as output
20# eg: unit_file += {'input:'<path>, 'output':<service name>}
21unit_files = []
22
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050023# Checking dependency external library
24
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050025libsystemd = dependency('libsystemd', version : '>=221')
George Liu73e0bab2021-06-29 15:57:43 +080026
Patrick Williams02634e52022-03-21 11:16:11 -050027sdbusplus_dep = dependency('sdbusplus')
28sdbusplusplus_prog = find_program('sdbus++')
29sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Marri Devender Rao3ed02c32022-06-28 23:12:14 -050030sdeventplus_dep = dependency('sdeventplus')
Patrick Williams02634e52022-03-21 11:16:11 -050031
32phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
33phosphor_logging_dep = dependency('phosphor-logging')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050034
Dhruvaraj Subhashchandran50646c22024-06-19 22:51:50 -050035# nlohmann-json dependency
36nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
37
Patrick Williamsabbe1592021-10-01 16:04:19 -050038# Get Cereal dependency.
39cereal_dep = dependency('cereal', required: false)
40has_cereal = cpp.has_header_symbol(
41 'cereal/cereal.hpp',
42 'cereal::specialize',
43 dependencies: cereal_dep,
44 required: false)
45if not has_cereal
46 cereal_opts = import('cmake').subproject_options()
Konstantin Aladyshev71a20da2024-04-02 17:42:46 +030047 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'})
Patrick Williamsabbe1592021-10-01 16:04:19 -050048 cereal_proj = import('cmake').subproject(
49 'cereal',
50 options: cereal_opts,
51 required: false)
52 assert(cereal_proj.found(), 'cereal is required')
53 cereal_dep = cereal_proj.dependency('cereal')
54endif
55
PriyangaRamasamy01c66462021-02-23 05:46:25 -060056# Disable FORTIFY_SOURCE when compiling with no optimization
57if(get_option('optimization') == '0')
58 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
59 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
60endif
61
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050062# Configuration header file(config.h) generation
63
64conf_data = configuration_data()
65
66conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'),
67 description : 'The Dbus busname to own'
68 )
69conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'),
70 description : 'The Dump manager Dbus root'
71 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050072conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'),
73 description : 'The BMC Dump manager Dbus path'
74 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050075conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'),
76 description : 'Directory where core dumps are placed'
77 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050078conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'),
79 description : 'The BMC dump entry DBus object path'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050080 )
81conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'),
82 description : 'Directory where bmc dumps are placed')
George Liuff92ffe2021-02-09 15:01:53 +080083conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'),
84 description : 'Path to the systemd pstore directory')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050085conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'),
86 description : 'Maximum size of one bmc dump in kilo bytes'
87 )
88conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'),
89 description : 'Minimum space required for one bmc dump in kilo bytes'
90 )
91conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'),
92 description : 'Total size of the dump in kilo bytes'
93 )
94conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging',
95 description : 'The log manager DBus object path'
96 )
97conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'),
98 description : 'Path of file for storing elog id\'s, which have associated dumps'
99 )
100conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'),
101 description : 'Class version to register with Cereal'
102 )
103conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'),
104 description : 'YAML filepath containing error object paths'
105 )
Patrick Williams7cd05282023-11-29 06:44:29 -0600106conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').allowed(),
Chirag Sharmae22aca72021-01-18 09:55:29 -0600107 description : 'Turn on jffs workaround for core file'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500108 )
Claire Weinan919f71c2022-03-01 19:02:07 -0800109conf_data.set_quoted('FAULTLOG_DUMP_OBJ_ENTRY', get_option('FAULTLOG_DUMP_OBJ_ENTRY'),
110 description : 'The Fault Log dump entry DBus object path'
111 )
112conf_data.set_quoted('FAULTLOG_DUMP_OBJPATH', get_option('FAULTLOG_DUMP_OBJPATH'),
113 description : 'The Fault Log Dump manager Dbus path'
114 )
115conf_data.set_quoted('FAULTLOG_DUMP_PATH', get_option('FAULTLOG_DUMP_PATH'),
116 description : 'Directory where fault logs are placed'
117 )
Patrick Williams7cd05282023-11-29 06:44:29 -0600118conf_data.set('BMC_DUMP_ROTATE_CONFIG', get_option('dump_rotate_config').allowed(),
Xie Ningfc69f352022-05-17 16:06:52 +0800119 description : 'Turn on rotate config for bmc dump'
120 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500121
Lakshmi Yadlapati03414ff2024-07-07 14:37:12 -0500122if cpp.has_header('poll.h')
123 add_project_arguments('-DPLDM_HAS_POLL=1', language: 'cpp')
124endif
125
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500126configure_file(configuration : conf_data,
127 output : 'config.h'
128 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500129
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500130dump_types_yaml_files = []
131
132# Dump types YAML file
133dump_types_yaml_files += {'input': 'example_dump_types.yaml',
134 'output': 'dump_types.yaml'}
135
136# Copy and combine YAML files
137concatenate_command = 'cat '
138combined_yaml_file = 'combined_dump_types.yaml'
139
140foreach yaml_file : dump_types_yaml_files
141 configure_file(input : yaml_file.get('input'),
142 output : yaml_file.get('output'),
143 copy : true)
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300144 concatenate_command += meson.project_build_root() + '/' + yaml_file.get('output') + ' '
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500145endforeach
146
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300147concatenate_command += '> ' + meson.project_build_root() + '/' + combined_yaml_file
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500148run_command('sh', '-c', concatenate_command)
149
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500150python = find_program('python3')
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500151map_gen_file_loc = meson.project_source_root()
152map_gen_file_loc += '/map_gen.py'
153
154dump_types_hpp = custom_target(
155 'dump_types.hpp',
156 command : [
157 python,
158 map_gen_file_loc,
159 '-i',
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300160 meson.project_build_root() + '/' + combined_yaml_file,
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500161 '-j',
162 get_option('ERROR_MAP_YAML'),
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500163 '-t',
164 'dump_types.mako.hpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500165 '-o',
166 'dump_types.hpp'
167 ],
168 depend_files : [ 'dump_types.mako.hpp',
169 'map_gen.py',
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300170 meson.project_build_root() + '/' + combined_yaml_file,
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500171 get_option('ERROR_MAP_YAML')
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500172 ],
173 output : 'dump_types.hpp'
174 )
175
176dump_types_cpp = custom_target(
177 'dump_types.cpp',
178 command : [
179 python,
180 map_gen_file_loc,
181 '-i',
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300182 meson.project_build_root() + '/' + combined_yaml_file,
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500183 '-j',
184 get_option('ERROR_MAP_YAML'),
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500185 '-t',
186 'dump_types.mako.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500187 '-o',
188 'dump_types.cpp'
189 ],
190 depend_files : [ 'dump_types.mako.cpp',
191 'map_gen.py',
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300192 meson.project_build_root() + '/' + combined_yaml_file,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500193 get_option('ERROR_MAP_YAML')
194 ],
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500195 output : 'dump_types.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500196 )
197
198phosphor_dump_manager_sources = [
199 'dump_entry.cpp',
200 'dump_manager.cpp',
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -0500201 'dump_manager_bmc.cpp',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500202 'dump_manager_main.cpp',
203 'dump_serialize.cpp',
204 'elog_watch.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500205 dump_types_hpp,
206 dump_types_cpp,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500207 'watch.cpp',
208 'bmc_dump_entry.cpp',
209 'dump_utils.cpp',
Claire Weinan919f71c2022-03-01 19:02:07 -0800210 'dump_offload.cpp',
211 'dump_manager_faultlog.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500212 'faultlog_dump_entry.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500213 ]
214
215phosphor_dump_manager_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800216 phosphor_dbus_interfaces_dep,
217 sdbusplus_dep,
Marri Devender Rao3ed02c32022-06-28 23:12:14 -0500218 sdeventplus_dep,
George Liu73e0bab2021-06-29 15:57:43 +0800219 phosphor_logging_dep,
Patrick Williamsabbe1592021-10-01 16:04:19 -0500220 cereal_dep,
Dhruvaraj Subhashchandran50646c22024-06-19 22:51:50 -0500221 nlohmann_json_dep,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500222 ]
223
224phosphor_dump_manager_install = true
225
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600226phosphor_dump_manager_incdir = []
227
Ramesh Iyyar131994b2020-12-03 08:35:36 -0600228# To get host transport based interface to take respective host
229# dump actions. It will contain required sources and dependency
230# list for phosphor_dump_manager.
231subdir('host-transport-extensions')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500232
Dhruvaraj Subhashchandran8b9b4692020-09-24 11:59:42 -0500233#pick any architecture specific dumps
234subdir('dump-extensions')
235
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500236phosphor_dump_monitor_sources = [
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500237 dump_types_hpp,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500238 'core_manager.cpp',
239 'core_manager_main.cpp',
240 'watch.cpp'
241 ]
242
243phosphor_dump_monitor_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800244 phosphor_dbus_interfaces_dep,
Patrick Williams07222712024-02-26 10:37:10 -0600245 phosphor_logging_dep,
246 sdeventplus_dep,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500247 ]
248
249phosphor_dump_monitor_install = true
250
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600251phosphor_dump_monitor_incdir = []
252
George Liuff92ffe2021-02-09 15:01:53 +0800253phosphor_ramoops_monitor_sources = [
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500254 dump_types_hpp,
George Liuff92ffe2021-02-09 15:01:53 +0800255 'ramoops_manager.cpp',
256 'ramoops_manager_main.cpp',
257 'watch.cpp'
258 ]
259
260phosphor_ramoops_monitor_dependency = [
George Liu858fbb22021-07-01 12:25:44 +0800261 phosphor_dbus_interfaces_dep,
Patrick Williams07222712024-02-26 10:37:10 -0600262 phosphor_logging_dep,
263 sdeventplus_dep,
George Liuff92ffe2021-02-09 15:01:53 +0800264 ]
265
266phosphor_ramoops_monitor_install = true
267
268phosphor_ramoops_monitor_incdir = []
269
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500270executables = [[ 'phosphor-dump-manager',
271 phosphor_dump_manager_sources,
272 phosphor_dump_manager_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600273 phosphor_dump_manager_install,
274 phosphor_dump_manager_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500275 ],
276 [ 'phosphor-dump-monitor',
277 phosphor_dump_monitor_sources,
278 phosphor_dump_monitor_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600279 phosphor_dump_monitor_install,
280 phosphor_dump_monitor_incdir
George Liuff92ffe2021-02-09 15:01:53 +0800281 ],
282 [ 'phosphor-ramoops-monitor',
283 phosphor_ramoops_monitor_sources,
284 phosphor_ramoops_monitor_dependency,
285 phosphor_ramoops_monitor_install,
286 phosphor_ramoops_monitor_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500287 ]
288 ]
289
290foreach executable : executables
291 binary = executable(
292 executable[0],
293 executable[1],
294 dependencies: executable[2],
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600295 install : executable[3],
296 include_directories : executable[4]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500297 )
298endforeach
Chirag Sharma50427252020-08-11 12:11:38 -0500299
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500300unit_subs = configuration_data()
301unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500302systemd_system_unit_dir = dependency('systemd').get_variable(
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500303 'systemdsystemunitdir',
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500304 pkgconfig_define: ['prefix', get_option('prefix')])
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500305foreach u : unit_files
306 configure_file(
307 configuration: unit_subs,
308 input: u.get('input'),
309 install: true,
310 install_dir: systemd_system_unit_dir,
311 output: u.get('output')
312 )
313endforeach
314
Patrick Williams7cd05282023-11-29 06:44:29 -0600315if get_option('tests').allowed()
Chirag Sharma50427252020-08-11 12:11:38 -0500316 subdir('test')
317endif