blob: 46df4fb15ae54e8399e453cbd84e441b0539cb1d [file] [log] [blame]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -05001# SPDX-License-Identifier: Apache-2.0
2
Patrick Williams57de2512025-02-01 08:37:12 -05003project(
4 'phosphor-debug-collector',
5 'cpp',
6 meson_version: '>=1.1.1',
7 default_options: [
8 'cpp_std=c++23',
9 'warning_level=3',
10 'werror=true',
11 'buildtype=debugoptimized',
12 ],
13 version: '1.0',
14 license: 'Apache-2.0',
15)
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050016
Patrick Williamsabbe1592021-10-01 16:04:19 -050017cpp = meson.get_compiler('cpp')
18
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -050019# list of unit files, the path as input and service name
20# as output
21# eg: unit_file += {'input:'<path>, 'output':<service name>}
22unit_files = []
23
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050024# Checking dependency external library
25
Patrick Williams57de2512025-02-01 08:37:12 -050026libsystemd = dependency('libsystemd', version: '>=221')
George Liu73e0bab2021-06-29 15:57:43 +080027
Patrick Williams02634e52022-03-21 11:16:11 -050028sdbusplus_dep = dependency('sdbusplus')
29sdbusplusplus_prog = find_program('sdbus++')
30sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson')
Marri Devender Rao3ed02c32022-06-28 23:12:14 -050031sdeventplus_dep = dependency('sdeventplus')
Patrick Williams02634e52022-03-21 11:16:11 -050032
33phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces')
34phosphor_logging_dep = dependency('phosphor-logging')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050035
Dhruvaraj Subhashchandran50646c22024-06-19 22:51:50 -050036# nlohmann-json dependency
37nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system')
38
Patrick Williamsabbe1592021-10-01 16:04:19 -050039# Get Cereal dependency.
40cereal_dep = dependency('cereal', required: false)
41has_cereal = cpp.has_header_symbol(
42 'cereal/cereal.hpp',
43 'cereal::specialize',
44 dependencies: cereal_dep,
Patrick Williams57de2512025-02-01 08:37:12 -050045 required: false,
46)
Patrick Williamsabbe1592021-10-01 16:04:19 -050047if not has_cereal
48 cereal_opts = import('cmake').subproject_options()
Patrick Williams57de2512025-02-01 08:37:12 -050049 cereal_opts.add_cmake_defines(
50 {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'},
51 )
Patrick Williamsabbe1592021-10-01 16:04:19 -050052 cereal_proj = import('cmake').subproject(
53 'cereal',
54 options: cereal_opts,
Patrick Williams57de2512025-02-01 08:37:12 -050055 required: false,
56 )
Patrick Williamsabbe1592021-10-01 16:04:19 -050057 assert(cereal_proj.found(), 'cereal is required')
58 cereal_dep = cereal_proj.dependency('cereal')
59endif
60
PriyangaRamasamy01c66462021-02-23 05:46:25 -060061# Disable FORTIFY_SOURCE when compiling with no optimization
Patrick Williams57de2512025-02-01 08:37:12 -050062if (get_option('optimization') == '0')
63 add_project_arguments('-U_FORTIFY_SOURCE', language: ['cpp', 'c'])
64 message('Disabling FORTIFY_SOURCE as optimization is set to 0')
PriyangaRamasamy01c66462021-02-23 05:46:25 -060065endif
66
Ramesh Iyyarbb410df2020-08-03 03:13:04 -050067# Configuration header file(config.h) generation
68
69conf_data = configuration_data()
70
Patrick Williams57de2512025-02-01 08:37:12 -050071conf_data.set_quoted(
72 'DUMP_BUSNAME',
73 get_option('DUMP_BUSNAME'),
74 description: 'The Dbus busname to own',
75)
76conf_data.set_quoted(
77 'DUMP_OBJPATH',
78 get_option('DUMP_OBJPATH'),
79 description: 'The Dump manager Dbus root',
80)
81conf_data.set_quoted(
82 'BMC_DUMP_OBJPATH',
83 get_option('BMC_DUMP_OBJPATH'),
84 description: 'The BMC Dump manager Dbus path',
85)
86conf_data.set_quoted(
87 'CORE_FILE_DIR',
88 get_option('CORE_FILE_DIR'),
89 description: 'Directory where core dumps are placed',
90)
91conf_data.set_quoted(
92 'BMC_DUMP_OBJ_ENTRY',
93 get_option('BMC_DUMP_OBJ_ENTRY'),
94 description: 'The BMC dump entry DBus object path',
95)
96conf_data.set_quoted(
97 'BMC_DUMP_PATH',
98 get_option('BMC_DUMP_PATH'),
99 description: 'Directory where bmc dumps are placed',
100)
101conf_data.set_quoted(
102 'SYSTEMD_PSTORE_PATH',
103 get_option('SYSTEMD_PSTORE_PATH'),
104 description: 'Path to the systemd pstore directory',
105)
106conf_data.set(
107 'BMC_DUMP_MAX_SIZE',
108 get_option('BMC_DUMP_MAX_SIZE'),
109 description: 'Maximum size of one bmc dump in kilo bytes',
110)
111conf_data.set(
112 'BMC_DUMP_MIN_SPACE_REQD',
113 get_option('BMC_DUMP_MIN_SPACE_REQD'),
114 description: 'Minimum space required for one bmc dump in kilo bytes',
115)
116conf_data.set(
117 'BMC_DUMP_TOTAL_SIZE',
118 get_option('BMC_DUMP_TOTAL_SIZE'),
119 description: 'Total size of the dump in kilo bytes',
120)
121conf_data.set_quoted(
122 'OBJ_LOGGING',
123 '/xyz/openbmc_project/logging',
124 description: 'The log manager DBus object path',
125)
126conf_data.set_quoted(
127 'ELOG_ID_PERSIST_PATH',
128 get_option('ELOG_ID_PERSIST_PATH'),
129 description: 'Path of file for storing elog id\'s, which have associated dumps',
130)
131conf_data.set(
132 'CLASS_VERSION',
133 get_option('CLASS_VERSION'),
134 description: 'Class version to register with Cereal',
135)
136conf_data.set(
137 'ERROR_MAP_YAML',
138 get_option('ERROR_MAP_YAML'),
139 description: 'YAML filepath containing error object paths',
140)
141conf_data.set(
142 'JFFS_CORE_FILE_WORKAROUND',
143 get_option('jffs-workaround').allowed(),
144 description: 'Turn on jffs workaround for core file',
145)
146conf_data.set_quoted(
147 'FAULTLOG_DUMP_OBJ_ENTRY',
148 get_option('FAULTLOG_DUMP_OBJ_ENTRY'),
149 description: 'The Fault Log dump entry DBus object path',
150)
151conf_data.set_quoted(
152 'FAULTLOG_DUMP_OBJPATH',
153 get_option('FAULTLOG_DUMP_OBJPATH'),
154 description: 'The Fault Log Dump manager Dbus path',
155)
156conf_data.set_quoted(
157 'FAULTLOG_DUMP_PATH',
158 get_option('FAULTLOG_DUMP_PATH'),
159 description: 'Directory where fault logs are placed',
160)
161conf_data.set(
162 'BMC_DUMP_ROTATE_CONFIG',
163 get_option('dump_rotate_config').allowed(),
164 description: 'Turn on rotate config for bmc dump',
165)
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500166
Lakshmi Yadlapati03414ff2024-07-07 14:37:12 -0500167if cpp.has_header('poll.h')
Patrick Williams57de2512025-02-01 08:37:12 -0500168 add_project_arguments('-DPLDM_HAS_POLL=1', language: 'cpp')
Lakshmi Yadlapati03414ff2024-07-07 14:37:12 -0500169endif
170
Patrick Williams57de2512025-02-01 08:37:12 -0500171configure_file(configuration: conf_data, output: 'config.h')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500172
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500173dump_types_yaml_files = []
174
175# Dump types YAML file
Patrick Williams57de2512025-02-01 08:37:12 -0500176dump_types_yaml_files += {
177 'input': 'example_dump_types.yaml',
178 'output': 'dump_types.yaml',
179}
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500180
181# Copy and combine YAML files
182concatenate_command = 'cat '
183combined_yaml_file = 'combined_dump_types.yaml'
184
185foreach yaml_file : dump_types_yaml_files
Patrick Williams57de2512025-02-01 08:37:12 -0500186 configure_file(
187 input: yaml_file.get('input'),
188 output: yaml_file.get('output'),
189 copy: true,
190 )
191 concatenate_command += meson.project_build_root() + '/' + yaml_file.get(
192 'output',
193 ) + ' '
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500194endforeach
195
Konstantin Aladyshevdf01f8a2024-04-02 17:50:49 +0300196concatenate_command += '> ' + meson.project_build_root() + '/' + combined_yaml_file
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500197run_command('sh', '-c', concatenate_command)
198
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500199python = find_program('python3')
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500200map_gen_file_loc = meson.project_source_root()
201map_gen_file_loc += '/map_gen.py'
202
203dump_types_hpp = custom_target(
Patrick Williams57de2512025-02-01 08:37:12 -0500204 'dump_types.hpp',
205 command: [
206 python,
207 map_gen_file_loc,
208 '-i',
209 meson.project_build_root() + '/' + combined_yaml_file,
210 '-j',
211 get_option('ERROR_MAP_YAML'),
212 '-t',
213 'dump_types.hpp.mako',
214 '-o',
215 'dump_types.hpp',
216 ],
217 depend_files: [
218 'dump_types.hpp.mako',
219 'map_gen.py',
220 meson.project_build_root() + '/' + combined_yaml_file,
221 get_option('ERROR_MAP_YAML'),
222 ],
223 output: 'dump_types.hpp',
224)
Dhruvaraj Subhashchandranc1f5ed62023-07-09 04:31:28 -0500225
226dump_types_cpp = custom_target(
Patrick Williams57de2512025-02-01 08:37:12 -0500227 'dump_types.cpp',
228 command: [
229 python,
230 map_gen_file_loc,
231 '-i',
232 meson.project_build_root() + '/' + combined_yaml_file,
233 '-j',
234 get_option('ERROR_MAP_YAML'),
235 '-t',
236 'dump_types.cpp.mako',
237 '-o',
238 'dump_types.cpp',
239 ],
240 depend_files: [
241 'dump_types.cpp.mako',
242 'map_gen.py',
243 meson.project_build_root() + '/' + combined_yaml_file,
244 get_option('ERROR_MAP_YAML'),
245 ],
246 output: 'dump_types.cpp',
247)
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500248
249phosphor_dump_manager_sources = [
Patrick Williams57de2512025-02-01 08:37:12 -0500250 'dump_entry.cpp',
251 'dump_manager.cpp',
252 'dump_manager_bmc.cpp',
253 'dump_manager_main.cpp',
254 'dump_serialize.cpp',
255 'elog_watch.cpp',
256 dump_types_hpp,
257 dump_types_cpp,
258 'watch.cpp',
259 'bmc_dump_entry.cpp',
260 'dump_utils.cpp',
261 'dump_offload.cpp',
262 'dump_manager_faultlog.cpp',
263 'faultlog_dump_entry.cpp',
264]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500265
266phosphor_dump_manager_dependency = [
Patrick Williams57de2512025-02-01 08:37:12 -0500267 phosphor_dbus_interfaces_dep,
268 sdbusplus_dep,
269 sdeventplus_dep,
270 phosphor_logging_dep,
271 cereal_dep,
272 nlohmann_json_dep,
273]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500274
275phosphor_dump_manager_install = true
276
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600277phosphor_dump_manager_incdir = []
278
Ramesh Iyyar131994b2020-12-03 08:35:36 -0600279# To get host transport based interface to take respective host
280# dump actions. It will contain required sources and dependency
281# list for phosphor_dump_manager.
282subdir('host-transport-extensions')
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500283
Dhruvaraj Subhashchandran8b9b4692020-09-24 11:59:42 -0500284#pick any architecture specific dumps
285subdir('dump-extensions')
286
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500287phosphor_dump_monitor_sources = [
Patrick Williams57de2512025-02-01 08:37:12 -0500288 dump_types_hpp,
289 'core_manager.cpp',
290 'core_manager_main.cpp',
291 'watch.cpp',
292]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500293
294phosphor_dump_monitor_dependency = [
Patrick Williams57de2512025-02-01 08:37:12 -0500295 phosphor_dbus_interfaces_dep,
296 phosphor_logging_dep,
297 sdeventplus_dep,
298]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500299
300phosphor_dump_monitor_install = true
301
Ramesh Iyyar3af5c322020-12-04 00:38:42 -0600302phosphor_dump_monitor_incdir = []
303
George Liuff92ffe2021-02-09 15:01:53 +0800304phosphor_ramoops_monitor_sources = [
Patrick Williams57de2512025-02-01 08:37:12 -0500305 dump_types_hpp,
306 'ramoops_manager.cpp',
307 'ramoops_manager_main.cpp',
308 'watch.cpp',
309]
George Liuff92ffe2021-02-09 15:01:53 +0800310
311phosphor_ramoops_monitor_dependency = [
Patrick Williams57de2512025-02-01 08:37:12 -0500312 phosphor_dbus_interfaces_dep,
313 phosphor_logging_dep,
314 sdeventplus_dep,
315]
George Liuff92ffe2021-02-09 15:01:53 +0800316
317phosphor_ramoops_monitor_install = true
318
319phosphor_ramoops_monitor_incdir = []
320
Patrick Williams57de2512025-02-01 08:37:12 -0500321executables = [
322 [
323 'phosphor-dump-manager',
324 phosphor_dump_manager_sources,
325 phosphor_dump_manager_dependency,
326 phosphor_dump_manager_install,
327 phosphor_dump_manager_incdir,
328 ],
329 [
330 'phosphor-dump-monitor',
331 phosphor_dump_monitor_sources,
332 phosphor_dump_monitor_dependency,
333 phosphor_dump_monitor_install,
334 phosphor_dump_monitor_incdir,
335 ],
336 [
337 'phosphor-ramoops-monitor',
338 phosphor_ramoops_monitor_sources,
339 phosphor_ramoops_monitor_dependency,
340 phosphor_ramoops_monitor_install,
341 phosphor_ramoops_monitor_incdir,
342 ],
343]
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500344
345foreach executable : executables
346 binary = executable(
Patrick Williams57de2512025-02-01 08:37:12 -0500347 executable[0],
348 executable[1],
349 dependencies: executable[2],
350 install: executable[3],
351 include_directories: executable[4],
352 )
Ramesh Iyyarbb410df2020-08-03 03:13:04 -0500353endforeach
Chirag Sharma50427252020-08-11 12:11:38 -0500354
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500355unit_subs = configuration_data()
356unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
Patrick Williams6c84a8c2023-04-12 08:10:41 -0500357systemd_system_unit_dir = dependency('systemd').get_variable(
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500358 'systemdsystemunitdir',
Patrick Williams57de2512025-02-01 08:37:12 -0500359 pkgconfig_define: ['prefix', get_option('prefix')],
360)
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500361foreach u : unit_files
362 configure_file(
363 configuration: unit_subs,
364 input: u.get('input'),
365 install: true,
366 install_dir: systemd_system_unit_dir,
Patrick Williams57de2512025-02-01 08:37:12 -0500367 output: u.get('output'),
Dhruvaraj Subhashchandran9f557362021-05-12 06:28:20 -0500368 )
369endforeach
370
Patrick Williams7cd05282023-11-29 06:44:29 -0600371if get_option('tests').allowed()
Patrick Williams57de2512025-02-01 08:37:12 -0500372 subdir('test')
Chirag Sharma50427252020-08-11 12:11:38 -0500373endif