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# nlohmann-json dependency 36nlohmann_json_dep = dependency('nlohmann_json', include_type: 'system') 37 38# 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() 47 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) 48 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 56# 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 62# 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 ) 72conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'), 73 description : 'The BMC Dump manager Dbus path' 74 ) 75conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'), 76 description : 'Directory where core dumps are placed' 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').allowed(), 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').allowed(), 119 description : 'Turn on rotate config for bmc dump' 120 ) 121 122if cpp.has_header('poll.h') 123 add_project_arguments('-DPLDM_HAS_POLL=1', language: 'cpp') 124endif 125 126configure_file(configuration : conf_data, 127 output : 'config.h' 128 ) 129 130dump_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) 144 concatenate_command += meson.project_build_root() + '/' + yaml_file.get('output') + ' ' 145endforeach 146 147concatenate_command += '> ' + meson.project_build_root() + '/' + combined_yaml_file 148run_command('sh', '-c', concatenate_command) 149 150python = find_program('python3') 151map_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', 160 meson.project_build_root() + '/' + combined_yaml_file, 161 '-j', 162 get_option('ERROR_MAP_YAML'), 163 '-t', 164 'dump_types.mako.hpp', 165 '-o', 166 'dump_types.hpp' 167 ], 168 depend_files : [ 'dump_types.mako.hpp', 169 'map_gen.py', 170 meson.project_build_root() + '/' + combined_yaml_file, 171 get_option('ERROR_MAP_YAML') 172 ], 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', 182 meson.project_build_root() + '/' + combined_yaml_file, 183 '-j', 184 get_option('ERROR_MAP_YAML'), 185 '-t', 186 'dump_types.mako.cpp', 187 '-o', 188 'dump_types.cpp' 189 ], 190 depend_files : [ 'dump_types.mako.cpp', 191 'map_gen.py', 192 meson.project_build_root() + '/' + combined_yaml_file, 193 get_option('ERROR_MAP_YAML') 194 ], 195 output : 'dump_types.cpp' 196 ) 197 198phosphor_dump_manager_sources = [ 199 'dump_entry.cpp', 200 'dump_manager.cpp', 201 'dump_manager_bmc.cpp', 202 'dump_manager_main.cpp', 203 'dump_serialize.cpp', 204 'elog_watch.cpp', 205 dump_types_hpp, 206 dump_types_cpp, 207 'watch.cpp', 208 'bmc_dump_entry.cpp', 209 'dump_utils.cpp', 210 'dump_offload.cpp', 211 'dump_manager_faultlog.cpp', 212 'faultlog_dump_entry.cpp' 213 ] 214 215phosphor_dump_manager_dependency = [ 216 phosphor_dbus_interfaces_dep, 217 sdbusplus_dep, 218 sdeventplus_dep, 219 phosphor_logging_dep, 220 cereal_dep, 221 nlohmann_json_dep, 222 ] 223 224phosphor_dump_manager_install = true 225 226phosphor_dump_manager_incdir = [] 227 228# 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') 232 233#pick any architecture specific dumps 234subdir('dump-extensions') 235 236phosphor_dump_monitor_sources = [ 237 dump_types_hpp, 238 'core_manager.cpp', 239 'core_manager_main.cpp', 240 'watch.cpp' 241 ] 242 243phosphor_dump_monitor_dependency = [ 244 phosphor_dbus_interfaces_dep, 245 phosphor_logging_dep, 246 sdeventplus_dep, 247 ] 248 249phosphor_dump_monitor_install = true 250 251phosphor_dump_monitor_incdir = [] 252 253phosphor_ramoops_monitor_sources = [ 254 dump_types_hpp, 255 'ramoops_manager.cpp', 256 'ramoops_manager_main.cpp', 257 'watch.cpp' 258 ] 259 260phosphor_ramoops_monitor_dependency = [ 261 phosphor_dbus_interfaces_dep, 262 phosphor_logging_dep, 263 sdeventplus_dep, 264 ] 265 266phosphor_ramoops_monitor_install = true 267 268phosphor_ramoops_monitor_incdir = [] 269 270executables = [[ 'phosphor-dump-manager', 271 phosphor_dump_manager_sources, 272 phosphor_dump_manager_dependency, 273 phosphor_dump_manager_install, 274 phosphor_dump_manager_incdir 275 ], 276 [ 'phosphor-dump-monitor', 277 phosphor_dump_monitor_sources, 278 phosphor_dump_monitor_dependency, 279 phosphor_dump_monitor_install, 280 phosphor_dump_monitor_incdir 281 ], 282 [ 'phosphor-ramoops-monitor', 283 phosphor_ramoops_monitor_sources, 284 phosphor_ramoops_monitor_dependency, 285 phosphor_ramoops_monitor_install, 286 phosphor_ramoops_monitor_incdir 287 ] 288 ] 289 290foreach executable : executables 291 binary = executable( 292 executable[0], 293 executable[1], 294 dependencies: executable[2], 295 install : executable[3], 296 include_directories : executable[4] 297 ) 298endforeach 299 300unit_subs = configuration_data() 301unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 302systemd_system_unit_dir = dependency('systemd').get_variable( 303 'systemdsystemunitdir', 304 pkgconfig_define: ['prefix', get_option('prefix')]) 305foreach 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 315if get_option('tests').allowed() 316 subdir('test') 317endif 318