1# SPDX-License-Identifier: Apache-2.0 2 3project('phosphor-debug-collector', 4 'cpp', 5 meson_version: '>= 0.57.0', 6 default_options: [ 7 'cpp_std=c++20', 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# Checking dependency external library 19 20libsystemd = dependency('libsystemd', version : '>=221') 21 22sdbusplus_dep = dependency('sdbusplus', required: false) 23if sdbusplus_dep.found() 24 sdbusplusplus_prog = find_program('sdbus++') 25 sdbuspp_gen_meson_prog = find_program('sdbus++-gen-meson') 26else 27 sdbusplus_proj = subproject('sdbusplus', required: true) 28 sdbusplus_dep = sdbusplus_proj.get_variable('sdbusplus_dep') 29 sdbusplusplus_prog = sdbusplus_proj.get_variable('sdbusplusplus_prog') 30 sdbuspp_gen_meson_prog = sdbusplus_proj.get_variable( 31 'sdbuspp_gen_meson_prog' 32 ) 33endif 34phosphor_dbus_interfaces_dep = dependency( 35 'phosphor-dbus-interfaces', 36 fallback: [ 37 'phosphor-dbus-interfaces', 38 'phosphor_dbus_interfaces_dep' 39 ], 40) 41phosphor_logging_dep = dependency( 42 'phosphor-logging', 43 fallback: [ 44 'phosphor-logging', 45 'phosphor_logging_dep' 46 ], 47) 48 49fmt_dep = dependency('fmt', required: false) 50if not fmt_dep.found() 51 fmt_proj = import('cmake').subproject( 52 'fmt', 53 cmake_options: [ 54 '-DCMAKE_POSITION_INDEPENDENT_CODE=ON', 55 '-DMASTER_PROJECT=OFF' 56 ], 57 required: false) 58 assert(fmt_proj.found(), 'fmtlib is required') 59 fmt_dep = fmt_proj.dependency('fmt') 60endif 61 62# Get Cereal dependency. 63cereal_dep = dependency('cereal', required: false) 64has_cereal = cpp.has_header_symbol( 65 'cereal/cereal.hpp', 66 'cereal::specialize', 67 dependencies: cereal_dep, 68 required: false) 69if not has_cereal 70 cereal_opts = import('cmake').subproject_options() 71 cereal_opts.add_cmake_defines({'BUILD_TESTS': 'OFF'}) 72 cereal_proj = import('cmake').subproject( 73 'cereal', 74 options: cereal_opts, 75 required: false) 76 assert(cereal_proj.found(), 'cereal is required') 77 cereal_dep = cereal_proj.dependency('cereal') 78endif 79 80# Disable FORTIFY_SOURCE when compiling with no optimization 81if(get_option('optimization') == '0') 82 add_project_arguments('-U_FORTIFY_SOURCE',language:['cpp','c']) 83 message('Disabling FORTIFY_SOURCE as optimization is set to 0') 84endif 85 86# Configuration header file(config.h) generation 87 88conf_data = configuration_data() 89 90conf_data.set_quoted('DUMP_BUSNAME', get_option('DUMP_BUSNAME'), 91 description : 'The Dbus busname to own' 92 ) 93conf_data.set_quoted('DUMP_OBJPATH', get_option('DUMP_OBJPATH'), 94 description : 'The Dump manager Dbus root' 95 ) 96conf_data.set_quoted('BMC_DUMP_OBJPATH', get_option('BMC_DUMP_OBJPATH'), 97 description : 'The BMC Dump manager Dbus path' 98 ) 99conf_data.set_quoted('CORE_FILE_DIR', get_option('CORE_FILE_DIR'), 100 description : 'Directory where core dumps are placed' 101 ) 102conf_data.set_quoted('OBJ_INTERNAL', get_option('OBJ_INTERNAL'), 103 description : 'Internal Dump manager Dbus object path' 104 ) 105conf_data.set_quoted('BMC_DUMP_OBJ_ENTRY', get_option('BMC_DUMP_OBJ_ENTRY'), 106 description : 'The BMC dump entry DBus object path' 107 ) 108conf_data.set_quoted('BMC_DUMP_PATH', get_option('BMC_DUMP_PATH'), 109 description : 'Directory where bmc dumps are placed') 110conf_data.set_quoted('SYSTEMD_PSTORE_PATH', get_option('SYSTEMD_PSTORE_PATH'), 111 description : 'Path to the systemd pstore directory') 112conf_data.set('BMC_DUMP_MAX_SIZE', get_option('BMC_DUMP_MAX_SIZE'), 113 description : 'Maximum size of one bmc dump in kilo bytes' 114 ) 115conf_data.set('BMC_DUMP_MIN_SPACE_REQD', get_option('BMC_DUMP_MIN_SPACE_REQD'), 116 description : 'Minimum space required for one bmc dump in kilo bytes' 117 ) 118conf_data.set('BMC_DUMP_TOTAL_SIZE', get_option('BMC_DUMP_TOTAL_SIZE'), 119 description : 'Total size of the dump in kilo bytes' 120 ) 121conf_data.set_quoted('OBJ_LOGGING', '/xyz/openbmc_project/logging', 122 description : 'The log manager DBus object path' 123 ) 124conf_data.set_quoted('ELOG_ID_PERSIST_PATH', get_option('ELOG_ID_PERSIST_PATH'), 125 description : 'Path of file for storing elog id\'s, which have associated dumps' 126 ) 127conf_data.set('CLASS_VERSION', get_option('CLASS_VERSION'), 128 description : 'Class version to register with Cereal' 129 ) 130conf_data.set('ERROR_MAP_YAML', get_option('ERROR_MAP_YAML'), 131 description : 'YAML filepath containing error object paths' 132 ) 133conf_data.set('JFFS_CORE_FILE_WORKAROUND', get_option('jffs-workaround').enabled(), 134 description : 'Turn on jffs workaround for core file' 135 ) 136 137configure_file(configuration : conf_data, 138 output : 'config.h' 139 ) 140 141subdir('xyz/openbmc_project/Dump/Internal/Create') 142 143python = find_program('python3') 144errors_map_gen_file_loc = meson.source_root() 145errors_map_gen_file_loc += '/errors_map_gen.py' 146 147errors_map_hpp = custom_target( 148 'errors_map.hpp', 149 command : [ 150 python, 151 errors_map_gen_file_loc, 152 '-i', 153 get_option('ERROR_MAP_YAML') 154 ], 155 depend_files : [ 'errors_map.mako.hpp', 156 'errors_map_gen.py', 157 get_option('ERROR_MAP_YAML') 158 ], 159 output : 'errors_map.hpp' 160 ) 161 162phosphor_dump_manager_sources = [ 163 'dump_entry.cpp', 164 'dump_manager.cpp', 165 'dump_manager_bmc.cpp', 166 'dump_manager_main.cpp', 167 'dump_serialize.cpp', 168 'elog_watch.cpp', 169 errors_map_hpp, 170 server_hpp, 171 server_cpp, 172 'watch.cpp', 173 'bmc_dump_entry.cpp', 174 'dump_utils.cpp', 175 'dump_offload.cpp' 176 ] 177 178phosphor_dump_manager_dependency = [ 179 phosphor_dbus_interfaces_dep, 180 sdbusplus_dep, 181 phosphor_logging_dep, 182 fmt_dep, 183 cereal_dep, 184 ] 185 186phosphor_dump_manager_install = true 187 188phosphor_dump_manager_incdir = [] 189 190# To get host transport based interface to take respective host 191# dump actions. It will contain required sources and dependency 192# list for phosphor_dump_manager. 193subdir('host-transport-extensions') 194 195#pick any architecture specific dumps 196subdir('dump-extensions') 197 198phosphor_dump_monitor_sources = [ 199 'core_manager.cpp', 200 'core_manager_main.cpp', 201 'watch.cpp' 202 ] 203 204phosphor_dump_monitor_dependency = [ 205 phosphor_dbus_interfaces_dep, 206 phosphor_logging_dep, 207 fmt_dep 208 ] 209 210phosphor_dump_monitor_install = true 211 212phosphor_dump_monitor_incdir = [] 213 214phosphor_ramoops_monitor_sources = [ 215 'ramoops_manager.cpp', 216 'ramoops_manager_main.cpp', 217 'watch.cpp' 218 ] 219 220phosphor_ramoops_monitor_dependency = [ 221 phosphor_dbus_interfaces_dep, 222 phosphor_logging_dep, 223 fmt_dep 224 ] 225 226phosphor_ramoops_monitor_install = true 227 228phosphor_ramoops_monitor_incdir = [] 229 230executables = [[ 'phosphor-dump-manager', 231 phosphor_dump_manager_sources, 232 phosphor_dump_manager_dependency, 233 phosphor_dump_manager_install, 234 phosphor_dump_manager_incdir 235 ], 236 [ 'phosphor-dump-monitor', 237 phosphor_dump_monitor_sources, 238 phosphor_dump_monitor_dependency, 239 phosphor_dump_monitor_install, 240 phosphor_dump_monitor_incdir 241 ], 242 [ 'phosphor-ramoops-monitor', 243 phosphor_ramoops_monitor_sources, 244 phosphor_ramoops_monitor_dependency, 245 phosphor_ramoops_monitor_install, 246 phosphor_ramoops_monitor_incdir 247 ] 248 ] 249 250foreach executable : executables 251 binary = executable( 252 executable[0], 253 executable[1], 254 dependencies: executable[2], 255 install : executable[3], 256 include_directories : executable[4] 257 ) 258endforeach 259 260if get_option('tests').enabled() 261 subdir('test') 262endif 263