blob: 98ce6d05c08a2691a49108497687ad48b01c6e62 [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
Patrick Williamsabbe1592021-10-01 16:04:19 -050035# Get Cereal dependency.
36cereal_dep = dependency('cereal', required: false)
37has_cereal = cpp.has_header_symbol(
38 'cereal/cereal.hpp',
39 'cereal::specialize',
40 dependencies: cereal_dep,
41 required: false)
42if not has_cereal
43 cereal_opts = import('cmake').subproject_options()
44 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'})
45 cereal_proj = import('cmake').subproject(
46 'cereal',
47 options: cereal_opts,
48 required: false)
49 assert(cereal_proj.found(), 'cereal is required')
50 cereal_dep = cereal_proj.dependency('cereal')
51endif
52
PriyangaRamasamy01c66462021-02-23 05:46:25 -060053# Disable FORTIFY_SOURCE when compiling with no optimization
54if(get_option('optimization') == '0')
55 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c'])
56 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
57endif
58
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050059# Configuration header file(config.h) generation
60
61conf_data = configuration_data()
62
63conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'),
64 description : 'The Dbus busname to own'
65 )
66conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'),
67 description : 'The Dump manager Dbus root'
68 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050069conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'),
70 description : 'The BMC Dump manager Dbus path'
71 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050072conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'),
73 description : 'Directory where core dumps are placed'
74 )
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -050075conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'),
76 description : 'The BMC dump entry DBus object path'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050077 )
78conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'),
79 description : 'Directory where bmc dumps are placed')
George Liuff92ffe2021-02-09 15:01:53 +080080conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'),
81 description : 'Path to the systemd pstore directory')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050082conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'),
83 description : 'Maximum size of one bmc dump in kilo bytes'
84 )
85conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'),
86 description : 'Minimum space required for one bmc dump in kilo bytes'
87 )
88conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'),
89 description : 'Total size of the dump in kilo bytes'
90 )
91conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging',
92 description : 'The log manager DBus object path'
93 )
94conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'),
95 description : 'Path of file for storing elog id\'s, which have associated dumps'
96 )
97conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'),
98 description : 'Class version to register with Cereal'
99 )
100conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'),
101 description : 'YAML filepath containing error object paths'
102 )
Chirag Sharmae22aca72021-01-18 09:55:29 -0600103conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').enabled(),
104 description : 'Turn on jffs workaround for core file'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500105 )
Claire Weinan919f71c2022-03-01 19:02:07 -0800106conf_data.set_quoted('FAULTLOG_DUMP_OBJ_ENTRY', get_option('FAULTLOG_DUMP_OBJ_ENTRY'),
107 description : 'The Fault Log dump entry DBus object path'
108 )
109conf_data.set_quoted('FAULTLOG_DUMP_OBJPATH', get_option('FAULTLOG_DUMP_OBJPATH'),
110 description : 'The Fault Log Dump manager Dbus path'
111 )
112conf_data.set_quoted('FAULTLOG_DUMP_PATH', get_option('FAULTLOG_DUMP_PATH'),
113 description : 'Directory where fault logs are placed'
114 )
Xie Ningfc69f352022-05-17 16:06:52 +0800115conf_data.set('BMC_DUMP_ROTATE_CONFIG', get_option('dump_rotate_config').enabled(),
116 description : 'Turn on rotate config for bmc dump'
117 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500118
119configure_file(configuration : conf_data,
120 output : 'config.h'
121 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500122
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500123dump_types_yaml_files = []
124
125# Dump types YAML file
126dump_types_yaml_files += {'input': 'example_dump_types.yaml',
127 'output': 'dump_types.yaml'}
128
129# Copy and combine YAML files
130concatenate_command = 'cat '
131combined_yaml_file = 'combined_dump_types.yaml'
132
133foreach yaml_file : dump_types_yaml_files
134 configure_file(input : yaml_file.get('input'),
135 output : yaml_file.get('output'),
136 copy : true)
137 concatenate_command += meson.build_root() + '/' + yaml_file.get('output') + ' '
138endforeach
139
140concatenate_command += '> ' + meson.build_root() + '/' + combined_yaml_file
141run_command('sh', '-c', concatenate_command)
142
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500143python = find_program('python3')
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500144map_gen_file_loc = meson.project_source_root()
145map_gen_file_loc += '/map_gen.py'
146
147dump_types_hpp = custom_target(
148 'dump_types.hpp',
149 command : [
150 python,
151 map_gen_file_loc,
152 '-i',
153 meson.build_root() + '/' + combined_yaml_file,
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500154 '-j',
155 get_option('ERROR_MAP_YAML'),
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500156 '-t',
157 'dump_types.mako.hpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500158 '-o',
159 'dump_types.hpp'
160 ],
161 depend_files : [ 'dump_types.mako.hpp',
162 'map_gen.py',
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500163 meson.build_root() + '/' + combined_yaml_file,
164 get_option('ERROR_MAP_YAML')
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500165 ],
166 output : 'dump_types.hpp'
167 )
168
169dump_types_cpp = custom_target(
170 'dump_types.cpp',
171 command : [
172 python,
173 map_gen_file_loc,
174 '-i',
175 meson.build_root() + '/' + combined_yaml_file,
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500176 '-j',
177 get_option('ERROR_MAP_YAML'),
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500178 '-t',
179 'dump_types.mako.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500180 '-o',
181 'dump_types.cpp'
182 ],
183 depend_files : [ 'dump_types.mako.cpp',
184 'map_gen.py',
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500185 meson.build_root() + '/' + combined_yaml_file,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500186 get_option('ERROR_MAP_YAML')
187 ],
Dhruvaraj Subhashchandranaa0937f2023-07-22 23:50:40 -0500188 output : 'dump_types.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500189 )
190
191phosphor_dump_manager_sources = [
192 'dump_entry.cpp',
193 'dump_manager.cpp',
Dhruvaraj Subhashchandranfef66a92020-09-06 13:10:59 -0500194 'dump_manager_bmc.cpp',
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500195 'dump_manager_main.cpp',
196 'dump_serialize.cpp',
197 'elog_watch.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500198 dump_types_hpp,
199 dump_types_cpp,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500200 'watch.cpp',
201 'bmc_dump_entry.cpp',
202 'dump_utils.cpp',
Claire Weinan919f71c2022-03-01 19:02:07 -0800203 'dump_offload.cpp',
204 'dump_manager_faultlog.cpp',
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500205 'faultlog_dump_entry.cpp'
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500206 ]
207
208phosphor_dump_manager_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800209 phosphor_dbus_interfaces_dep,
210 sdbusplus_dep,
Marri Devender Rao3ed02c32022-06-28 23:12:14 -0500211 sdeventplus_dep,
George Liu73e0bab2021-06-29 15:57:43 +0800212 phosphor_logging_dep,
Patrick Williamsabbe1592021-10-01 16:04:19 -0500213 cereal_dep,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500214 ]
215
216phosphor_dump_manager_install = true
217
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600218phosphor_dump_manager_incdir = []
219
Ramesh Iyyar131994b2020-12-03 08:35:36 -0600220# To get host transport based interface to take respective host
221# dump actions. It will contain required sources and dependency
222# list for phosphor_dump_manager.
223subdir('host-transport-extensions')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500224
Dhruvaraj Subhashchandran8b9b4692020-09-24 11:59:42 -0500225#pick any architecture specific dumps
226subdir('dump-extensions')
227
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500228phosphor_dump_monitor_sources = [
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500229 dump_types_hpp,
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500230 'core_manager.cpp',
231 'core_manager_main.cpp',
232 'watch.cpp'
233 ]
234
235phosphor_dump_monitor_dependency = [
George Liu73e0bab2021-06-29 15:57:43 +0800236 phosphor_dbus_interfaces_dep,
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -0500237 phosphor_logging_dep
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500238 ]
239
240phosphor_dump_monitor_install = true
241
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600242phosphor_dump_monitor_incdir = []
243
George Liuff92ffe2021-02-09 15:01:53 +0800244phosphor_ramoops_monitor_sources = [
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500245 dump_types_hpp,
George Liuff92ffe2021-02-09 15:01:53 +0800246 'ramoops_manager.cpp',
247 'ramoops_manager_main.cpp',
248 'watch.cpp'
249 ]
250
251phosphor_ramoops_monitor_dependency = [
George Liu858fbb22021-07-01 12:25:44 +0800252 phosphor_dbus_interfaces_dep,
Dhruvaraj Subhashchandrand1f670f2023-06-05 22:19:25 -0500253 phosphor_logging_dep
George Liuff92ffe2021-02-09 15:01:53 +0800254 ]
255
256phosphor_ramoops_monitor_install = true
257
258phosphor_ramoops_monitor_incdir = []
259
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500260executables = [[ 'phosphor-dump-manager',
261 phosphor_dump_manager_sources,
262 phosphor_dump_manager_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600263 phosphor_dump_manager_install,
264 phosphor_dump_manager_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500265 ],
266 [ 'phosphor-dump-monitor',
267 phosphor_dump_monitor_sources,
268 phosphor_dump_monitor_dependency,
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600269 phosphor_dump_monitor_install,
270 phosphor_dump_monitor_incdir
George Liuff92ffe2021-02-09 15:01:53 +0800271 ],
272 [ 'phosphor-ramoops-monitor',
273 phosphor_ramoops_monitor_sources,
274 phosphor_ramoops_monitor_dependency,
275 phosphor_ramoops_monitor_install,
276 phosphor_ramoops_monitor_incdir
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500277 ]
278 ]
279
280foreach executable : executables
281 binary = executable(
282 executable[0],
283 executable[1],
284 dependencies: executable[2],
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600285 install : executable[3],
286 include_directories : executable[4]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500287 )
288endforeach
Chirag Sharma50427252020-08-11 12:11:38 -0500289
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500290unit_subs = configuration_data()
291unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500292systemd_system_unit_dir = dependency('systemd').get_variable(
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500293 'systemdsystemunitdir',
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500294 pkgconfig_define: ['prefix', get_option('prefix')])
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500295foreach u : unit_files
296 configure_file(
297 configuration: unit_subs,
298 input: u.get('input'),
299 install: true,
300 install_dir: systemd_system_unit_dir,
301 output: u.get('output')
302 )
303endforeach
304
Chirag Sharma50427252020-08-11 12:11:38 -0500305if get_option('tests').enabled()
306 subdir('test')
307endif