Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 3 | project( |
| 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 Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 16 | |
Patrick Williams | abbe159 | 2021-10-01 16:04:19 -0500 | [diff] [blame] | 17 | cpp = meson.get_compiler('cpp') |
| 18 | |
Dhruvaraj Subhashchandran | 9f55736 | 2021-05-12 06:28:20 -0500 | [diff] [blame] | 19 | # list of unit files, the path as input and service name |
| 20 | # as output |
| 21 | # eg: unit_file += {'input:'<path>, 'output':<service name>} |
| 22 | unit_files = [] |
| 23 | |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 24 | # Checking dependency external library |
| 25 | |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 26 | libsystemd = dependency('libsystemd', version: '>=221') |
George Liu | 73e0bab | 2021-06-29 15:57:43 +0800 | [diff] [blame] | 27 | |
Patrick Williams | 02634e5 | 2022-03-21 11:16:11 -0500 | [diff] [blame] | 28 | sdbusplus_dep = dependency('sdbusplus') |
| 29 | sdbusplusplus_prog = find_program('sdbus++') |
| 30 | sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') |
Marri Devender Rao | 3ed02c3 | 2022-06-28 23:12:14 -0500 | [diff] [blame] | 31 | sdeventplus_dep = dependency('sdeventplus') |
Patrick Williams | 02634e5 | 2022-03-21 11:16:11 -0500 | [diff] [blame] | 32 | |
| 33 | phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') |
| 34 | phosphor_logging_dep = dependency('phosphor-logging') |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 35 | |
Dhruvaraj Subhashchandran | 50646c2 | 2024-06-19 22:51:50 -0500 | [diff] [blame] | 36 | # nlohmann-json dependency |
| 37 | nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') |
| 38 | |
Patrick Williams | abbe159 | 2021-10-01 16:04:19 -0500 | [diff] [blame] | 39 | # Get Cereal dependency. |
| 40 | cereal_dep = dependency('cereal', required: false) |
| 41 | has_cereal = cpp.has_header_symbol( |
| 42 | 'cereal/cereal.hpp', |
| 43 | 'cereal::specialize', |
| 44 | dependencies: cereal_dep, |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 45 | required: false, |
| 46 | ) |
Patrick Williams | abbe159 | 2021-10-01 16:04:19 -0500 | [diff] [blame] | 47 | if not has_cereal |
| 48 | cereal_opts = import('cmake').subproject_options() |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 49 | cereal_opts.add_cmake_defines( |
| 50 | {'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}, |
| 51 | ) |
Patrick Williams | abbe159 | 2021-10-01 16:04:19 -0500 | [diff] [blame] | 52 | cereal_proj = import('cmake').subproject( |
| 53 | 'cereal', |
| 54 | options: cereal_opts, |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 55 | required: false, |
| 56 | ) |
Patrick Williams | abbe159 | 2021-10-01 16:04:19 -0500 | [diff] [blame] | 57 | assert(cereal_proj.found(), 'cereal is required') |
| 58 | cereal_dep = cereal_proj.dependency('cereal') |
| 59 | endif |
| 60 | |
PriyangaRamasamy | 01c6646 | 2021-02-23 05:46:25 -0600 | [diff] [blame] | 61 | # Disable FORTIFY_SOURCE when compiling with no optimization |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 62 | if (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') |
PriyangaRamasamy | 01c6646 | 2021-02-23 05:46:25 -0600 | [diff] [blame] | 65 | endif |
| 66 | |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 67 | # Configuration header file(config.h) generation |
| 68 | |
| 69 | conf_data = configuration_data() |
| 70 | |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 71 | conf_data.set_quoted( |
| 72 | 'DUMP_BUSNAME', |
| 73 | get_option('DUMP_BUSNAME'), |
| 74 | description: 'The Dbus busname to own', |
| 75 | ) |
| 76 | conf_data.set_quoted( |
| 77 | 'DUMP_OBJPATH', |
| 78 | get_option('DUMP_OBJPATH'), |
| 79 | description: 'The Dump manager Dbus root', |
| 80 | ) |
| 81 | conf_data.set_quoted( |
| 82 | 'BMC_DUMP_OBJPATH', |
| 83 | get_option('BMC_DUMP_OBJPATH'), |
| 84 | description: 'The BMC Dump manager Dbus path', |
| 85 | ) |
| 86 | conf_data.set_quoted( |
| 87 | 'CORE_FILE_DIR', |
| 88 | get_option('CORE_FILE_DIR'), |
| 89 | description: 'Directory where core dumps are placed', |
| 90 | ) |
| 91 | conf_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 | ) |
| 96 | conf_data.set_quoted( |
| 97 | 'BMC_DUMP_PATH', |
| 98 | get_option('BMC_DUMP_PATH'), |
| 99 | description: 'Directory where bmc dumps are placed', |
| 100 | ) |
| 101 | conf_data.set_quoted( |
| 102 | 'SYSTEMD_PSTORE_PATH', |
| 103 | get_option('SYSTEMD_PSTORE_PATH'), |
| 104 | description: 'Path to the systemd pstore directory', |
| 105 | ) |
| 106 | conf_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 | ) |
| 111 | conf_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 | ) |
| 116 | conf_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 | ) |
| 121 | conf_data.set_quoted( |
| 122 | 'OBJ_LOGGING', |
| 123 | '/xyz/openbmc_project/logging', |
| 124 | description: 'The log manager DBus object path', |
| 125 | ) |
| 126 | conf_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 | ) |
| 131 | conf_data.set( |
| 132 | 'CLASS_VERSION', |
| 133 | get_option('CLASS_VERSION'), |
| 134 | description: 'Class version to register with Cereal', |
| 135 | ) |
| 136 | conf_data.set( |
| 137 | 'ERROR_MAP_YAML', |
| 138 | get_option('ERROR_MAP_YAML'), |
| 139 | description: 'YAML filepath containing error object paths', |
| 140 | ) |
| 141 | conf_data.set( |
| 142 | 'JFFS_CORE_FILE_WORKAROUND', |
| 143 | get_option('jffs-workaround').allowed(), |
| 144 | description: 'Turn on jffs workaround for core file', |
| 145 | ) |
| 146 | conf_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 | ) |
| 151 | conf_data.set_quoted( |
| 152 | 'FAULTLOG_DUMP_OBJPATH', |
| 153 | get_option('FAULTLOG_DUMP_OBJPATH'), |
| 154 | description: 'The Fault Log Dump manager Dbus path', |
| 155 | ) |
| 156 | conf_data.set_quoted( |
| 157 | 'FAULTLOG_DUMP_PATH', |
| 158 | get_option('FAULTLOG_DUMP_PATH'), |
| 159 | description: 'Directory where fault logs are placed', |
| 160 | ) |
| 161 | conf_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 Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 166 | |
Lakshmi Yadlapati | 03414ff | 2024-07-07 14:37:12 -0500 | [diff] [blame] | 167 | if cpp.has_header('poll.h') |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 168 | add_project_arguments('-DPLDM_HAS_POLL=1', language: 'cpp') |
Lakshmi Yadlapati | 03414ff | 2024-07-07 14:37:12 -0500 | [diff] [blame] | 169 | endif |
| 170 | |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 171 | configure_file(configuration: conf_data, output: 'config.h') |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 172 | |
Dhruvaraj Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 173 | dump_types_yaml_files = [] |
| 174 | |
| 175 | # Dump types YAML file |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 176 | dump_types_yaml_files += { |
| 177 | 'input': 'example_dump_types.yaml', |
| 178 | 'output': 'dump_types.yaml', |
| 179 | } |
Dhruvaraj Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 180 | |
| 181 | # Copy and combine YAML files |
| 182 | concatenate_command = 'cat ' |
| 183 | combined_yaml_file = 'combined_dump_types.yaml' |
| 184 | |
| 185 | foreach yaml_file : dump_types_yaml_files |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 186 | 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 Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 194 | endforeach |
| 195 | |
Konstantin Aladyshev | df01f8a | 2024-04-02 17:50:49 +0300 | [diff] [blame] | 196 | concatenate_command += '> ' + meson.project_build_root() + '/' + combined_yaml_file |
Dhruvaraj Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 197 | run_command('sh', '-c', concatenate_command) |
| 198 | |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 199 | python = find_program('python3') |
Dhruvaraj Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 200 | map_gen_file_loc = meson.project_source_root() |
| 201 | map_gen_file_loc += '/map_gen.py' |
| 202 | |
| 203 | dump_types_hpp = custom_target( |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 204 | '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 Subhashchandran | c1f5ed6 | 2023-07-09 04:31:28 -0500 | [diff] [blame] | 225 | |
| 226 | dump_types_cpp = custom_target( |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 227 | '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 Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 248 | |
| 249 | phosphor_dump_manager_sources = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 250 | '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 Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 265 | |
| 266 | phosphor_dump_manager_dependency = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 267 | phosphor_dbus_interfaces_dep, |
| 268 | sdbusplus_dep, |
| 269 | sdeventplus_dep, |
| 270 | phosphor_logging_dep, |
| 271 | cereal_dep, |
| 272 | nlohmann_json_dep, |
| 273 | ] |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 274 | |
| 275 | phosphor_dump_manager_install = true |
| 276 | |
Ramesh Iyyar | 3af5c32 | 2020-12-04 00:38:42 -0600 | [diff] [blame] | 277 | phosphor_dump_manager_incdir = [] |
| 278 | |
Ramesh Iyyar | 131994b | 2020-12-03 08:35:36 -0600 | [diff] [blame] | 279 | # 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. |
| 282 | subdir('host-transport-extensions') |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 283 | |
Dhruvaraj Subhashchandran | 8b9b469 | 2020-09-24 11:59:42 -0500 | [diff] [blame] | 284 | #pick any architecture specific dumps |
| 285 | subdir('dump-extensions') |
| 286 | |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 287 | phosphor_dump_monitor_sources = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 288 | dump_types_hpp, |
| 289 | 'core_manager.cpp', |
| 290 | 'core_manager_main.cpp', |
| 291 | 'watch.cpp', |
| 292 | ] |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 293 | |
| 294 | phosphor_dump_monitor_dependency = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 295 | phosphor_dbus_interfaces_dep, |
| 296 | phosphor_logging_dep, |
| 297 | sdeventplus_dep, |
| 298 | ] |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 299 | |
| 300 | phosphor_dump_monitor_install = true |
| 301 | |
Ramesh Iyyar | 3af5c32 | 2020-12-04 00:38:42 -0600 | [diff] [blame] | 302 | phosphor_dump_monitor_incdir = [] |
| 303 | |
George Liu | ff92ffe | 2021-02-09 15:01:53 +0800 | [diff] [blame] | 304 | phosphor_ramoops_monitor_sources = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 305 | dump_types_hpp, |
| 306 | 'ramoops_manager.cpp', |
| 307 | 'ramoops_manager_main.cpp', |
| 308 | 'watch.cpp', |
| 309 | ] |
George Liu | ff92ffe | 2021-02-09 15:01:53 +0800 | [diff] [blame] | 310 | |
| 311 | phosphor_ramoops_monitor_dependency = [ |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 312 | phosphor_dbus_interfaces_dep, |
| 313 | phosphor_logging_dep, |
| 314 | sdeventplus_dep, |
| 315 | ] |
George Liu | ff92ffe | 2021-02-09 15:01:53 +0800 | [diff] [blame] | 316 | |
| 317 | phosphor_ramoops_monitor_install = true |
| 318 | |
| 319 | phosphor_ramoops_monitor_incdir = [] |
| 320 | |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 321 | executables = [ |
| 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 Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 344 | |
| 345 | foreach executable : executables |
| 346 | binary = executable( |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 347 | executable[0], |
| 348 | executable[1], |
| 349 | dependencies: executable[2], |
| 350 | install: executable[3], |
| 351 | include_directories: executable[4], |
| 352 | ) |
Ramesh Iyyar | bb410df | 2020-08-03 03:13:04 -0500 | [diff] [blame] | 353 | endforeach |
Chirag Sharma | 5042725 | 2020-08-11 12:11:38 -0500 | [diff] [blame] | 354 | |
Dhruvaraj Subhashchandran | 9f55736 | 2021-05-12 06:28:20 -0500 | [diff] [blame] | 355 | unit_subs = configuration_data() |
| 356 | unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) |
Patrick Williams | 6c84a8c | 2023-04-12 08:10:41 -0500 | [diff] [blame] | 357 | systemd_system_unit_dir = dependency('systemd').get_variable( |
Dhruvaraj Subhashchandran | 9f55736 | 2021-05-12 06:28:20 -0500 | [diff] [blame] | 358 | 'systemdsystemunitdir', |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 359 | pkgconfig_define: ['prefix', get_option('prefix')], |
| 360 | ) |
Dhruvaraj Subhashchandran | 9f55736 | 2021-05-12 06:28:20 -0500 | [diff] [blame] | 361 | foreach 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 Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 367 | output: u.get('output'), |
Dhruvaraj Subhashchandran | 9f55736 | 2021-05-12 06:28:20 -0500 | [diff] [blame] | 368 | ) |
| 369 | endforeach |
| 370 | |
Patrick Williams | 7cd0528 | 2023-11-29 06:44:29 -0600 | [diff] [blame] | 371 | if get_option('tests').allowed() |
Patrick Williams | 57de251 | 2025-02-01 08:37:12 -0500 | [diff] [blame^] | 372 | subdir('test') |
Chirag Sharma | 5042725 | 2020-08-11 12:11:38 -0500 | [diff] [blame] | 373 | endif |