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', 'SKIP_PERFORMANCE_COMPARISON': 'ON'}) 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('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'), 76 description : 'The BMC dump entry DBus object path' 77 ) 78conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'), 79 description : 'Directory where bmc dumps are placed') 80conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'), 81 description : 'Path to the systemd pstore directory') 82conf_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 ) 103conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').allowed(), 104 description : 'Turn on jffs workaround for core file' 105 ) 106conf_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 ) 115conf_data.set('BMC_DUMP_ROTATE_CONFIG', get_option('dump_rotate_config').allowed(), 116 description : 'Turn on rotate config for bmc dump' 117 ) 118 119configure_file(configuration : conf_data, 120 output : 'config.h' 121 ) 122 123dump_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.project_build_root() + '/' + yaml_file.get('output') + ' ' 138endforeach 139 140concatenate_command += '> ' + meson.project_build_root() + '/' + combined_yaml_file 141run_command('sh', '-c', concatenate_command) 142 143python = find_program('python3') 144map_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.project_build_root() + '/' + combined_yaml_file, 154 '-j', 155 get_option('ERROR_MAP_YAML'), 156 '-t', 157 'dump_types.mako.hpp', 158 '-o', 159 'dump_types.hpp' 160 ], 161 depend_files : [ 'dump_types.mako.hpp', 162 'map_gen.py', 163 meson.project_build_root() + '/' + combined_yaml_file, 164 get_option('ERROR_MAP_YAML') 165 ], 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.project_build_root() + '/' + combined_yaml_file, 176 '-j', 177 get_option('ERROR_MAP_YAML'), 178 '-t', 179 'dump_types.mako.cpp', 180 '-o', 181 'dump_types.cpp' 182 ], 183 depend_files : [ 'dump_types.mako.cpp', 184 'map_gen.py', 185 meson.project_build_root() + '/' + combined_yaml_file, 186 get_option('ERROR_MAP_YAML') 187 ], 188 output : 'dump_types.cpp' 189 ) 190 191phosphor_dump_manager_sources = [ 192 'dump_entry.cpp', 193 'dump_manager.cpp', 194 'dump_manager_bmc.cpp', 195 'dump_manager_main.cpp', 196 'dump_serialize.cpp', 197 'elog_watch.cpp', 198 dump_types_hpp, 199 dump_types_cpp, 200 'watch.cpp', 201 'bmc_dump_entry.cpp', 202 'dump_utils.cpp', 203 'dump_offload.cpp', 204 'dump_manager_faultlog.cpp', 205 'faultlog_dump_entry.cpp' 206 ] 207 208phosphor_dump_manager_dependency = [ 209 phosphor_dbus_interfaces_dep, 210 sdbusplus_dep, 211 sdeventplus_dep, 212 phosphor_logging_dep, 213 cereal_dep, 214 ] 215 216phosphor_dump_manager_install = true 217 218phosphor_dump_manager_incdir = [] 219 220# 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') 224 225#pick any architecture specific dumps 226subdir('dump-extensions') 227 228phosphor_dump_monitor_sources = [ 229 dump_types_hpp, 230 'core_manager.cpp', 231 'core_manager_main.cpp', 232 'watch.cpp' 233 ] 234 235phosphor_dump_monitor_dependency = [ 236 phosphor_dbus_interfaces_dep, 237 phosphor_logging_dep, 238 sdeventplus_dep, 239 ] 240 241phosphor_dump_monitor_install = true 242 243phosphor_dump_monitor_incdir = [] 244 245phosphor_ramoops_monitor_sources = [ 246 dump_types_hpp, 247 'ramoops_manager.cpp', 248 'ramoops_manager_main.cpp', 249 'watch.cpp' 250 ] 251 252phosphor_ramoops_monitor_dependency = [ 253 phosphor_dbus_interfaces_dep, 254 phosphor_logging_dep, 255 sdeventplus_dep, 256 ] 257 258phosphor_ramoops_monitor_install = true 259 260phosphor_ramoops_monitor_incdir = [] 261 262executables = [[ 'phosphor-dump-manager', 263 phosphor_dump_manager_sources, 264 phosphor_dump_manager_dependency, 265 phosphor_dump_manager_install, 266 phosphor_dump_manager_incdir 267 ], 268 [ 'phosphor-dump-monitor', 269 phosphor_dump_monitor_sources, 270 phosphor_dump_monitor_dependency, 271 phosphor_dump_monitor_install, 272 phosphor_dump_monitor_incdir 273 ], 274 [ 'phosphor-ramoops-monitor', 275 phosphor_ramoops_monitor_sources, 276 phosphor_ramoops_monitor_dependency, 277 phosphor_ramoops_monitor_install, 278 phosphor_ramoops_monitor_incdir 279 ] 280 ] 281 282foreach executable : executables 283 binary = executable( 284 executable[0], 285 executable[1], 286 dependencies: executable[2], 287 install : executable[3], 288 include_directories : executable[4] 289 ) 290endforeach 291 292unit_subs = configuration_data() 293unit_subs.set('bindir', join_paths(get_option('prefix'), get_option('bindir'))) 294systemd_system_unit_dir = dependency('systemd').get_variable( 295 'systemdsystemunitdir', 296 pkgconfig_define: ['prefix', get_option('prefix')]) 297foreach u : unit_files 298 configure_file( 299 configuration: unit_subs, 300 input: u.get('input'), 301 install: true, 302 install_dir: systemd_system_unit_dir, 303 output: u.get('output') 304 ) 305endforeach 306 307if get_option('tests').allowed() 308 subdir('test') 309endif 310