1# SPDX-License-Identifier: Apache-2.0 2 3project('phosphor-debug-collector', 4 'cpp', 5 meson_version: '>=1.1.1', 6 default_options: [ 7 'cpp_std=c++23', 8 'warning_level=3', 9 'werror=true', 10 'buildtype=debugoptimized' 11 ], 12 version: '1.0', 13 license: 'Apache-2.0' 14 ) 15 16cpp = meson.get_compiler('cpp') 17 18# 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 23# Checking dependency external library 24 25libsystemd = dependency('libsystemd', version : '>=221') 26 27sdbusplus_dep = dependency('sdbusplus') 28sdbusplusplus_prog = find_program('sdbus++') 29sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') 30sdeventplus_dep = dependency('sdeventplus') 31 32phosphor_dbus_interfaces_dep = dependency('phosphor-dbus-interfaces') 33phosphor_logging_dep = dependency('phosphor-logging') 34 35# 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 53# 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 59# 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 ) 69conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'), 70 description : 'The BMC Dump manager Dbus path' 71 ) 72conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'), 73 description : 'Directory where core dumps are placed' 74 ) 75conf_data.set_quoted('OBJ_INTERNAL', get_option('OBJ_INTERNAL'), 76 description : 'Internal Dump manager Dbus object path' 77 ) 78conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'), 79 description : 'The BMC dump entry DBus object path' 80 ) 81conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'), 82 description : 'Directory where bmc dumps are placed') 83conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'), 84 description : 'Path to the systemd pstore directory') 85conf_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 ) 106conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').enabled(), 107 description : 'Turn on jffs workaround for core file' 108 ) 109conf_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 ) 118conf_data.set('BMC_DUMP_ROTATE_CONFIG', get_option('dump_rotate_config').enabled(), 119 description : 'Turn on rotate config for bmc dump' 120 ) 121 122configure_file(configuration : conf_data, 123 output : 'config.h' 124 ) 125subdir('xyz/openbmc_project/Dump/Internal/Create') 126 127dump_types_yaml_files = [] 128 129# Dump types YAML file 130dump_types_yaml_files += {'input': 'example_dump_types.yaml', 131 'output': 'dump_types.yaml'} 132 133# Copy and combine YAML files 134concatenate_command = 'cat ' 135combined_yaml_file = 'combined_dump_types.yaml' 136 137foreach yaml_file : dump_types_yaml_files 138 configure_file(input : yaml_file.get('input'), 139 output : yaml_file.get('output'), 140 copy : true) 141 concatenate_command += meson.build_root() + '/' + yaml_file.get('output') + ' ' 142endforeach 143 144concatenate_command += '> ' + meson.build_root() + '/' + combined_yaml_file 145run_command('sh', '-c', concatenate_command) 146 147python = find_program('python3') 148map_gen_file_loc = meson.project_source_root() 149map_gen_file_loc += '/map_gen.py' 150 151dump_types_hpp = custom_target( 152 'dump_types.hpp', 153 command : [ 154 python, 155 map_gen_file_loc, 156 '-i', 157 meson.build_root() + '/' + combined_yaml_file, 158 '-t', 159 'dump_types.mako.hpp', 160 '-v', 161 'DUMP_TYPE_TABLE', 162 '-o', 163 'dump_types.hpp' 164 ], 165 depend_files : [ 'dump_types.mako.hpp', 166 'map_gen.py', 167 meson.build_root() + '/' + combined_yaml_file 168 ], 169 output : 'dump_types.hpp' 170 ) 171 172dump_types_cpp = custom_target( 173 'dump_types.cpp', 174 command : [ 175 python, 176 map_gen_file_loc, 177 '-i', 178 meson.build_root() + '/' + combined_yaml_file, 179 '-t', 180 'dump_types.mako.cpp', 181 '-v', 182 'DUMP_TYPE_TABLE', 183 '-o', 184 'dump_types.cpp' 185 ], 186 depend_files : [ 'dump_types.mako.cpp', 187 'map_gen.py', 188 meson.build_root() + '/' + combined_yaml_file 189 ], 190 output : 'dump_types.cpp' 191 ) 192 193errors_map_cpp = custom_target( 194 'errors_map.cpp', 195 command : [ 196 python, 197 map_gen_file_loc, 198 '-i', 199 get_option('ERROR_MAP_YAML'), 200 '-t', 201 'errors_map.mako.cpp', 202 '-v', 203 'errDict', 204 '-o', 205 'errors_map.cpp' 206 ], 207 depend_files : [ 'errors_map.mako.cpp', 208 'map_gen.py', 209 get_option('ERROR_MAP_YAML') 210 ], 211 output : 'errors_map.cpp' 212 ) 213 214phosphor_dump_manager_sources = [ 215 'dump_entry.cpp', 216 'dump_manager.cpp', 217 'dump_manager_bmc.cpp', 218 'dump_manager_main.cpp', 219 'dump_serialize.cpp', 220 'elog_watch.cpp', 221 errors_map_cpp, 222 common_hpp, 223 server_hpp, 224 server_cpp, 225 dump_types_hpp, 226 dump_types_cpp, 227 'watch.cpp', 228 'bmc_dump_entry.cpp', 229 'dump_utils.cpp', 230 'dump_offload.cpp', 231 'dump_manager_faultlog.cpp', 232 'faultlog_dump_entry.cpp' 233 ] 234 235phosphor_dump_manager_dependency = [ 236 phosphor_dbus_interfaces_dep, 237 sdbusplus_dep, 238 sdeventplus_dep, 239 phosphor_logging_dep, 240 cereal_dep, 241 ] 242 243phosphor_dump_manager_install = true 244 245phosphor_dump_manager_incdir = [] 246 247# To get host transport based interface to take respective host 248# dump actions. It will contain required sources and dependency 249# list for phosphor_dump_manager. 250subdir('host-transport-extensions') 251 252#pick any architecture specific dumps 253subdir('dump-extensions') 254 255phosphor_dump_monitor_sources = [ 256 dump_types_hpp, 257 'core_manager.cpp', 258 'core_manager_main.cpp', 259 'watch.cpp' 260 ] 261 262phosphor_dump_monitor_dependency = [ 263 phosphor_dbus_interfaces_dep, 264 phosphor_logging_dep 265 ] 266 267phosphor_dump_monitor_install = true 268 269phosphor_dump_monitor_incdir = [] 270 271phosphor_ramoops_monitor_sources = [ 272 dump_types_hpp, 273 'ramoops_manager.cpp', 274 'ramoops_manager_main.cpp', 275 'watch.cpp' 276 ] 277 278phosphor_ramoops_monitor_dependency = [ 279 phosphor_dbus_interfaces_dep, 280 phosphor_logging_dep 281 ] 282 283phosphor_ramoops_monitor_install = true 284 285phosphor_ramoops_monitor_incdir = [] 286 287executables = [[ 'phosphor-dump-manager', 288 phosphor_dump_manager_sources, 289 phosphor_dump_manager_dependency, 290 phosphor_dump_manager_install, 291 phosphor_dump_manager_incdir 292 ], 293 [ 'phosphor-dump-monitor', 294 phosphor_dump_monitor_sources, 295 phosphor_dump_monitor_dependency, 296 phosphor_dump_monitor_install, 297 phosphor_dump_monitor_incdir 298 ], 299 [ 'phosphor-ramoops-monitor', 300 phosphor_ramoops_monitor_sources, 301 phosphor_ramoops_monitor_dependency, 302 phosphor_ramoops_monitor_install, 303 phosphor_ramoops_monitor_incdir 304 ] 305 ] 306 307foreach executable : executables 308 binary = executable( 309 executable[0], 310 executable[1], 311 dependencies: executable[2], 312 install : executable[3], 313 include_directories : executable[4] 314 ) 315endforeach 316 317unit_subs = configuration_data() 318unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 319systemd_system_unit_dir = dependency('systemd').get_variable( 320 'systemdsystemunitdir', 321 pkgconfig_define: ['prefix', get_option('prefix')]) 322foreach u : unit_files 323 configure_file( 324 configuration: unit_subs, 325 input: u.get('input'), 326 install: true, 327 install_dir: systemd_system_unit_dir, 328 output: u.get('output') 329 ) 330endforeach 331 332if get_option('tests').enabled() 333 subdir('test') 334endif 335